From 3890ea578b52d883fc950e9e78477ed35526a2e1 Mon Sep 17 00:00:00 2001 From: neslihanturan Date: Wed, 10 Jul 2019 12:42:36 +0300 Subject: [PATCH] use SupportMapFragment instead --- .../commons/contributions/MainActivity.java | 2 +- .../mvp/fragments/NearbyParentFragment.java | 34 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) 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 c3c83021c..7e212c46f 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 @@ -188,7 +188,7 @@ public class MainActivity extends AuthenticatedActivity implements FragmentManag isContributionsFragmentVisible = false; updateMenuItem(); // Do all permission and GPS related tasks on tab selected, not on create - ((NearbyParentFragment)contributionsActivityPagerAdapter.getItem(1)).nearbyParentFragmentPresenter.onTabSelected(); + //((NearbyParentFragment)contributionsActivityPagerAdapter.getItem(1)).nearbyParentFragmentPresenter.onTabSelected(); break; default: tabLayout.getTabAt(CONTRIBUTIONS_TAB_POSITION).select(); diff --git a/app/src/main/java/fr/free/nrw/commons/nearby/mvp/fragments/NearbyParentFragment.java b/app/src/main/java/fr/free/nrw/commons/nearby/mvp/fragments/NearbyParentFragment.java index fc10a1b52..1173b41b5 100644 --- a/app/src/main/java/fr/free/nrw/commons/nearby/mvp/fragments/NearbyParentFragment.java +++ b/app/src/main/java/fr/free/nrw/commons/nearby/mvp/fragments/NearbyParentFragment.java @@ -68,7 +68,7 @@ import static fr.free.nrw.commons.location.LocationServiceManager.LocationChange */ public class NearbyParentFragment extends CommonsDaggerSupportFragment implements WikidataEditListener.WikidataP18EditListener, - NearbyParentFragmentContract.View { + NearbyParentFragmentContract.View, OnMapReadyCallback { @BindView(R.id.progressBar) ProgressBar progressBar; @@ -98,9 +98,9 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment private NearbyParentFragmentContract.UserActions userActions; - private NearbyMapFragment2 nearbyMapFragment; + private SupportMapFragment nearbyMapFragment; private NearbyListFragment nearbyListFragment; - private static final String TAG_RETAINED_MAP_FRAGMENT = NearbyMapFragment2.class.getSimpleName(); + private static final String TAG_RETAINED_MAP_FRAGMENT = SupportMapFragment.class.getSimpleName(); private static final String TAG_RETAINED_LIST_FRAGMENT = NearbyListFragment.class.getSimpleName(); public NearbyParentFragmentPresenter nearbyParentFragmentPresenter; @@ -168,7 +168,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment */ public void childMapFragmentAttached() { nearbyParentFragmentPresenter = new NearbyParentFragmentPresenter - (this, nearbyMapFragment, locationManager); + (this, null, locationManager); Timber.d("Child fragment attached"); } @@ -240,8 +240,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment /** * Returns the map fragment added to child fragment manager previously, if exists. */ - private NearbyMapFragment2 getMapFragment() { - NearbyMapFragment2 existingFragment = (NearbyMapFragment2) getChildFragmentManager() + private SupportMapFragment getMapFragment() { + SupportMapFragment existingFragment = (SupportMapFragment) getChildFragmentManager() .findFragmentByTag(TAG_RETAINED_MAP_FRAGMENT); if (existingFragment == null) { existingFragment = setMapFragment(); @@ -249,7 +249,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment return existingFragment; } - private NearbyMapFragment2 setMapFragment() { + private SupportMapFragment setMapFragment() { + Log.d("deneme2","setMapFragment is called"); FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction(); // Build mapboxMap MapboxMapOptions options = new MapboxMapOptions(); @@ -259,22 +260,16 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment .build()); // Create map fragment - NearbyMapFragment2 nearbyMapFragment = NearbyMapFragment2.newInstance(options); + SupportMapFragment nearbyMapFragment = SupportMapFragment.newInstance(options); //NearbyMapFragment2 nearbyMapFragment = new NearbyMapFragment2(); fragmentTransaction.replace(R.id.container, nearbyMapFragment, TAG_RETAINED_MAP_FRAGMENT); fragmentTransaction.commitAllowingStateLoss(); - nearbyMapFragment.getMapAsync(new OnMapReadyCallback() { - @Override - public void onMapReady(@NonNull MapboxMap mapboxMap) { - Log.d("deneme2","onMapReady"); - nearbyMapFragment.viewsAreReadyCallback.nearbyMapViewReady(); - } - }); - if (nearbyMapFragment.getMapboxMap()!=null){ + nearbyMapFragment.getMapAsync(this); + /*if (nearbyMapFragment.getMapboxMap()!=null){ - } + }*/ return nearbyMapFragment; } @@ -421,4 +416,9 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment public boolean isBottomSheetExpanded() { return bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED; } + + @Override + public void onMapReady(MapboxMap mapboxMap) { + Log.d("deneme2","on map ready"); + } }