@@ -98,6 +98,7 @@ public class NearbyFragment extends CommonsDaggerSupportFragment
9898
9999 private boolean onOrientationChanged = false ;
100100 private boolean populateForCurrentLocation = false ;
101+ private boolean isNetworkErrorOccured = false ;
101102
102103 @ Override
103104 public void onCreate (@ Nullable Bundle savedInstanceState ) {
@@ -124,7 +125,6 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
124125 super .onViewCreated (view , savedInstanceState );
125126 if (savedInstanceState != null ) {
126127 onOrientationChanged = true ;
127- refreshView (LOCATION_SIGNIFICANTLY_CHANGED );
128128 }
129129 }
130130
@@ -225,7 +225,7 @@ public void onLocationChangedSignificantly(LatLng latLng) {
225225
226226 @ Override
227227 public void onLocationChangedSlightly (LatLng latLng ) {
228- refreshView (LOCATION_SLIGHTLY_CHANGED );
228+ refreshView (LOCATION_SLIGHTLY_CHANGED );
229229 }
230230
231231
@@ -333,7 +333,6 @@ public void refreshView(LocationServiceManager.LocationChangeType locationChange
333333 * @param customLatLng Custom area which we will search around
334334 */
335335 public void refreshViewForCustomLocation (LatLng customLatLng , boolean refreshForCurrentLocation ) {
336-
337336 if (customLatLng == null ) {
338337 // If null, return
339338 return ;
@@ -445,8 +444,7 @@ private void lockNearbyView(boolean lock) {
445444 * @param nearbyPlacesInfo Includes nearby places list and boundary coordinates
446445 */
447446 private void updateMapFragment (boolean updateViaButton , boolean isSlightUpdate , @ Nullable LatLng customLatLng , @ Nullable NearbyController .NearbyPlacesInfo nearbyPlacesInfo ) {
448-
449- if (nearbyMapFragment .searchThisAreaModeOn ) {
447+ if (nearbyMapFragment .checkingAround ) {
450448 return ;
451449 }
452450 /*
@@ -464,11 +462,14 @@ private void updateMapFragment(boolean updateViaButton, boolean isSlightUpdate,
464462 * If we are close to nearby places boundaries, we need a significant update to
465463 * get new nearby places. Check order is south, north, west, east
466464 * */
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 ())) {
472473 // populate places
473474 placesDisposable = Observable .fromCallable (() -> nearbyController
474475 .loadAttractionsFromLocation (curLatLng , curLatLng , false , updateViaButton ))
@@ -718,9 +719,13 @@ private void addNetworkBroadcastReceiver() {
718719 public void onReceive (Context context , Intent intent ) {
719720 if (snackbar != null && getActivity () != null ) {
720721 if (NetworkUtils .isInternetConnectionEstablished (getActivity ())) {
721- refreshView (LOCATION_SIGNIFICANTLY_CHANGED );
722+ if (isNetworkErrorOccured ) {
723+ refreshView (LOCATION_SIGNIFICANTLY_CHANGED );
724+ isNetworkErrorOccured = false ;
725+ }
722726 snackbar .dismiss ();
723727 } else {
728+ isNetworkErrorOccured = true ;
724729 snackbar .show ();
725730 }
726731 }
0 commit comments