Request permission for nearby places if fragment is loaded and tab is selected

This commit is contained in:
neslihanturan 2019-09-02 15:13:56 +03:00
parent aa7fb84313
commit d858813a01
3 changed files with 6 additions and 2 deletions

View file

@ -110,6 +110,7 @@ public class NearbyTestFragmentLayersActivity extends AuthenticatedActivity {
case NEARBY_TAB_POSITION: case NEARBY_TAB_POSITION:
Timber.d("Nearby tab selected"); Timber.d("Nearby tab selected");
tabLayout.getTabAt(NEARBY_TAB_POSITION).select(); tabLayout.getTabAt(NEARBY_TAB_POSITION).select();
((NearbyTestLayersFragment)contributionsActivityPagerAdapter.getItem(1)).nearbyParentFragmentPresenter.onTabSelected();
break; break;
default: default:
tabLayout.getTabAt(CONTRIBUTIONS_TAB_POSITION).select(); tabLayout.getTabAt(CONTRIBUTIONS_TAB_POSITION).select();

View file

@ -114,8 +114,8 @@ public class NearbyTestLayersFragment extends CommonsDaggerSupportFragment imple
nearbyParentFragmentPresenter = new NearbyParentFragmentPresenter nearbyParentFragmentPresenter = new NearbyParentFragmentPresenter
(this, mapFragment, locationManager); (this, mapFragment, locationManager);
Timber.d("Child fragment attached"); Timber.d("Child fragment attached");
// TODO: find out why location manager is null nearbyParentFragmentPresenter.nearbyFragmentsAreReady();
checkPermissionsAndPerformAction(this::registerLocationUpdates); //checkPermissionsAndPerformAction(this::registerLocationUpdates);
} }
@Override @Override
@ -178,6 +178,7 @@ public class NearbyTestLayersFragment extends CommonsDaggerSupportFragment imple
@Override @Override
public void checkPermissionsAndPerformAction(Runnable runnable) { public void checkPermissionsAndPerformAction(Runnable runnable) {
Log.d("denemeTest","checkPermissionsAndPerformAction is called");
PermissionUtils.checkPermissionsAndPerformAction(getActivity(), PermissionUtils.checkPermissionsAndPerformAction(getActivity(),
Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION,
runnable, runnable,

View file

@ -67,6 +67,7 @@ public class NearbyParentFragmentPresenter
@Override @Override
public void onTabSelected() { public void onTabSelected() {
Timber.d("Nearby tab selected"); Timber.d("Nearby tab selected");
Log.d("denemeTest","Nearby tab selected");
onTabSelected = true; onTabSelected = true;
// The condition for initialize operations is both having views ready and tab is selected // The condition for initialize operations is both having views ready and tab is selected
if (nearbyViewsAreReady) { if (nearbyViewsAreReady) {
@ -81,6 +82,7 @@ public class NearbyParentFragmentPresenter
@Override @Override
public void nearbyFragmentsAreReady() { public void nearbyFragmentsAreReady() {
Timber.d("Nearby fragments are ready to be used by presenter"); Timber.d("Nearby fragments are ready to be used by presenter");
Log.d("denemeTest","nearbyFragmentsAreReady");
nearbyViewsAreReady = true; nearbyViewsAreReady = true;
// The condition for initialize operations is both having views ready and tab is selected // The condition for initialize operations is both having views ready and tab is selected
if (onTabSelected) { if (onTabSelected) {