@@ -70,7 +70,6 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
70
70
private NearbyMapFragment nearbyMapFragment ;
71
71
private static final String TAG_RETAINED_FRAGMENT = "RetainedFragment" ;
72
72
73
- @ BindView (R .id .swipe_container ) SwipeRefreshLayout swipeLayout ;
74
73
@ Override
75
74
protected void onCreate (Bundle savedInstanceState ) {
76
75
super .onCreate (savedInstanceState );
@@ -81,13 +80,6 @@ protected void onCreate(Bundle savedInstanceState) {
81
80
82
81
initBottomSheetBehaviour ();
83
82
initDrawer ();
84
- swipeLayout .setOnRefreshListener (new SwipeRefreshLayout .OnRefreshListener () {
85
- @ Override
86
- public void onRefresh () {
87
- lockNearbyView (false );
88
- refreshView (true );
89
- }
90
- });
91
83
}
92
84
93
85
private void resumeFragment () {
@@ -142,10 +134,6 @@ public boolean onCreateOptionsMenu(Menu menu) {
142
134
public boolean onOptionsItemSelected (MenuItem item ) {
143
135
// Handle item selection
144
136
switch (item .getItemId ()) {
145
- case R .id .action_refresh :
146
- lockNearbyView (false );
147
- refreshView (true );
148
- return true ;
149
137
case R .id .action_display_list :
150
138
bottomSheetBehaviorForDetails .setState (BottomSheetBehavior .STATE_HIDDEN );
151
139
bottomSheetBehavior .setState (BottomSheetBehavior .STATE_EXPANDED );
@@ -166,7 +154,7 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
166
154
switch (requestCode ) {
167
155
case LOCATION_REQUEST : {
168
156
if (grantResults .length > 0 && grantResults [0 ] == PackageManager .PERMISSION_GRANTED ) {
169
- refreshView (false );
157
+ refreshView ();
170
158
} else {
171
159
//If permission not granted, go to page that says Nearby Places cannot be displayed
172
160
hideProgressBar ();
@@ -221,7 +209,7 @@ private void checkGps() {
221
209
private void checkLocationPermission () {
222
210
if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .M ) {
223
211
if (locationManager .isLocationPermissionGranted ()) {
224
- refreshView (false );
212
+ refreshView ();
225
213
} else {
226
214
// Should we show an explanation?
227
215
if (locationManager .isPermissionExplanationRequired (this )) {
@@ -247,7 +235,7 @@ private void checkLocationPermission() {
247
235
}
248
236
}
249
237
} else {
250
- refreshView (false );
238
+ refreshView ();
251
239
}
252
240
}
253
241
@@ -256,7 +244,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
256
244
super .onActivityResult (requestCode , resultCode , data );
257
245
if (requestCode == 1 ) {
258
246
Timber .d ("User is back from Settings page" );
259
- refreshView (false );
247
+ refreshView ();
260
248
}
261
249
}
262
250
@@ -306,18 +294,15 @@ public void onPause() {
306
294
/**
307
295
* This method should be the single point to load/refresh nearby places
308
296
*
309
- * @param isHardRefresh Should display a toast if the location hasn't changed
310
297
*/
311
- private void refreshView (boolean isHardRefresh ) {
298
+ private void refreshView () {
312
299
if (lockNearbyView ) {
313
300
return ;
314
301
}
315
302
locationManager .registerLocationManager ();
316
303
LatLng lastLocation = locationManager .getLastLocation ();
317
304
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
+
321
306
return ;
322
307
}
323
308
curLatLang = lastLocation ;
@@ -357,7 +342,6 @@ private void populatePlaces(List<Place> placeList) {
357
342
setListFragment ();
358
343
359
344
hideProgressBar ();
360
- swipeLayout .setRefreshing (false );
361
345
}
362
346
363
347
private void lockNearbyView (boolean lock ) {
@@ -403,7 +387,7 @@ private void setListFragment() {
403
387
404
388
@ Override
405
389
public void onLocationChanged (LatLng latLng ) {
406
- refreshView (false );
390
+ refreshView ();
407
391
}
408
392
409
393
public void prepareViewsForSheetPosition (int bottomSheetState ) {
0 commit comments