From b8b524f85999baaf60cd6fbeb6338029148b6e03 Mon Sep 17 00:00:00 2001 From: neslihanturan Date: Fri, 28 Jun 2019 18:34:56 +0300 Subject: [PATCH] Make nearby map ready callback came --- .../mvp/contract/NearbyMapContract.java | 1 + .../mvp/fragments/NearbyMapFragment.java | 26 ++++++++++--------- .../NearbyParentFragmentPresenter.java | 3 ++- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/nearby/mvp/contract/NearbyMapContract.java b/app/src/main/java/fr/free/nrw/commons/nearby/mvp/contract/NearbyMapContract.java index b7d531cba..00678b74a 100644 --- a/app/src/main/java/fr/free/nrw/commons/nearby/mvp/contract/NearbyMapContract.java +++ b/app/src/main/java/fr/free/nrw/commons/nearby/mvp/contract/NearbyMapContract.java @@ -2,6 +2,7 @@ package fr.free.nrw.commons.nearby.mvp.contract; import android.net.Uri; import android.os.Bundle; +import android.view.View; import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions; diff --git a/app/src/main/java/fr/free/nrw/commons/nearby/mvp/fragments/NearbyMapFragment.java b/app/src/main/java/fr/free/nrw/commons/nearby/mvp/fragments/NearbyMapFragment.java index 9f3cab203..6a77563cc 100644 --- a/app/src/main/java/fr/free/nrw/commons/nearby/mvp/fragments/NearbyMapFragment.java +++ b/app/src/main/java/fr/free/nrw/commons/nearby/mvp/fragments/NearbyMapFragment.java @@ -99,11 +99,12 @@ public class NearbyMapFragment extends CommonsDaggerSupportFragment implements N public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Timber.d("onCreateView called"); - View view = inflater.inflate(R.layout.fragment_nearby_map, container, false); + //View view = inflater.inflate(R.layout.fragment_nearby_map, container, false); setHasOptionsMenu(false); initViews(); - // this.mapView = setupMapView(savedInstanceState); - return view; + this.mapView = setupMapView(savedInstanceState); + + return mapView; } @Override @@ -159,7 +160,7 @@ public class NearbyMapFragment extends CommonsDaggerSupportFragment implements N Log.d("deneme2", "setuo map view is called"); Timber.d("setting up map view"); boolean isDarkTheme = applicationKvStore.getBoolean("theme", false); - /*MapboxMapOptions options = new MapboxMapOptions() + MapboxMapOptions options = new MapboxMapOptions() .compassGravity(Gravity.BOTTOM | Gravity.LEFT) .compassMargins(new int[]{12, 0, 0, 24}) .styleUrl(isDarkTheme ? Style.DARK : Style.OUTDOORS) @@ -167,9 +168,9 @@ public class NearbyMapFragment extends CommonsDaggerSupportFragment implements N .attributionEnabled(false) .camera(new CameraPosition.Builder() .zoom(ZOOM_LEVEL) - .build());*/ - - MapView mapView = getView().findViewById(R.id.mapView); + .build()); +/* + MapView mapView = view.findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @Override @@ -182,15 +183,16 @@ public class NearbyMapFragment extends CommonsDaggerSupportFragment implements N ); return mapView; +*/ - - /*if (!getParentFragment().getActivity().isFinishing()) { + if (!getParentFragment().getActivity().isFinishing()) { MapView mapView = new MapView(getParentFragment().getActivity(), options); // create map mapView.onCreate(savedInstanceState); mapView.getMapAsync(mapboxMap -> { - LocalizationPlugin localizationPlugin = new LocalizationPlugin(mapView, mapboxMap); + Log.d("deneme2","nearby map is ready"); + /*LocalizationPlugin localizationPlugin = new LocalizationPlugin(mapView, mapboxMap); try { localizationPlugin.matchMapLanguageWithDeviceDefault(); @@ -201,11 +203,11 @@ public class NearbyMapFragment extends CommonsDaggerSupportFragment implements N this.mapboxMap = mapboxMap; viewsAreReadyCallback.nearbyMapViewReady(); //addMapMovementListeners(); - //updateMapSignificantlyForCurrentLocation(); + //updateMapSignificantlyForCurrentLocation();*/ }); return mapView; } - return null;*/ + return null; } @Override diff --git a/app/src/main/java/fr/free/nrw/commons/nearby/mvp/presenter/NearbyParentFragmentPresenter.java b/app/src/main/java/fr/free/nrw/commons/nearby/mvp/presenter/NearbyParentFragmentPresenter.java index 8a19d693d..e24e587ea 100644 --- a/app/src/main/java/fr/free/nrw/commons/nearby/mvp/presenter/NearbyParentFragmentPresenter.java +++ b/app/src/main/java/fr/free/nrw/commons/nearby/mvp/presenter/NearbyParentFragmentPresenter.java @@ -90,6 +90,7 @@ public class NearbyParentFragmentPresenter */ @Override public void nearbyMapViewReady() { + Log.d("deneme2","Nearby view ready method is called"); Timber.d("Nearby map view is created and ready"); updateMapAndList(LOCATION_SIGNIFICANTLY_CHANGED, null); // TODO: document this prpoblem, if updateMapAndList is not called at checkGPS then this method never called, setup map view never ends @@ -118,7 +119,7 @@ public class NearbyParentFragmentPresenter //nearbyParentFragmentView.checkGps(locationServiceManager); // We will know when we went offline and online again nearbyParentFragmentView.addNetworkBroadcastReceiver(); - nearbyMapFragmentView.setupMapView(null); + //nearbyMapFragmentView.setupMapView(null); } /**