mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Add lock neabry method to unlisten nearby operations during updates
This commit is contained in:
parent
a8190bb8b1
commit
f8e8d13b78
2 changed files with 26 additions and 0 deletions
|
|
@ -20,5 +20,6 @@ public interface NearbyParentFragmentContract {
|
|||
void onTabSelected();
|
||||
void initializeNearbyOperations();
|
||||
void updateMapAndList(LocationServiceManager.LocationChangeType locationChangeType);
|
||||
void lockNearby(boolean isNearbyLocked);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import fr.free.nrw.commons.location.LocationServiceManager;
|
|||
import fr.free.nrw.commons.location.LocationUpdateListener;
|
||||
import fr.free.nrw.commons.nearby.mvp.contract.NearbyParentFragmentContract;
|
||||
import fr.free.nrw.commons.wikidata.WikidataEditListener;
|
||||
import timber.log.Timber;
|
||||
|
||||
public class NearbyParentFragmentPresenter
|
||||
implements NearbyParentFragmentContract.UserActions,
|
||||
|
|
@ -16,6 +17,7 @@ public class NearbyParentFragmentPresenter
|
|||
LocationServiceManager locationManager;
|
||||
|
||||
private NearbyParentFragmentContract.View nearbyParentFragmentView;
|
||||
private boolean isNearbyLocked;
|
||||
|
||||
public NearbyParentFragmentPresenter(NearbyParentFragmentContract.View nearbyParentFragmentView) {
|
||||
this.nearbyParentFragmentView = nearbyParentFragmentView;
|
||||
|
|
@ -43,6 +45,23 @@ public class NearbyParentFragmentPresenter
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Nearby updates takes time, since they are network operations. During update time, we don't
|
||||
* want to get any other calls from user. So locking nearby.
|
||||
* @param isNearbyLocked true means lock, false means unlock
|
||||
*/
|
||||
@Override
|
||||
public void lockNearby(boolean isNearbyLocked) {
|
||||
this.isNearbyLocked = isNearbyLocked;
|
||||
if (isNearbyLocked) {
|
||||
locationManager.unregisterLocationManager();
|
||||
locationManager.removeLocationListener(this);
|
||||
} else {
|
||||
nearbyParentFragmentView.registerLocationUpdates(locationManager);
|
||||
locationManager.addLocationListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method should be the single point to update Map and List. Triggered by location
|
||||
* changes
|
||||
|
|
@ -50,6 +69,12 @@ public class NearbyParentFragmentPresenter
|
|||
*/
|
||||
@Override
|
||||
public void updateMapAndList(LocationServiceManager.LocationChangeType locationChangeType) {
|
||||
if (isNearbyLocked) {
|
||||
Timber.d("Nearby is locked, so updateMapAndList returns");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue