95 lines
2.2 KiB
Java
95 lines
2.2 KiB
Java
package com.mogo.map;
|
|
|
|
import android.content.Context;
|
|
import android.os.Bundle;
|
|
import android.util.AttributeSet;
|
|
import android.widget.FrameLayout;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
|
|
/**
|
|
* @author congtaowang
|
|
* @since 2019-12-18
|
|
* <p>
|
|
* 对地图的基本抽象
|
|
*/
|
|
public abstract class MogoBaseMapView extends FrameLayout implements ILifeCycle {
|
|
|
|
protected IMogoMapView mMapView;
|
|
|
|
public MogoBaseMapView( Context context ) {
|
|
this( context, null );
|
|
}
|
|
|
|
public MogoBaseMapView( Context context, @Nullable AttributeSet attrs ) {
|
|
this( context, attrs, 0 );
|
|
}
|
|
|
|
public MogoBaseMapView( Context context, @Nullable AttributeSet attrs, int defStyleAttr ) {
|
|
super( context, attrs, defStyleAttr );
|
|
init( context,attrs );
|
|
}
|
|
|
|
private void init( Context context, AttributeSet attrs) {
|
|
addMapView( context, attrs );
|
|
if (mMapView != null){
|
|
MogoMap.Companion.getMapInstance().initInstance( mMapView.getMap() , getInstanceTag());
|
|
}
|
|
}
|
|
|
|
protected abstract void addMapView( Context context , AttributeSet attrs);
|
|
|
|
protected abstract String getInstanceTag();
|
|
|
|
@Override
|
|
public void onCreate( Bundle bundle ) {
|
|
if ( mMapView != null ) {
|
|
mMapView.onCreate( bundle );
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onResume() {
|
|
if ( mMapView != null ) {
|
|
mMapView.onResume();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onPause() {
|
|
if ( mMapView != null ) {
|
|
mMapView.onPause();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onDestroy() {
|
|
if ( mMapView != null ) {
|
|
mMapView.onDestroy();
|
|
}
|
|
MogoMap.Companion.getMapInstance().clear(getInstanceTag());
|
|
}
|
|
|
|
@Override
|
|
public void onSaveInstanceState( Bundle outState ) {
|
|
if ( mMapView != null ) {
|
|
mMapView.onSaveInstanceState( outState );
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onLowMemory() {
|
|
if ( mMapView != null ) {
|
|
mMapView.onLowMemory();
|
|
}
|
|
}
|
|
|
|
protected IMogoMap getMap() {
|
|
if ( mMapView != null ) {
|
|
return mMapView.getMap();
|
|
}
|
|
return null;
|
|
}
|
|
}
|