State: Map ready call is not called but permissions and methods are in correct order

This commit is contained in:
neslihanturan 2019-07-02 18:45:19 +03:00
parent f6c1d27382
commit 2e7365e902
2 changed files with 7 additions and 5 deletions

View file

@ -138,9 +138,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
// Resume the fragment if exist // Resume the fragment if exist
resumeFragment(); resumeFragment();
if (!((MainActivity) getActivity()).isContributionsFragmentVisible) { if (!((MainActivity) getActivity()).isContributionsFragmentVisible) {
checkPermissionsAndPerformAction(this::resumeFragment); checkPermissionsAndPerformAction(nearbyParentFragmentPresenter::performNearbyOperationsIfPermissionGiven);
} else {
resumeFragment();
} }
} }
@ -154,7 +152,6 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
R.string.location_permission_rationale_nearby); R.string.location_permission_rationale_nearby);
} }
/** /**
* Thanks to this method we make sure NearbyMapFragment is ready and attached. So that we can * Thanks to this method we make sure NearbyMapFragment is ready and attached. So that we can
* prevent NPE caused by null child fragment. This method is called from child fragment when * prevent NPE caused by null child fragment. This method is called from child fragment when

View file

@ -99,7 +99,12 @@ public class NearbyParentFragmentPresenter
Timber.d("initializing nearby operations started"); Timber.d("initializing nearby operations started");
// Add location listener to be notified about location changes // Add location listener to be notified about location changes
locationServiceManager.addLocationListener(this); locationServiceManager.addLocationListener(this);
nearbyParentFragmentView.checkPermissionsAndPerformAction(nearbyParentFragmentView::resumeFragment); nearbyParentFragmentView.checkPermissionsAndPerformAction(this::performNearbyOperationsIfPermissionGiven);
}
public void performNearbyOperationsIfPermissionGiven() {
Timber.d("performNearbyOperationsIfPermissionGiven");
nearbyParentFragmentView.registerLocationUpdates(locationServiceManager); nearbyParentFragmentView.registerLocationUpdates(locationServiceManager);
// Nearby buttons should be active, they should be inactive only during update // Nearby buttons should be active, they should be inactive only during update
lockNearby(false); lockNearby(false);