Make boundary check work (finally)

This commit is contained in:
neslihanturan 2018-02-24 12:23:36 +03:00
parent 35ebe0f7a3
commit 0df35beab2

View file

@ -20,6 +20,8 @@ import android.widget.Toast;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import java.util.List; import java.util.List;
@ -383,7 +385,7 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
} }
private void lockNearbyView(boolean lock) { private void lockNearbyView(boolean lock) {
/*if (lock) { if (lock) {
lockNearbyView = true; lockNearbyView = true;
locationManager.unregisterLocationManager(); locationManager.unregisterLocationManager();
locationManager.removeLocationListener(this); locationManager.removeLocationListener(this);
@ -391,7 +393,7 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
lockNearbyView = false; lockNearbyView = false;
locationManager.registerLocationManager(); locationManager.registerLocationManager();
locationManager.addLocationListener(this); locationManager.addLocationListener(this);
}*/ }
} }
private void hideProgressBar() { private void hideProgressBar() {
@ -420,10 +422,18 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
* If we are close to nearby places boundaries, we need a significant update to * If we are close to nearby places boundaries, we need a significant update to
* get new nearby places. Check order is south, north, west, east * get new nearby places. Check order is south, north, west, east
* */ * */
hideProgressBar(); // In case it is visible (this happens, not an impossible case)
if (curLatLang.getLatitude() <= nearbyMapFragment.boundaryCoordinates[0].getLatitude() if (curLatLang.getLatitude() <= nearbyMapFragment.boundaryCoordinates[0].getLatitude()
|| curLatLang.getLatitude() >= nearbyMapFragment.boundaryCoordinates[1].getLatitude() || curLatLang.getLatitude() >= nearbyMapFragment.boundaryCoordinates[1].getLatitude()
|| curLatLang.getLongitude() <= nearbyMapFragment.boundaryCoordinates[2].getLongitude() || curLatLang.getLongitude() <= nearbyMapFragment.boundaryCoordinates[2].getLongitude()
|| curLatLang.getLongitude() >= nearbyMapFragment.boundaryCoordinates[3].getLongitude()) { || curLatLang.getLongitude() >= nearbyMapFragment.boundaryCoordinates[3].getLongitude()) {
// populate places
placesDisposable = Observable.fromCallable(() -> nearbyController
.loadAttractionsFromLocation(curLatLang))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::populatePlaces);
nearbyMapFragment.setArguments(bundle); nearbyMapFragment.setArguments(bundle);
nearbyMapFragment.updateMapSignificantly(); nearbyMapFragment.updateMapSignificantly();
return; return;
@ -436,6 +446,13 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
nearbyMapFragment.setArguments(bundle); nearbyMapFragment.setArguments(bundle);
nearbyMapFragment.updateMapSignificantly(); nearbyMapFragment.updateMapSignificantly();
} }
} else {
lockNearbyView(true);
setMapFragment();
setListFragment();
hideProgressBar();
lockNearbyView(false);
} }
} }
@ -481,4 +498,5 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
public void prepareViewsForSheetPosition(int bottomSheetState) { public void prepareViewsForSheetPosition(int bottomSheetState) {
// TODO // TODO
} }
} }