From 42efa9b782e7005e33364b2842221a7dd1965239 Mon Sep 17 00:00:00 2001 From: Ifeoluwa Andrew Omole Date: Wed, 22 Jan 2025 13:43:59 +0100 Subject: [PATCH] MainActivity: Add methods to pass extras between Nearby and Explore --- .../commons/contributions/MainActivity.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/app/src/main/java/fr/free/nrw/commons/contributions/MainActivity.java b/app/src/main/java/fr/free/nrw/commons/contributions/MainActivity.java index 03027f287..da64d7235 100644 --- a/app/src/main/java/fr/free/nrw/commons/contributions/MainActivity.java +++ b/app/src/main/java/fr/free/nrw/commons/contributions/MainActivity.java @@ -432,6 +432,44 @@ public class MainActivity extends BaseActivity }); } + /** + * Launch the Explore fragment from Nearby fragment. This method is called when a user clicks + * the 'Show in Explore' option in the 3-dots menu in Nearby. + * + * @param zoom current zoom of Nearby map + * @param latitude current latitude of Nearby map + * @param longitude current longitude of Nearby map + **/ + public void loadExploreMapFromNearby(double zoom, double latitude, double longitude) { + Bundle bundle = new Bundle(); + bundle.putDouble("prev_zoom", zoom); + bundle.putDouble("prev_latitude", latitude); + bundle.putDouble("prev_longitude", longitude); + + loadFragment(ExploreFragment.newInstance(), false); + exploreFragment.setArguments(bundle); + setSelectedItemId(NavTab.EXPLORE.code()); + } + + /** + * Launch the Nearby fragment from Explore fragment. This method is called when a user clicks + * the 'Show in Nearby' option in the 3-dots menu in Explore. + * + * @param zoom current zoom of Explore map + * @param latitude current latitude of Explore map + * @param longitude current longitude of Explore map + **/ + public void loadNearbyMapFromExplore(double zoom, double latitude, double longitude) { + Bundle bundle = new Bundle(); + bundle.putDouble("prev_zoom", zoom); + bundle.putDouble("prev_latitude", latitude); + bundle.putDouble("prev_longitude", longitude); + + loadFragment(NearbyParentFragment.newInstance(), false); + nearbyParentFragment.setArguments(bundle); + setSelectedItemId(NavTab.NEARBY.code()); + } + @Override protected void onResume() { super.onResume();