mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Merge pull request #1271 from commons-app/directNearbyUploadsNewLocal
Removes Manual Nearby Update Methods
This commit is contained in:
commit
e38450b4fd
3 changed files with 17 additions and 44 deletions
|
|
@ -70,7 +70,6 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
|
||||||
private NearbyMapFragment nearbyMapFragment;
|
private NearbyMapFragment nearbyMapFragment;
|
||||||
private static final String TAG_RETAINED_FRAGMENT = "RetainedFragment";
|
private static final String TAG_RETAINED_FRAGMENT = "RetainedFragment";
|
||||||
|
|
||||||
@BindView(R.id.swipe_container) SwipeRefreshLayout swipeLayout;
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
@ -81,13 +80,6 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
|
||||||
|
|
||||||
initBottomSheetBehaviour();
|
initBottomSheetBehaviour();
|
||||||
initDrawer();
|
initDrawer();
|
||||||
swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
|
||||||
@Override
|
|
||||||
public void onRefresh() {
|
|
||||||
lockNearbyView(false);
|
|
||||||
refreshView(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resumeFragment() {
|
private void resumeFragment() {
|
||||||
|
|
@ -142,10 +134,6 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
// Handle item selection
|
// Handle item selection
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.action_refresh:
|
|
||||||
lockNearbyView(false);
|
|
||||||
refreshView(true);
|
|
||||||
return true;
|
|
||||||
case R.id.action_display_list:
|
case R.id.action_display_list:
|
||||||
bottomSheetBehaviorForDetails.setState(BottomSheetBehavior.STATE_HIDDEN);
|
bottomSheetBehaviorForDetails.setState(BottomSheetBehavior.STATE_HIDDEN);
|
||||||
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||||
|
|
@ -166,7 +154,7 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
case LOCATION_REQUEST: {
|
case LOCATION_REQUEST: {
|
||||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
refreshView(false);
|
refreshView();
|
||||||
} else {
|
} else {
|
||||||
//If permission not granted, go to page that says Nearby Places cannot be displayed
|
//If permission not granted, go to page that says Nearby Places cannot be displayed
|
||||||
hideProgressBar();
|
hideProgressBar();
|
||||||
|
|
@ -221,7 +209,7 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
|
||||||
private void checkLocationPermission() {
|
private void checkLocationPermission() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
if (locationManager.isLocationPermissionGranted()) {
|
if (locationManager.isLocationPermissionGranted()) {
|
||||||
refreshView(false);
|
refreshView();
|
||||||
} else {
|
} else {
|
||||||
// Should we show an explanation?
|
// Should we show an explanation?
|
||||||
if (locationManager.isPermissionExplanationRequired(this)) {
|
if (locationManager.isPermissionExplanationRequired(this)) {
|
||||||
|
|
@ -247,7 +235,7 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
refreshView(false);
|
refreshView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -256,7 +244,7 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
if (requestCode == 1) {
|
if (requestCode == 1) {
|
||||||
Timber.d("User is back from Settings page");
|
Timber.d("User is back from Settings page");
|
||||||
refreshView(false);
|
refreshView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -306,18 +294,15 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
|
||||||
/**
|
/**
|
||||||
* This method should be the single point to load/refresh nearby places
|
* This method should be the single point to load/refresh nearby places
|
||||||
*
|
*
|
||||||
* @param isHardRefresh Should display a toast if the location hasn't changed
|
|
||||||
*/
|
*/
|
||||||
private void refreshView(boolean isHardRefresh) {
|
private void refreshView() {
|
||||||
if (lockNearbyView) {
|
if (lockNearbyView) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
locationManager.registerLocationManager();
|
locationManager.registerLocationManager();
|
||||||
LatLng lastLocation = locationManager.getLastLocation();
|
LatLng lastLocation = locationManager.getLastLocation();
|
||||||
if (curLatLang != null && curLatLang.equals(lastLocation)) { //refresh view only if location has changed
|
if (curLatLang != null && curLatLang.equals(lastLocation)) { //refresh view only if location has changed
|
||||||
if (isHardRefresh) {
|
|
||||||
ViewUtil.showLongToast(this, R.string.nearby_location_has_not_changed);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
curLatLang = lastLocation;
|
curLatLang = lastLocation;
|
||||||
|
|
@ -357,7 +342,6 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
|
||||||
setListFragment();
|
setListFragment();
|
||||||
|
|
||||||
hideProgressBar();
|
hideProgressBar();
|
||||||
swipeLayout.setRefreshing(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void lockNearbyView(boolean lock) {
|
private void lockNearbyView(boolean lock) {
|
||||||
|
|
@ -403,7 +387,7 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLocationChanged(LatLng latLng) {
|
public void onLocationChanged(LatLng latLng) {
|
||||||
refreshView(false);
|
refreshView();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void prepareViewsForSheetPosition(int bottomSheetState) {
|
public void prepareViewsForSheetPosition(int bottomSheetState) {
|
||||||
|
|
|
||||||
|
|
@ -26,19 +26,16 @@
|
||||||
android:layout_below="@id/toolbar"
|
android:layout_below="@id/toolbar"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
<ProgressBar
|
|
||||||
android:id="@+id/progressBar"
|
<ProgressBar
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/progressBar"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_width="match_parent"
|
||||||
<android.support.v4.widget.SwipeRefreshLayout
|
android:layout_height="wrap_content" />
|
||||||
android:id="@+id/swipe_container"
|
|
||||||
android:layout_width="match_parent"
|
<FrameLayout
|
||||||
android:layout_height="match_parent">
|
android:id="@+id/container"
|
||||||
<FrameLayout
|
android:layout_width="match_parent"
|
||||||
android:id="@+id/container"
|
android:layout_height="match_parent" />
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent" />
|
|
||||||
</android.support.v4.widget.SwipeRefreshLayout>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<android.support.design.widget.FloatingActionButton
|
<android.support.design.widget.FloatingActionButton
|
||||||
android:id="@+id/fab_list"
|
android:id="@+id/fab_list"
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,4 @@
|
||||||
app:showAsAction="ifRoom"
|
app:showAsAction="ifRoom"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/action_refresh"
|
|
||||||
android:title="@string/refresh_button"
|
|
||||||
android:icon="@drawable/ic_refresh_white_24dp"
|
|
||||||
android:orderInCategory="1"
|
|
||||||
app:showAsAction="ifRoom"
|
|
||||||
/>
|
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue