Add a view to nearby map ragment and insert map view as an item inside it

This commit is contained in:
neslihanturan 2019-06-12 15:58:54 +03:00
parent c84ecd1b9c
commit c8b1ebb7fe
3 changed files with 34 additions and 4 deletions

View file

@ -28,6 +28,7 @@ import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.MapboxMapOptions; import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.plugins.localization.LocalizationPlugin; import com.mapbox.mapboxsdk.plugins.localization.LocalizationPlugin;
import java.util.List; import java.util.List;
@ -98,10 +99,11 @@ 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);
setHasOptionsMenu(false); setHasOptionsMenu(false);
initViews(); initViews();
this.mapView = setupMapView(savedInstanceState); // this.mapView = setupMapView(savedInstanceState);
return mapView; return view;
} }
@Override @Override
@ -165,7 +167,22 @@ public class NearbyMapFragment extends CommonsDaggerSupportFragment implements N
.zoom(ZOOM_LEVEL) .zoom(ZOOM_LEVEL)
.build()); .build());
if (!getParentFragment().getActivity().isFinishing()) { MapView mapView = getView().findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {
NearbyMapFragment.this.mapboxMap = mapboxMap;
viewsAreReadyCallback.nearbyMapViewReady();
}
}
);
return mapView;
/*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);
@ -185,7 +202,7 @@ public class NearbyMapFragment extends CommonsDaggerSupportFragment implements N
}); });
return mapView; return mapView;
} }
return null; return null;*/
} }
@Override @Override

View file

@ -118,6 +118,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);
} }
/** /**

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>