Skip to content

Commit e38450b

Browse files
authored
Merge pull request #1271 from commons-app/directNearbyUploadsNewLocal
Removes Manual Nearby Update Methods
2 parents 123c4ad + c9fdeeb commit e38450b

File tree

3 files changed

+17
-44
lines changed

3 files changed

+17
-44
lines changed

app/src/main/java/fr/free/nrw/commons/nearby/NearbyActivity.java

+7-23
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
7070
private NearbyMapFragment nearbyMapFragment;
7171
private static final String TAG_RETAINED_FRAGMENT = "RetainedFragment";
7272

73-
@BindView(R.id.swipe_container) SwipeRefreshLayout swipeLayout;
7473
@Override
7574
protected void onCreate(Bundle savedInstanceState) {
7675
super.onCreate(savedInstanceState);
@@ -81,13 +80,6 @@ protected void onCreate(Bundle savedInstanceState) {
8180

8281
initBottomSheetBehaviour();
8382
initDrawer();
84-
swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
85-
@Override
86-
public void onRefresh() {
87-
lockNearbyView(false);
88-
refreshView(true);
89-
}
90-
});
9183
}
9284

9385
private void resumeFragment() {
@@ -142,10 +134,6 @@ public boolean onCreateOptionsMenu(Menu menu) {
142134
public boolean onOptionsItemSelected(MenuItem item) {
143135
// Handle item selection
144136
switch (item.getItemId()) {
145-
case R.id.action_refresh:
146-
lockNearbyView(false);
147-
refreshView(true);
148-
return true;
149137
case R.id.action_display_list:
150138
bottomSheetBehaviorForDetails.setState(BottomSheetBehavior.STATE_HIDDEN);
151139
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
@@ -166,7 +154,7 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
166154
switch (requestCode) {
167155
case LOCATION_REQUEST: {
168156
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
169-
refreshView(false);
157+
refreshView();
170158
} else {
171159
//If permission not granted, go to page that says Nearby Places cannot be displayed
172160
hideProgressBar();
@@ -221,7 +209,7 @@ private void checkGps() {
221209
private void checkLocationPermission() {
222210
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
223211
if (locationManager.isLocationPermissionGranted()) {
224-
refreshView(false);
212+
refreshView();
225213
} else {
226214
// Should we show an explanation?
227215
if (locationManager.isPermissionExplanationRequired(this)) {
@@ -247,7 +235,7 @@ private void checkLocationPermission() {
247235
}
248236
}
249237
} else {
250-
refreshView(false);
238+
refreshView();
251239
}
252240
}
253241

@@ -256,7 +244,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
256244
super.onActivityResult(requestCode, resultCode, data);
257245
if (requestCode == 1) {
258246
Timber.d("User is back from Settings page");
259-
refreshView(false);
247+
refreshView();
260248
}
261249
}
262250

@@ -306,18 +294,15 @@ public void onPause() {
306294
/**
307295
* This method should be the single point to load/refresh nearby places
308296
*
309-
* @param isHardRefresh Should display a toast if the location hasn't changed
310297
*/
311-
private void refreshView(boolean isHardRefresh) {
298+
private void refreshView() {
312299
if (lockNearbyView) {
313300
return;
314301
}
315302
locationManager.registerLocationManager();
316303
LatLng lastLocation = locationManager.getLastLocation();
317304
if (curLatLang != null && curLatLang.equals(lastLocation)) { //refresh view only if location has changed
318-
if (isHardRefresh) {
319-
ViewUtil.showLongToast(this, R.string.nearby_location_has_not_changed);
320-
}
305+
321306
return;
322307
}
323308
curLatLang = lastLocation;
@@ -357,7 +342,6 @@ private void populatePlaces(List<Place> placeList) {
357342
setListFragment();
358343

359344
hideProgressBar();
360-
swipeLayout.setRefreshing(false);
361345
}
362346

363347
private void lockNearbyView(boolean lock) {
@@ -403,7 +387,7 @@ private void setListFragment() {
403387

404388
@Override
405389
public void onLocationChanged(LatLng latLng) {
406-
refreshView(false);
390+
refreshView();
407391
}
408392

409393
public void prepareViewsForSheetPosition(int bottomSheetState) {

app/src/main/res/layout/activity_nearby.xml

+10-13
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,16 @@
2626
android:layout_below="@id/toolbar"
2727
android:gravity="center_vertical"
2828
android:orientation="horizontal">
29-
<ProgressBar
30-
android:id="@+id/progressBar"
31-
android:layout_width="match_parent"
32-
android:layout_height="wrap_content" />
33-
<android.support.v4.widget.SwipeRefreshLayout
34-
android:id="@+id/swipe_container"
35-
android:layout_width="match_parent"
36-
android:layout_height="match_parent">
37-
<FrameLayout
38-
android:id="@+id/container"
39-
android:layout_width="match_parent"
40-
android:layout_height="match_parent" />
41-
</android.support.v4.widget.SwipeRefreshLayout>
29+
30+
<ProgressBar
31+
android:id="@+id/progressBar"
32+
android:layout_width="match_parent"
33+
android:layout_height="wrap_content" />
34+
35+
<FrameLayout
36+
android:id="@+id/container"
37+
android:layout_width="match_parent"
38+
android:layout_height="match_parent" />
4239
</LinearLayout>
4340
<android.support.design.widget.FloatingActionButton
4441
android:id="@+id/fab_list"

app/src/main/res/menu/menu_nearby.xml

-8
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,4 @@
1010
app:showAsAction="ifRoom"
1111
/>
1212

13-
<item
14-
android:id="@+id/action_refresh"
15-
android:title="@string/refresh_button"
16-
android:icon="@drawable/ic_refresh_white_24dp"
17-
android:orderInCategory="1"
18-
app:showAsAction="ifRoom"
19-
/>
20-
2113
</menu>

0 commit comments

Comments
 (0)