mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Define a presenter variable in fragment and call updateMapAndList method from there, if permissions are okay
This commit is contained in:
parent
1c27c3cbe3
commit
a8190bb8b1
1 changed files with 11 additions and 6 deletions
|
|
@ -30,9 +30,12 @@ import fr.free.nrw.commons.nearby.NearbyController;
|
||||||
import fr.free.nrw.commons.nearby.NearbyListFragment;
|
import fr.free.nrw.commons.nearby.NearbyListFragment;
|
||||||
import fr.free.nrw.commons.nearby.NearbyMapFragment;
|
import fr.free.nrw.commons.nearby.NearbyMapFragment;
|
||||||
import fr.free.nrw.commons.nearby.mvp.contract.NearbyParentFragmentContract;
|
import fr.free.nrw.commons.nearby.mvp.contract.NearbyParentFragmentContract;
|
||||||
|
import fr.free.nrw.commons.nearby.mvp.presenter.NearbyParentFragmentPresenter;
|
||||||
import fr.free.nrw.commons.wikidata.WikidataEditListener;
|
import fr.free.nrw.commons.wikidata.WikidataEditListener;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
|
import static fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.LOCATION_SIGNIFICANTLY_CHANGED;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This fragment is under MainActivity at the came level with ContributionFragment and holds
|
* This fragment is under MainActivity at the came level with ContributionFragment and holds
|
||||||
* two nearby element fragments as NearbyMapFragment and NearbyListFragment
|
* two nearby element fragments as NearbyMapFragment and NearbyListFragment
|
||||||
|
|
@ -68,11 +71,13 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
private fr.free.nrw.commons.nearby.NearbyListFragment nearbyListFragment;
|
private fr.free.nrw.commons.nearby.NearbyListFragment nearbyListFragment;
|
||||||
private static final String TAG_RETAINED_MAP_FRAGMENT = NearbyMapFragment.class.getSimpleName();
|
private static final String TAG_RETAINED_MAP_FRAGMENT = NearbyMapFragment.class.getSimpleName();
|
||||||
private static final String TAG_RETAINED_LIST_FRAGMENT = NearbyListFragment.class.getSimpleName();
|
private static final String TAG_RETAINED_LIST_FRAGMENT = NearbyListFragment.class.getSimpleName();
|
||||||
|
private NearbyParentFragmentPresenter nearbyParentFragmentPresenter;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setRetainInstance(true);
|
setRetainInstance(true);
|
||||||
|
nearbyParentFragmentPresenter = new NearbyParentFragmentPresenter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
@ -233,14 +238,14 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
startActivityForResult(callGPSSettingIntent, 1);
|
startActivityForResult(callGPSSettingIntent, 1);
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.menu_cancel_upload, (dialog, id) -> {
|
.setNegativeButton(R.string.menu_cancel_upload, (dialog, id) -> {
|
||||||
showLocationPermissionDeniedErrorDialog();
|
showLocationPermissionDeniedErrorDialog(locationServiceManager);
|
||||||
dialog.cancel();
|
dialog.cancel();
|
||||||
})
|
})
|
||||||
.create()
|
.create()
|
||||||
.show();
|
.show();
|
||||||
} else {
|
} else {
|
||||||
Timber.d("GPS is enabled");
|
Timber.d("GPS is enabled");
|
||||||
checkLocationPermission();
|
checkLocationPermission(locationServiceManager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -255,7 +260,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
Timber.d("Checking location permission");
|
Timber.d("Checking location permission");
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
if (locationServiceManager.isLocationPermissionGranted(requireContext())) {
|
if (locationServiceManager.isLocationPermissionGranted(requireContext())) {
|
||||||
refreshView(LOCATION_SIGNIFICANTLY_CHANGED);
|
nearbyParentFragmentPresenter.updateMapAndList(LOCATION_SIGNIFICANTLY_CHANGED);
|
||||||
} else {
|
} else {
|
||||||
// Should we show an explanation?
|
// Should we show an explanation?
|
||||||
if (locationServiceManager.isPermissionExplanationRequired(getActivity())) {
|
if (locationServiceManager.isPermissionExplanationRequired(getActivity())) {
|
||||||
|
|
@ -265,11 +270,11 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
new AlertDialog.Builder(getActivity())
|
new AlertDialog.Builder(getActivity())
|
||||||
.setMessage(getString(R.string.location_permission_rationale_nearby))
|
.setMessage(getString(R.string.location_permission_rationale_nearby))
|
||||||
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
|
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
|
||||||
requestLocationPermissions();
|
requestLocationPermissions(locationServiceManager);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
})
|
})
|
||||||
.setNegativeButton(android.R.string.cancel, (dialog, id) -> {
|
.setNegativeButton(android.R.string.cancel, (dialog, id) -> {
|
||||||
showLocationPermissionDeniedErrorDialog();
|
showLocationPermissionDeniedErrorDialog(locationServiceManager);
|
||||||
dialog.cancel();
|
dialog.cancel();
|
||||||
})
|
})
|
||||||
.create()
|
.create()
|
||||||
|
|
@ -281,7 +286,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
refreshView(LOCATION_SIGNIFICANTLY_CHANGED);
|
nearbyParentFragmentPresenter.updateMapAndList(LOCATION_SIGNIFICANTLY_CHANGED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue