Make nearby map ready callback came

This commit is contained in:
neslihanturan 2019-06-28 18:34:56 +03:00
parent 3bb801b62c
commit b8b524f859
3 changed files with 17 additions and 13 deletions

View file

@ -2,6 +2,7 @@ package fr.free.nrw.commons.nearby.mvp.contract;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.view.View;
import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions; import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions;

View file

@ -99,11 +99,12 @@ public class NearbyMapFragment extends CommonsDaggerSupportFragment implements N
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
Timber.d("onCreateView called"); 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); setHasOptionsMenu(false);
initViews(); initViews();
// this.mapView = setupMapView(savedInstanceState); this.mapView = setupMapView(savedInstanceState);
return view;
return mapView;
} }
@Override @Override
@ -159,7 +160,7 @@ public class NearbyMapFragment extends CommonsDaggerSupportFragment implements N
Log.d("deneme2", "setuo map view is called"); Log.d("deneme2", "setuo map view is called");
Timber.d("setting up map view"); Timber.d("setting up map view");
boolean isDarkTheme = applicationKvStore.getBoolean("theme", false); boolean isDarkTheme = applicationKvStore.getBoolean("theme", false);
/*MapboxMapOptions options = new MapboxMapOptions() MapboxMapOptions options = new MapboxMapOptions()
.compassGravity(Gravity.BOTTOM | Gravity.LEFT) .compassGravity(Gravity.BOTTOM | Gravity.LEFT)
.compassMargins(new int[]{12, 0, 0, 24}) .compassMargins(new int[]{12, 0, 0, 24})
.styleUrl(isDarkTheme ? Style.DARK : Style.OUTDOORS) .styleUrl(isDarkTheme ? Style.DARK : Style.OUTDOORS)
@ -167,9 +168,9 @@ public class NearbyMapFragment extends CommonsDaggerSupportFragment implements N
.attributionEnabled(false) .attributionEnabled(false)
.camera(new CameraPosition.Builder() .camera(new CameraPosition.Builder()
.zoom(ZOOM_LEVEL) .zoom(ZOOM_LEVEL)
.build());*/ .build());
/*
MapView mapView = getView().findViewById(R.id.mapView); MapView mapView = view.findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState); mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() { mapView.getMapAsync(new OnMapReadyCallback() {
@Override @Override
@ -182,15 +183,16 @@ public class NearbyMapFragment extends CommonsDaggerSupportFragment implements N
); );
return mapView; return mapView;
*/
if (!getParentFragment().getActivity().isFinishing()) {
/*if (!getParentFragment().getActivity().isFinishing()) {
MapView mapView = new MapView(getParentFragment().getActivity(), options); MapView mapView = new MapView(getParentFragment().getActivity(), options);
// create map // create map
mapView.onCreate(savedInstanceState); mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap -> { mapView.getMapAsync(mapboxMap -> {
LocalizationPlugin localizationPlugin = new LocalizationPlugin(mapView, mapboxMap); Log.d("deneme2","nearby map is ready");
/*LocalizationPlugin localizationPlugin = new LocalizationPlugin(mapView, mapboxMap);
try { try {
localizationPlugin.matchMapLanguageWithDeviceDefault(); localizationPlugin.matchMapLanguageWithDeviceDefault();
@ -201,11 +203,11 @@ public class NearbyMapFragment extends CommonsDaggerSupportFragment implements N
this.mapboxMap = mapboxMap; this.mapboxMap = mapboxMap;
viewsAreReadyCallback.nearbyMapViewReady(); viewsAreReadyCallback.nearbyMapViewReady();
//addMapMovementListeners(); //addMapMovementListeners();
//updateMapSignificantlyForCurrentLocation(); //updateMapSignificantlyForCurrentLocation();*/
}); });
return mapView; return mapView;
} }
return null;*/ return null;
} }
@Override @Override

View file

@ -90,6 +90,7 @@ public class NearbyParentFragmentPresenter
*/ */
@Override @Override
public void nearbyMapViewReady() { public void nearbyMapViewReady() {
Log.d("deneme2","Nearby view ready method is called");
Timber.d("Nearby map view is created and ready"); Timber.d("Nearby map view is created and ready");
updateMapAndList(LOCATION_SIGNIFICANTLY_CHANGED, null); 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 // 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); //nearbyParentFragmentView.checkGps(locationServiceManager);
// We will know when we went offline and online again // We will know when we went offline and online again
nearbyParentFragmentView.addNetworkBroadcastReceiver(); nearbyParentFragmentView.addNetworkBroadcastReceiver();
nearbyMapFragmentView.setupMapView(null); //nearbyMapFragmentView.setupMapView(null);
} }
/** /**