|
|
|
|
@@ -12,31 +12,21 @@ import android.widget.TextView;
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.android.arouter.launcher.ARouter;
|
|
|
|
|
import com.mogo.commons.mvp.IView;
|
|
|
|
|
import com.mogo.commons.mvp.MvpFragment;
|
|
|
|
|
import com.mogo.commons.mvp.Presenter;
|
|
|
|
|
import com.mogo.map.MogoLatLng;
|
|
|
|
|
import com.mogo.map.listener.IMogoMapListener;
|
|
|
|
|
import com.mogo.map.location.IMogoLocationListener;
|
|
|
|
|
import com.mogo.map.location.IMogoLocationClient;
|
|
|
|
|
import com.mogo.map.location.MogoLocation;
|
|
|
|
|
import com.mogo.map.marker.IMogoMarker;
|
|
|
|
|
import com.mogo.map.marker.IMogoMarkerClickListener;
|
|
|
|
|
import com.mogo.map.marker.IMogoMarkerManager;
|
|
|
|
|
import com.mogo.map.marker.MogoMarkerOptions;
|
|
|
|
|
import com.mogo.map.model.MogoPoi;
|
|
|
|
|
import com.mogo.map.navi.IMogoNavi;
|
|
|
|
|
import com.mogo.map.search.geo.MogoPoiItem;
|
|
|
|
|
import com.mogo.map.search.poisearch.IMogoPoiSearch;
|
|
|
|
|
import com.mogo.map.search.poisearch.IMogoPoiSearchListener;
|
|
|
|
|
import com.mogo.map.search.poisearch.MogoPoiResult;
|
|
|
|
|
import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery;
|
|
|
|
|
import com.mogo.map.uicontroller.EnumMapUI;
|
|
|
|
|
import com.mogo.map.uicontroller.IMogoMapUIController;
|
|
|
|
|
import com.mogo.service.MogoServicePaths;
|
|
|
|
|
import com.mogo.service.imageloader.IMogoImageloader;
|
|
|
|
|
import com.mogo.service.map.IMogoMapService;
|
|
|
|
|
import com.mogo.service.module.IMogoModuleLifecycle;
|
|
|
|
|
import com.mogo.utils.TipToast;
|
|
|
|
|
import com.mogo.utils.logger.Logger;
|
|
|
|
|
@@ -65,6 +55,8 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|
|
|
|
private Button mAddMarker;
|
|
|
|
|
private Button mAddMarkers;
|
|
|
|
|
|
|
|
|
|
private static IMogoMarker mLastClickedMarker;
|
|
|
|
|
|
|
|
|
|
private Bitmap mMarkerIcon;
|
|
|
|
|
private Bitmap mClickedMarkerIcon;
|
|
|
|
|
private TextView mLocInfo;
|
|
|
|
|
@@ -72,19 +64,10 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|
|
|
|
private Button m2D3D;
|
|
|
|
|
private CheckBox mNaviMode;
|
|
|
|
|
|
|
|
|
|
private IMogoMarker mLastClickedMarker;
|
|
|
|
|
|
|
|
|
|
private IMogoMapService mMapService;
|
|
|
|
|
private IMogoPoiSearch mPoiSearch;
|
|
|
|
|
private IMogoLocationClient mLocationClient;
|
|
|
|
|
private IMogoMarkerManager mMarkerManager;
|
|
|
|
|
private IMogoNavi mNavi;
|
|
|
|
|
private IMogoMapUIController mMapUIController;
|
|
|
|
|
|
|
|
|
|
private DemoInfoWindowAdapter mDemoInfoWindowAdapter;
|
|
|
|
|
private MogoLocation mLocation;
|
|
|
|
|
|
|
|
|
|
private IMogoImageloader mImageloader;
|
|
|
|
|
private int position = -1;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected int getLayoutId() {
|
|
|
|
|
@@ -94,18 +77,12 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|
|
|
|
@Override
|
|
|
|
|
protected void initViews() {
|
|
|
|
|
|
|
|
|
|
position = getArguments().getInt( "position" );
|
|
|
|
|
|
|
|
|
|
mNaviMode = findViewById( R.id.demo_module_id_navi_mode );
|
|
|
|
|
|
|
|
|
|
mMapService = ( IMogoMapService ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation( getContext() );
|
|
|
|
|
mImageloader = ( IMogoImageloader ) ARouter.getInstance().build( MogoServicePaths.PATH_UTILS_IMAGE_LOADER ).navigation( getContext() );
|
|
|
|
|
mPoiSearch = mMapService.getPoiSearch( getContext(), new MogoPoiSearchQuery() );
|
|
|
|
|
mPoiSearch.setPoiSearchListener( this );
|
|
|
|
|
mLocationClient = mMapService.getLocationClient( getContext() );
|
|
|
|
|
mLocation = mLocationClient.getLastKnowLocation();
|
|
|
|
|
mMarkerManager = mMapService.getMarkerManager( getContext() );
|
|
|
|
|
mNavi = mMapService.getNavi( getContext() );
|
|
|
|
|
mMapUIController = mMapService.getMapUIController();
|
|
|
|
|
|
|
|
|
|
ServiceHandler.getPoiSearch().setPoiSearchListener( this );
|
|
|
|
|
mLocation = ServiceHandler.getLocationClient().getLastKnowLocation();
|
|
|
|
|
m2D3D = findViewById( R.id.demo_module_id_2d3d );
|
|
|
|
|
|
|
|
|
|
mLocInfo = findViewById( R.id.demo_module_id_loc_info );
|
|
|
|
|
@@ -114,12 +91,12 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|
|
|
|
new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick( View v ) {
|
|
|
|
|
mLocationClient.start( 4_000L );
|
|
|
|
|
ServiceHandler.getLocationClient().start( 4_000L );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
mDemoInfoWindowAdapter = new DemoInfoWindowAdapter( getContext(), mNavi, mImageloader );
|
|
|
|
|
mDemoInfoWindowAdapter = new DemoInfoWindowAdapter( getContext(), ServiceHandler.getNavi(), ServiceHandler.getImageloader() );
|
|
|
|
|
|
|
|
|
|
mMarkerIcon = BitmapFactory.decodeResource( getResources(), R.drawable.ic_search_poi_location );
|
|
|
|
|
mClickedMarkerIcon = BitmapFactory.decodeResource( getResources(), R.drawable.ic_search_choice_point );
|
|
|
|
|
@@ -132,7 +109,7 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|
|
|
|
.latitude( 39.974525d )
|
|
|
|
|
.owner( DemoConstants.TAG )
|
|
|
|
|
.longitude( 116.41733d );
|
|
|
|
|
IMogoMarker marker = mMarkerManager.addMarker( DemoConstants.TAG, options );
|
|
|
|
|
IMogoMarker marker = ServiceHandler.getMarkerManager().addMarker( DemoConstants.TAG, options );
|
|
|
|
|
marker.setInfoWindowAdapter( mDemoInfoWindowAdapter );
|
|
|
|
|
marker.setOnMarkerClickListener( DemoCardViewFragment.this );
|
|
|
|
|
}
|
|
|
|
|
@@ -155,7 +132,7 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|
|
|
|
}
|
|
|
|
|
optionsList.add( options );
|
|
|
|
|
}
|
|
|
|
|
List< IMogoMarker > iMogoMarkers = mMarkerManager.addMarkers( DemoConstants.TAG, optionsList, true );
|
|
|
|
|
List< IMogoMarker > iMogoMarkers = ServiceHandler.getMarkerManager().addMarkers( DemoConstants.TAG, optionsList, true );
|
|
|
|
|
for ( IMogoMarker iMogoMarker : iMogoMarkers ) {
|
|
|
|
|
iMogoMarker.setInfoWindowAdapter( mDemoInfoWindowAdapter );
|
|
|
|
|
iMogoMarker.setOnMarkerClickListener( DemoCardViewFragment.this );
|
|
|
|
|
@@ -166,7 +143,7 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|
|
|
|
findViewById( R.id.demo_module_id_clear ).setOnClickListener( new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick( View v ) {
|
|
|
|
|
mMarkerManager.removeMarkers( DemoConstants.TAG );
|
|
|
|
|
ServiceHandler.getMarkerManager().removeMarkers( DemoConstants.TAG );
|
|
|
|
|
}
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
@@ -176,7 +153,7 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick( View v ) {
|
|
|
|
|
mMapUIController.changeMapMode( ui = ui.next() );
|
|
|
|
|
ServiceHandler.getMapUIController().changeMapMode( ui = ui.next() );
|
|
|
|
|
m2D3D.setText( ui.toString() );
|
|
|
|
|
}
|
|
|
|
|
} );
|
|
|
|
|
@@ -184,21 +161,21 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|
|
|
|
findViewById( R.id.demo_module_id_current ).setOnClickListener( new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick( View v ) {
|
|
|
|
|
mMapUIController.moveToCenter( new MogoLatLng( mLocation.getLatitude(), mLocation.getLongitude() ) );
|
|
|
|
|
ServiceHandler.getMapUIController().moveToCenter( new MogoLatLng( mLocation.getLatitude(), mLocation.getLongitude() ) );
|
|
|
|
|
}
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
findViewById( R.id.demo_module_id_start_navi ).setOnClickListener( new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick( View v ) {
|
|
|
|
|
mNavi.startNavi( !mNaviMode.isChecked() );
|
|
|
|
|
ServiceHandler.getNavi().startNavi( !mNaviMode.isChecked() );
|
|
|
|
|
}
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
findViewById( R.id.demo_module_id_stop_navi ).setOnClickListener( new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick( View v ) {
|
|
|
|
|
mNavi.stopNavi();
|
|
|
|
|
ServiceHandler.getNavi().stopNavi();
|
|
|
|
|
}
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
@@ -208,7 +185,7 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick( View v ) {
|
|
|
|
|
mMapUIController.setTrafficEnabled( enable = !enable );
|
|
|
|
|
ServiceHandler.getMapUIController().setTrafficEnabled( enable = !enable );
|
|
|
|
|
}
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
@@ -216,7 +193,7 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick( View v ) {
|
|
|
|
|
mMapUIController.changeZoom( true );
|
|
|
|
|
ServiceHandler.getMapUIController().changeZoom( true );
|
|
|
|
|
}
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
@@ -224,7 +201,7 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick( View v ) {
|
|
|
|
|
mMapUIController.changeZoom( false );
|
|
|
|
|
ServiceHandler.getMapUIController().changeZoom( false );
|
|
|
|
|
}
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
@@ -232,7 +209,7 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick( View v ) {
|
|
|
|
|
mMapUIController.changeMapMode( EnumMapUI.Type_Light );
|
|
|
|
|
ServiceHandler.getMapUIController().changeMapMode( EnumMapUI.Type_Light );
|
|
|
|
|
}
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
@@ -240,7 +217,7 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick( View v ) {
|
|
|
|
|
mMapUIController.changeMapMode( EnumMapUI.Type_Night );
|
|
|
|
|
ServiceHandler.getMapUIController().changeMapMode( EnumMapUI.Type_Night );
|
|
|
|
|
}
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
@@ -248,7 +225,7 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick( View v ) {
|
|
|
|
|
mMapUIController.displayOverview();
|
|
|
|
|
ServiceHandler.getMapUIController().displayOverview();
|
|
|
|
|
}
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
@@ -256,11 +233,11 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick( View v ) {
|
|
|
|
|
mMapUIController.recoverLockMode();
|
|
|
|
|
ServiceHandler.getMapUIController().recoverLockMode();
|
|
|
|
|
}
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
mLocationClient.addLocationListener( new IMogoLocationListener() {
|
|
|
|
|
ServiceHandler.getLocationClient().addLocationListener( new IMogoLocationListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onLocationChanged( MogoLocation location ) {
|
|
|
|
|
mLocation = location;
|
|
|
|
|
@@ -320,7 +297,7 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|
|
|
|
if ( poi != null ) {
|
|
|
|
|
TipToast.shortTip( poi.getName() );
|
|
|
|
|
}
|
|
|
|
|
mPoiSearch.searchPOIIdAsyn( poi.getPoiId() );
|
|
|
|
|
ServiceHandler.getPoiSearch().searchPOIIdAsyn( poi.getPoiId() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@@ -338,7 +315,7 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|
|
|
|
if ( mPoiMarker != null ) {
|
|
|
|
|
mPoiMarker.destroy();
|
|
|
|
|
}
|
|
|
|
|
mPoiMarker = mMarkerManager.addMarker( DemoConstants.TAG, new MogoMarkerOptions()
|
|
|
|
|
mPoiMarker = ServiceHandler.getMarkerManager().addMarker( DemoConstants.TAG, new MogoMarkerOptions()
|
|
|
|
|
.longitude( item.getPoint().lng )
|
|
|
|
|
.latitude( item.getPoint().lat )
|
|
|
|
|
.icon( mMarkerIcon ) );
|
|
|
|
|
@@ -379,19 +356,9 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onDestroyView() {
|
|
|
|
|
Logger.w( TAG, "onDestroyView" );
|
|
|
|
|
Logger.w( TAG, "onDestroyView position=" + position );
|
|
|
|
|
super.onDestroyView();
|
|
|
|
|
getViewLifecycleOwner().getLifecycle().removeObserver( mPresenter );
|
|
|
|
|
mLocationClient.removeLocationListener( this );
|
|
|
|
|
if ( mLastClickedMarker != null ) {
|
|
|
|
|
mLastClickedMarker.destroy();
|
|
|
|
|
mLastClickedMarker = null;
|
|
|
|
|
}
|
|
|
|
|
if ( mPoiSearch != null ) {
|
|
|
|
|
mPoiSearch.destroy();
|
|
|
|
|
}
|
|
|
|
|
mMapService = null;
|
|
|
|
|
mPoiSearch = null;
|
|
|
|
|
mLocationClient = null;
|
|
|
|
|
ServiceHandler.getLocationClient().removeLocationListener( this );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|