Android Open Source - droid-fake-road Base Map View Activity






From Project

Back to project page droid-fake-road.

License

The source code is released under:

Apache License

If you think the Android project droid-fake-road listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package mobi.droid.fakeroad.ui.activity;
/*from  w w w.  j av  a 2s .c om*/
import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.MapsInitializer;
import com.google.android.gms.maps.UiSettings;
import com.google.android.gms.maps.model.LatLng;
import mobi.droid.fakeroad.R;
import mobi.droid.fakeroad.location.MapsHelper;

/**
 * @author ak
 */
public abstract class BaseMapViewActivity extends Activity{

    protected MapView mMapView;
    protected GoogleMap mMap;

    private void assignViews(){
        mMapView = (MapView) findViewById(R.id.mapView);
    }

    @Override
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        assignViews();

        configureMap(savedInstanceState);
    }

    protected void configureMap(Bundle savedInstanceState){
        mMapView.onCreate(savedInstanceState);
        mMapView.onResume();//needed to get the map to display immediately

        try{
//todo ???????? ?? ????????????? Google Play
            MapsInitializer.initialize(this);
            mMap = mMapView.getMap();
            mMap.setMyLocationEnabled(true);
            mMap.setTrafficEnabled(false);
//            mMap.animateCamera(
//                    CameraUpdateFactory.zoomBy(12f));
            UiSettings uiSettings = mMap.getUiSettings();
            uiSettings.setAllGesturesEnabled(true);
            uiSettings.setCompassEnabled(true);
            uiSettings.setZoomControlsEnabled(true);
            uiSettings.setMyLocationButtonEnabled(true);

        } catch(GooglePlayServicesNotAvailableException e){
            e.printStackTrace();
            finish();
            Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
        }

    }

    protected abstract void onAddMarker(LatLng aLatLng);

    @Override
    public void onDestroy(){
        if(mMapView != null){
            mMapView.onDestroy();
        }
        super.onDestroy();
    }

    @Override
    public void onLowMemory(){
        super.onLowMemory();
        if(mMapView != null){
            mMapView.onLowMemory();
        }
    }

    @Override
    public void onResume(){
        super.onResume();
        if(mMapView != null){
            mMapView.onResume();
        }
        MapsHelper.checkIfMockEnabled(this);
    }

    @Override
    public void onPause(){
        super.onPause();
        if(mMapView != null){
            mMapView.onPause();
        }
    }

    @Override
    public void onSaveInstanceState(final Bundle outState){
        super.onSaveInstanceState(outState);
        if(mMapView != null){
            mMapView.onSaveInstanceState(outState);
        }
    }
}




Java Source Code List

android.UnusedStub.java
mobi.droid.fakeroad.Actions.java
mobi.droid.fakeroad.App.java
mobi.droid.fakeroad.location.MapsHelper.java
mobi.droid.fakeroad.service.FakeLocationService.java
mobi.droid.fakeroad.service.LocationDbHelper.java
mobi.droid.fakeroad.ui.activity.BaseMapViewActivity.java
mobi.droid.fakeroad.ui.activity.MainActivity.java
mobi.droid.fakeroad.ui.activity.PreferencesActivity.java
mobi.droid.fakeroad.ui.view.AutoCompleteAddressTextView.java
mobi.droid.widget.SpeedPicker.java