@@ -98,6 +98,7 @@ public class NearbyFragment extends CommonsDaggerSupportFragment
98
98
99
99
private boolean onOrientationChanged = false ;
100
100
private boolean populateForCurrentLocation = false ;
101
+ private boolean isNetworkErrorOccured = false ;
101
102
102
103
@ Override
103
104
public void onCreate (@ Nullable Bundle savedInstanceState ) {
@@ -124,7 +125,6 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
124
125
super .onViewCreated (view , savedInstanceState );
125
126
if (savedInstanceState != null ) {
126
127
onOrientationChanged = true ;
127
- refreshView (LOCATION_SIGNIFICANTLY_CHANGED );
128
128
}
129
129
}
130
130
@@ -225,7 +225,7 @@ public void onLocationChangedSignificantly(LatLng latLng) {
225
225
226
226
@ Override
227
227
public void onLocationChangedSlightly (LatLng latLng ) {
228
- refreshView (LOCATION_SLIGHTLY_CHANGED );
228
+ refreshView (LOCATION_SLIGHTLY_CHANGED );
229
229
}
230
230
231
231
@@ -333,7 +333,6 @@ public void refreshView(LocationServiceManager.LocationChangeType locationChange
333
333
* @param customLatLng Custom area which we will search around
334
334
*/
335
335
public void refreshViewForCustomLocation (LatLng customLatLng , boolean refreshForCurrentLocation ) {
336
-
337
336
if (customLatLng == null ) {
338
337
// If null, return
339
338
return ;
@@ -445,8 +444,7 @@ private void lockNearbyView(boolean lock) {
445
444
* @param nearbyPlacesInfo Includes nearby places list and boundary coordinates
446
445
*/
447
446
private void updateMapFragment (boolean updateViaButton , boolean isSlightUpdate , @ Nullable LatLng customLatLng , @ Nullable NearbyController .NearbyPlacesInfo nearbyPlacesInfo ) {
448
-
449
- if (nearbyMapFragment .searchThisAreaModeOn ) {
447
+ if (nearbyMapFragment .checkingAround ) {
450
448
return ;
451
449
}
452
450
/*
@@ -464,11 +462,14 @@ private void updateMapFragment(boolean updateViaButton, boolean isSlightUpdate,
464
462
* If we are close to nearby places boundaries, we need a significant update to
465
463
* get new nearby places. Check order is south, north, west, east
466
464
* */
467
- if (nearbyMapFragment .boundaryCoordinates != null && !nearbyMapFragment .searchThisAreaModeOn
468
- && (curLatLng .getLatitude () <= nearbyMapFragment .boundaryCoordinates [0 ].getLatitude ()
469
- || curLatLng .getLatitude () >= nearbyMapFragment .boundaryCoordinates [1 ].getLatitude ()
470
- || curLatLng .getLongitude () <= nearbyMapFragment .boundaryCoordinates [2 ].getLongitude ()
471
- || curLatLng .getLongitude () >= nearbyMapFragment .boundaryCoordinates [3 ].getLongitude ())) {
465
+ if (nearbyMapFragment .boundaryCoordinates != null
466
+ && !nearbyMapFragment .checkingAround
467
+ && !nearbyMapFragment .searchThisAreaModeOn
468
+ && !onOrientationChanged
469
+ && (curLatLng .getLatitude () < nearbyMapFragment .boundaryCoordinates [0 ].getLatitude ()
470
+ || curLatLng .getLatitude () > nearbyMapFragment .boundaryCoordinates [1 ].getLatitude ()
471
+ || curLatLng .getLongitude () < nearbyMapFragment .boundaryCoordinates [2 ].getLongitude ()
472
+ || curLatLng .getLongitude () > nearbyMapFragment .boundaryCoordinates [3 ].getLongitude ())) {
472
473
// populate places
473
474
placesDisposable = Observable .fromCallable (() -> nearbyController
474
475
.loadAttractionsFromLocation (curLatLng , curLatLng , false , updateViaButton ))
@@ -718,9 +719,13 @@ private void addNetworkBroadcastReceiver() {
718
719
public void onReceive (Context context , Intent intent ) {
719
720
if (snackbar != null && getActivity () != null ) {
720
721
if (NetworkUtils .isInternetConnectionEstablished (getActivity ())) {
721
- refreshView (LOCATION_SIGNIFICANTLY_CHANGED );
722
+ if (isNetworkErrorOccured ) {
723
+ refreshView (LOCATION_SIGNIFICANTLY_CHANGED );
724
+ isNetworkErrorOccured = false ;
725
+ }
722
726
snackbar .dismiss ();
723
727
} else {
728
+ isNetworkErrorOccured = true ;
724
729
snackbar .show ();
725
730
}
726
731
}
0 commit comments