Remove toggle view code

This commit is contained in:
neslihanturan 2017-12-14 16:57:00 +03:00
parent 56cdf56430
commit dc294b8b97
4 changed files with 3 additions and 44 deletions

View file

@ -48,7 +48,6 @@ import timber.log.Timber;
public class NearbyActivity extends NavigationBaseActivity implements LocationUpdateListener { public class NearbyActivity extends NavigationBaseActivity implements LocationUpdateListener {
private static final int LOCATION_REQUEST = 1; private static final int LOCATION_REQUEST = 1;
private static final String MAP_LAST_USED_PREFERENCE = "mapLastUsed";
@BindView(R.id.progressBar) @BindView(R.id.progressBar)
ProgressBar progressBar; ProgressBar progressBar;
@ -69,7 +68,6 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
private LatLng curLatLang; private LatLng curLatLang;
private Bundle bundle; private Bundle bundle;
private SharedPreferences sharedPreferences;
private NearbyActivityMode viewMode; private NearbyActivityMode viewMode;
private Disposable placesDisposable; private Disposable placesDisposable;
private boolean lockNearbyView; //Determines if the nearby places needs to be refreshed private boolean lockNearbyView; //Determines if the nearby places needs to be refreshed
@ -81,7 +79,6 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
setContentView(R.layout.activity_nearby); setContentView(R.layout.activity_nearby);
ButterKnife.bind(this); ButterKnife.bind(this);
resumeFragment(); resumeFragment();
@ -91,7 +88,6 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
initFabList(); initFabList();
initDrawer(); initDrawer();
initViewState();
} }
private void resumeFragment() { private void resumeFragment() {
@ -109,14 +105,6 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
} }
private void initViewState() {
if (sharedPreferences.getBoolean(MAP_LAST_USED_PREFERENCE, false)) {
viewMode = NearbyActivityMode.MAP;
} else {
viewMode = NearbyActivityMode.LIST;
}
}
private void initBottomSheetBehaviour() { private void initBottomSheetBehaviour() {
transparentView.setAlpha(0); transparentView.setAlpha(0);
@ -157,11 +145,6 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
MenuInflater inflater = getMenuInflater(); MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_nearby, menu); inflater.inflate(R.menu.menu_nearby, menu);
if (viewMode.isMap()) {
MenuItem item = menu.findItem(R.id.action_toggle_view);
item.setIcon(viewMode.getIcon());
}
return super.onCreateOptionsMenu(menu); return super.onCreateOptionsMenu(menu);
} }
@ -173,11 +156,6 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
lockNearbyView(false); lockNearbyView(false);
refreshView(true); refreshView(true);
return true; return true;
case R.id.action_toggle_view:
viewMode = viewMode.toggle();
item.setIcon(viewMode.getIcon());
toggleView();
return true;
default: default:
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@ -288,15 +266,6 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
} }
} }
private void toggleView() {
if (viewMode.isMap()) {
setMapFragment();
} else {
setListFragment();
}
sharedPreferences.edit().putBoolean(MAP_LAST_USED_PREFERENCE, viewMode.isMap()).apply();
}
@Override @Override
protected void onStart() { protected void onStart() {
super.onStart(); super.onStart();
@ -456,7 +425,6 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
} }
else if (bottomSheetState == BottomSheetBehavior.STATE_EXPANDED) { else if (bottomSheetState == BottomSheetBehavior.STATE_EXPANDED) {
fabList.hide(); fabList.hide();
//NearbyActivity.bottomSheetStatus = BottomSheetStatus.DISPLAY_LIST_SHEET;
} }
} }
} }

View file

@ -21,8 +21,7 @@
android:id="@+id/icon" android:id="@+id/icon"
android:layout_width="40dp" android:layout_width="40dp"
android:layout_height="40dp" android:layout_height="40dp"
android:layout_marginLeft="16dp" android:layout_marginLeft="16dp">
android:src="@drawable/ic_launcher">
</ImageView> </ImageView>
<LinearLayout <LinearLayout
@ -72,7 +71,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
app:srcCompat="@drawable/ic_directions_black_48dp" /> app:srcCompat="@drawable/ic_directions_black_24dp" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View file

@ -4,7 +4,7 @@
android:id="@+id/buttonLayout" android:id="@+id/buttonLayout"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal" android:orientation="horizontal"
android:visibility="visible" android:visibility="gone"
android:layout_below="@+id/icon" android:layout_below="@+id/icon"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
> >

View file

@ -2,14 +2,6 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity"> xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
<item
android:id="@+id/action_toggle_view"
android:title="@string/refresh_button"
android:icon="@drawable/ic_map_white_24dp"
android:orderInCategory="1"
app:showAsAction="ifRoom"
/>
<item <item
android:id="@+id/action_refresh" android:id="@+id/action_refresh"
android:title="@string/refresh_button" android:title="@string/refresh_button"