[android] #2462 moving MapFragment into the SDK

This commit is contained in:
Tobrun
2015-10-08 10:08:58 +02:00
committed by Brad Leege
parent fd45a206ec
commit ba97c69845
3 changed files with 13 additions and 3 deletions

View File

@@ -1,120 +0,0 @@
package com.mapbox.mapboxsdk.testapp;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.mapbox.mapboxsdk.views.MapView;
// TODO move this to SDK
public class MapFragment extends Fragment {
//
// Static members
//
// Tag used for logging
private static final String TAG = "MapFragment";
//
// Instance members
//
// The map
private MapView mMap;
//
// Lifecycle events
//
// Called when the fragment is created
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
Log.v(TAG, "onCreateView");
// Create the map
mMap = (MapView) inflater.inflate(R.layout.fragment_main, container, false);
// Set accessToken
mMap.setAccessToken(Util.getAccessToken(container.getContext()));
// Need to pass on any saved state to the map
mMap.onCreate(savedInstanceState);
// Return the map as the root view
return mMap;
}
// Called when the fragment is destroyed
@Override
public void onDestroyView() {
super.onDestroyView();
Log.v(TAG, "onDestroyView");
// Need to pass on to view
mMap.onDestroy();
mMap = null;
}
// Called when the fragment is visible
@Override
public void onStart() {
super.onStart();
Log.v(TAG, "onStart");
// Need to pass on to view
mMap.onStart();
}
// Called when the fragment is invisible
@Override
public void onStop() {
super.onStop();
Log.v(TAG, "onStop");
// Need to pass on to view
mMap.onStop();
}
// Called when the fragment is in the background
@Override
public void onPause() {
super.onPause();
Log.v(TAG, "onPause");
// Need to pass on to view
mMap.onPause();
}
// Called when the fragment is no longer in the background
@Override
public void onResume() {
super.onResume();
Log.v(TAG, "onResume");
// Need to pass on to view
mMap.onResume();
}
// Called before fragment is destroyed
@Override
public void onSaveInstanceState(Bundle outState) {
Log.v(TAG, "onSaveInstanceState");
// Need to retrieve any saved state from the map
mMap.onSaveInstanceState(outState);
super.onSaveInstanceState(outState);
}
//
// Property methods
//
public MapView getMap() {
return mMap;
}
}

View File

@@ -9,6 +9,7 @@ import android.view.Gravity;
import android.view.MenuItem;
import android.view.View;
import com.mapbox.mapboxsdk.MapFragment;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.views.MapView;

View File

@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<com.mapbox.mapboxsdk.views.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" />