Change method calls loadAttractionsFromLocation by considering new parameter to decide between closest nearby call or an usual nearby call

This commit is contained in:
neslihanturan 2018-09-18 14:16:05 +03:00
parent 735b4430c6
commit 7de3ad8b89

View file

@ -173,7 +173,7 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
// If dismissed, we can inform fragment to start showcase sequence there // If dismissed, we can inform fragment to start showcase sequence there
@Override @Override
public void onShowcaseDismissed(MaterialShowcaseView materialShowcaseView) { public void onShowcaseDismissed(MaterialShowcaseView materialShowcaseView) {
nearbyMapFragment.onNearbyMaterialShowcaseDismissed(); nearbyMapFragment.onNearbyMaterialShowcaseDismissed();
} }
}) })
.build(); .build();
@ -435,7 +435,7 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
bundle.putString("CurLatLng", gsonCurLatLng); bundle.putString("CurLatLng", gsonCurLatLng);
placesDisposable = Observable.fromCallable(() -> nearbyController placesDisposable = Observable.fromCallable(() -> nearbyController
.loadAttractionsFromLocation(curLatLng)) .loadAttractionsFromLocation(curLatLng, false))
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(this::populatePlaces, .subscribe(this::populatePlaces,
@ -525,12 +525,12 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
} }
public void setMapViewTutorialShowCase() { public void setMapViewTutorialShowCase() {
/* /*
*This showcase view will be the first step of our nearbyMaterialShowcaseSequence. The reason we use a *This showcase view will be the first step of our nearbyMaterialShowcaseSequence. The reason we use a
* single item instead of adding another step to nearbyMaterialShowcaseSequence is that we are not able to * single item instead of adding another step to nearbyMaterialShowcaseSequence is that we are not able to
* call withoutShape() method on steps. For mapView we need an showcase view without * call withoutShape() method on steps. For mapView we need an showcase view without
* any circle on it, it should cover the whole page. * any circle on it, it should cover the whole page.
* */ * */
MaterialShowcaseView firstSingleShowCaseView = new MaterialShowcaseView.Builder(this) MaterialShowcaseView firstSingleShowCaseView = new MaterialShowcaseView.Builder(this)
.setTarget(nearbyMapFragment.mapView) .setTarget(nearbyMapFragment.mapView)
.setDismissText(getString(R.string.showcase_view_got_it_button)) .setDismissText(getString(R.string.showcase_view_got_it_button))
@ -547,9 +547,9 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
@Override @Override
public void onShowcaseDismissed(MaterialShowcaseView materialShowcaseView) { public void onShowcaseDismissed(MaterialShowcaseView materialShowcaseView) {
/* Add other nearbyMaterialShowcaseSequence here, it will make the user feel as they are a /* Add other nearbyMaterialShowcaseSequence here, it will make the user feel as they are a
* nearbyMaterialShowcaseSequence whole together. * nearbyMaterialShowcaseSequence whole together.
* */ * */
secondSingleShowCaseView.show(NearbyActivity.this); secondSingleShowCaseView.show(NearbyActivity.this);
} }
}) })
@ -605,21 +605,21 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
private void updateMapFragment(boolean isSlightUpdate) { private void updateMapFragment(boolean isSlightUpdate) {
/* /*
* Significant update means updating nearby place markers. Slightly update means only * Significant update means updating nearby place markers. Slightly update means only
* updating current location marker and camera target. * updating current location marker and camera target.
* We update our map Significantly on each 1000 meter change, but we can't never know * We update our map Significantly on each 1000 meter change, but we can't never know
* the frequency of nearby places. Thus we check if we are close to the boundaries of * the frequency of nearby places. Thus we check if we are close to the boundaries of
* our nearby markers, we update our map Significantly. * our nearby markers, we update our map Significantly.
* */ * */
NearbyMapFragment nearbyMapFragment = getMapFragment(); NearbyMapFragment nearbyMapFragment = getMapFragment();
if (nearbyMapFragment != null && curLatLng != null) { if (nearbyMapFragment != null && curLatLng != null) {
hideProgressBar(); // In case it is visible (this happens, not an impossible case) hideProgressBar(); // In case it is visible (this happens, not an impossible case)
/* /*
* 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
* */ * */
if (nearbyMapFragment.boundaryCoordinates != null if (nearbyMapFragment.boundaryCoordinates != null
&& (curLatLng.getLatitude() <= nearbyMapFragment.boundaryCoordinates[0].getLatitude() && (curLatLng.getLatitude() <= nearbyMapFragment.boundaryCoordinates[0].getLatitude()
|| curLatLng.getLatitude() >= nearbyMapFragment.boundaryCoordinates[1].getLatitude() || curLatLng.getLatitude() >= nearbyMapFragment.boundaryCoordinates[1].getLatitude()
@ -627,7 +627,7 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
|| curLatLng.getLongitude() >= nearbyMapFragment.boundaryCoordinates[3].getLongitude())) { || curLatLng.getLongitude() >= nearbyMapFragment.boundaryCoordinates[3].getLongitude())) {
// populate places // populate places
placesDisposable = Observable.fromCallable(() -> nearbyController placesDisposable = Observable.fromCallable(() -> nearbyController
.loadAttractionsFromLocation(curLatLng)) .loadAttractionsFromLocation(curLatLng, false))
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(this::populatePlaces, .subscribe(this::populatePlaces,