opt
This commit is contained in:
@@ -11,6 +11,7 @@ import com.mogo.map.impl.amap.utils.ObjectUtils;
|
||||
import com.mogo.map.navi.IMogoNavi;
|
||||
import com.mogo.map.navi.MogoCalculatePath;
|
||||
import com.mogo.map.navi.MogoNaviConfig;
|
||||
import com.mogo.map.navi.OnCalculatePathItemClickInteraction;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -147,6 +148,21 @@ public class NaviClient implements IMogoNavi {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OnCalculatePathItemClickInteraction getItemClickInteraction() {
|
||||
if ( mAMapNaviListener != null ) {
|
||||
return mAMapNaviListener.getItemClickInteraction();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLineClickInteraction( OnCalculatePathItemClickInteraction lineClickInteraction ) {
|
||||
if ( mAMapNaviListener != null ) {
|
||||
mAMapNaviListener.setLineClickInteraction( lineClickInteraction );
|
||||
}
|
||||
}
|
||||
|
||||
// -- end
|
||||
|
||||
private boolean checkAMapNavi() {
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.mogo.map.impl.amap.message.AMapMessageManager;
|
||||
import com.mogo.map.impl.amap.utils.ObjectUtils;
|
||||
import com.mogo.map.navi.MogoCalculatePath;
|
||||
import com.mogo.map.navi.MogoNaviListenerHandler;
|
||||
import com.mogo.map.navi.OnCalculatePathItemClickInteraction;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.List;
|
||||
@@ -165,4 +166,17 @@ public class NaviListenerAdapter extends AMapNaviListenerAdapter {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public OnCalculatePathItemClickInteraction getItemClickInteraction() {
|
||||
if ( mNaviOverlayHelper != null ) {
|
||||
return mNaviOverlayHelper.getItemClickInteraction();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setLineClickInteraction( OnCalculatePathItemClickInteraction lineClickInteraction ) {
|
||||
if ( mNaviOverlayHelper != null ) {
|
||||
mNaviOverlayHelper.setLineClickInteraction( lineClickInteraction );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.mogo.map.impl.amap.AMapWrapper;
|
||||
import com.mogo.map.impl.amap.R;
|
||||
import com.mogo.map.impl.amap.overlay.RouteOverLayWrapper;
|
||||
import com.mogo.map.navi.MogoCalculatePath;
|
||||
import com.mogo.map.navi.OnCalculatePathItemClickInteraction;
|
||||
import com.mogo.utils.WindowUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
@@ -31,7 +32,7 @@ import java.util.TreeMap;
|
||||
* <p>
|
||||
* 导航路径管理
|
||||
*/
|
||||
public class NaviOverlayHelper implements MogoCalculatePath.OnItemClickInteraction {
|
||||
public class NaviOverlayHelper implements OnCalculatePathItemClickInteraction {
|
||||
|
||||
private static final String TAG = "NaviOverlayHelper";
|
||||
|
||||
@@ -52,9 +53,11 @@ public class NaviOverlayHelper implements MogoCalculatePath.OnItemClickInteracti
|
||||
private Rect mBoundRect = null;
|
||||
|
||||
private List< CalculatePathItem > mCalculatePathItems;
|
||||
private List< MogoCalculatePath > mPaths = new ArrayList<>();
|
||||
|
||||
private int mSelectedPathId;
|
||||
private CalculatePathItem mSelectedCalculatePathItem;
|
||||
private OnCalculatePathItemClickInteraction mLineClickInteraction;
|
||||
|
||||
public NaviOverlayHelper( AMapNavi mAMapNavi, AMap mAMap, Context mContext ) {
|
||||
this.mAMapNavi = mAMapNavi;
|
||||
@@ -132,7 +135,7 @@ public class NaviOverlayHelper implements MogoCalculatePath.OnItemClickInteracti
|
||||
mAMap.animateCamera( CameraUpdateFactory.newLatLngBoundsRect( bounds, mBoundRect.left, mBoundRect.right, mBoundRect.top, mBoundRect.bottom ) );
|
||||
}
|
||||
|
||||
private void checkAMapInstance(){
|
||||
private void checkAMapInstance() {
|
||||
if ( mAMap == null ) {
|
||||
mAMap = AMapWrapper.getAMap();
|
||||
}
|
||||
@@ -174,6 +177,9 @@ public class NaviOverlayHelper implements MogoCalculatePath.OnItemClickInteracti
|
||||
}
|
||||
mCalculatePathItems.clear();
|
||||
}
|
||||
if ( mPaths != null ) {
|
||||
mPaths.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,6 +192,16 @@ public class NaviOverlayHelper implements MogoCalculatePath.OnItemClickInteracti
|
||||
if ( polyline == null ) {
|
||||
return false;
|
||||
}
|
||||
if ( mPaths != null && !mPaths.isEmpty() ) {
|
||||
for ( MogoCalculatePath path : mPaths ) {
|
||||
if ( TextUtils.equals( path.getTagId(), polyline.getId() ) ) {
|
||||
if ( mLineClickInteraction != null ) {
|
||||
mLineClickInteraction.onItemClicked( path.getTagId() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return handleClickedPolyline( polyline.getId() );
|
||||
}
|
||||
|
||||
@@ -267,16 +283,15 @@ public class NaviOverlayHelper implements MogoCalculatePath.OnItemClickInteracti
|
||||
|
||||
|
||||
public List< MogoCalculatePath > getCalculateStrategies() {
|
||||
List< MogoCalculatePath > paths = new ArrayList<>();
|
||||
if ( mCalculatePathItems != null && !mCalculatePathItems.isEmpty() ) {
|
||||
for ( CalculatePathItem calculatePathItem : mCalculatePathItems ) {
|
||||
MogoCalculatePath path = new MogoCalculatePath( this );
|
||||
MogoCalculatePath path = new MogoCalculatePath();
|
||||
path.setDistance( calculatePathItem.getDistance() );
|
||||
path.setPathId( calculatePathItem.getId() );
|
||||
path.setStrategyName( calculatePathItem.getStrategyName() );
|
||||
path.setTime( calculatePathItem.getTime() );
|
||||
path.setTrafficLights( calculatePathItem.getTrafficNumber() );
|
||||
paths.add( path );
|
||||
mPaths.add( path );
|
||||
final RouteOverLayWrapper wrapper = calculatePathItem.getOverLazWrapper( true );
|
||||
if ( wrapper == null ) {
|
||||
continue;
|
||||
@@ -287,11 +302,20 @@ public class NaviOverlayHelper implements MogoCalculatePath.OnItemClickInteracti
|
||||
path.setTagId( wrapper.getTrafficColorfulPolyline().getId() );
|
||||
}
|
||||
}
|
||||
return paths;
|
||||
return mPaths;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClicked( String tagId ) {
|
||||
handleClickedPolyline( tagId );
|
||||
mAMapNavi.selectRouteId( getSelectedPathId() );
|
||||
}
|
||||
|
||||
public OnCalculatePathItemClickInteraction getItemClickInteraction() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setLineClickInteraction( OnCalculatePathItemClickInteraction lineClickInteraction ) {
|
||||
mLineClickInteraction = lineClickInteraction;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,4 +76,17 @@ public interface IMogoNavi {
|
||||
* @return 规划的路线
|
||||
*/
|
||||
List< MogoCalculatePath > getCalculatedStrategies();
|
||||
|
||||
/**
|
||||
* 获取列表Item点击回调
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
OnCalculatePathItemClickInteraction getItemClickInteraction();
|
||||
|
||||
|
||||
/**
|
||||
* 设置线条点击回调
|
||||
*/
|
||||
void setLineClickInteraction( OnCalculatePathItemClickInteraction itemClickInteraction );
|
||||
}
|
||||
|
||||
@@ -11,40 +11,34 @@ public class MogoCalculatePath {
|
||||
/**
|
||||
* 策略名称
|
||||
*/
|
||||
public String mStrategyName;
|
||||
private String mStrategyName;
|
||||
|
||||
/**
|
||||
* 时间
|
||||
*/
|
||||
public String mTime;
|
||||
private String mTime;
|
||||
|
||||
/**
|
||||
* 距离
|
||||
*/
|
||||
public String mDistance;
|
||||
private String mDistance;
|
||||
|
||||
/**
|
||||
* 红绿灯个数
|
||||
*/
|
||||
public int mTrafficLights;
|
||||
private int mTrafficLights;
|
||||
|
||||
/**
|
||||
* 路线ID,用于选择那一条线
|
||||
*/
|
||||
public String mTagId;
|
||||
private String mTagId;
|
||||
|
||||
/**
|
||||
* 规划的线路ID
|
||||
*/
|
||||
public int mPathId;
|
||||
private int mPathId;
|
||||
|
||||
/**
|
||||
* 点击事件
|
||||
*/
|
||||
public OnItemClickInteraction mOnItemClickInteraction;
|
||||
|
||||
public MogoCalculatePath( OnItemClickInteraction onItemClickInteraction ) {
|
||||
this.mOnItemClickInteraction = onItemClickInteraction;
|
||||
public MogoCalculatePath() {
|
||||
}
|
||||
|
||||
public String getStrategyName() {
|
||||
@@ -80,7 +74,6 @@ public class MogoCalculatePath {
|
||||
}
|
||||
|
||||
|
||||
|
||||
private StringBuilder mDescBuilder = null;
|
||||
|
||||
public String getDesc() {
|
||||
@@ -112,13 +105,4 @@ public class MogoCalculatePath {
|
||||
public void setPathId( int mPathId ) {
|
||||
this.mPathId = mPathId;
|
||||
}
|
||||
|
||||
public interface OnItemClickInteraction {
|
||||
|
||||
void onItemClicked( String tagId );
|
||||
}
|
||||
|
||||
public OnItemClickInteraction getOnItemClickInteraction() {
|
||||
return mOnItemClickInteraction;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mogo.map.navi;
|
||||
|
||||
/**
|
||||
* 规划路线交互接口
|
||||
*/
|
||||
public interface OnCalculatePathItemClickInteraction {
|
||||
|
||||
/**
|
||||
* 点击:列表点击、线路点击
|
||||
*
|
||||
* @param tagId 线条ID
|
||||
*/
|
||||
void onItemClicked( String tagId );
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import com.mogo.map.impl.amap.navi.NaviClient;
|
||||
import com.mogo.map.navi.IMogoNavi;
|
||||
import com.mogo.map.navi.MogoCalculatePath;
|
||||
import com.mogo.map.navi.MogoNaviConfig;
|
||||
import com.mogo.map.navi.OnCalculatePathItemClickInteraction;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -104,4 +105,19 @@ public class MogoNavi implements IMogoNavi {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OnCalculatePathItemClickInteraction getItemClickInteraction() {
|
||||
if ( mDelegate != null ) {
|
||||
return mDelegate.getItemClickInteraction();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLineClickInteraction( OnCalculatePathItemClickInteraction itemClickInteraction ) {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.setLineClickInteraction( itemClickInteraction );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,4 +99,13 @@ public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > impleme
|
||||
mIndicator.setViewPager( mAppsPager );
|
||||
mLoadingView.setVisibility( View.GONE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
if ( mPresenter != null ) {
|
||||
mPresenter.onDestroy( getViewLifecycleOwner() );
|
||||
}
|
||||
mPresenter = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,4 +59,9 @@ public class AppsPresenter extends Presenter< AppsView > {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy( @NonNull LifecycleOwner owner ) {
|
||||
super.onDestroy( owner );
|
||||
mView = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
android:id="@+id/module_apps_id_apps_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:overScrollMode="never"
|
||||
android:layout_marginTop="@dimen/dp_210" />
|
||||
|
||||
<com.mogo.module.apps.view.LinePageIndicator
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.module.extensions.entrance;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -11,11 +12,17 @@ import androidx.fragment.app.Fragment;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.model.MogoPoi;
|
||||
import com.mogo.map.navi.IMogoNavi;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.map.navi.MogoNaviInfo;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.extensions.ExtensionsModuleConst;
|
||||
import com.mogo.module.extensions.R;
|
||||
import com.mogo.module.extensions.navi.NaviInfoView;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
@@ -23,6 +30,7 @@ import com.mogo.service.fragmentmanager.FragmentDescriptor;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
import com.mogo.service.module.IMogoRegisterCenter;
|
||||
import com.mogo.service.windowview.IMogoWindowManager;
|
||||
import com.mogo.utils.TipToast;
|
||||
|
||||
@@ -32,7 +40,8 @@ import com.mogo.utils.TipToast;
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresenter > implements EntranceView {
|
||||
public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresenter > implements EntranceView,
|
||||
IMogoNaviListener, IMogoMapListener {
|
||||
|
||||
|
||||
private View mSearch;
|
||||
@@ -47,7 +56,7 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
private View mMove2CurrentLocation;
|
||||
|
||||
private NaviInfoView mNaviInfo;
|
||||
private View mExitNavi;
|
||||
private TextView mExitNavi;
|
||||
|
||||
private IMogoMapService mService;
|
||||
private IMogoMapUIController mMApUIController;
|
||||
@@ -55,10 +64,13 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
private IMogoNavi mMogoNavi;
|
||||
private IMogoFragmentManager mMogoFragmentManager;
|
||||
|
||||
private IMogoRegisterCenter mMogoRegisterCenter;
|
||||
|
||||
/**
|
||||
* 搜索莫模块
|
||||
*/
|
||||
private IMogoModuleProvider mSearchProvider;
|
||||
private boolean mIsLock = true;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
@@ -107,7 +119,11 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
mExitNavi = findViewById( R.id.module_entrance_id_exit_navi );
|
||||
mExitNavi.setOnClickListener( view -> {
|
||||
if ( mMogoNavi != null ) {
|
||||
mMogoNavi.stopNavi();
|
||||
if ( mIsLock ) {
|
||||
mMogoNavi.stopNavi();
|
||||
} else {
|
||||
mMApUIController.recoverLockMode();
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
@@ -123,8 +139,91 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
public void onActivityCreated( @Nullable Bundle savedInstanceState ) {
|
||||
super.onActivityCreated( savedInstanceState );
|
||||
mService = ( IMogoMapService ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation( getContext() );
|
||||
mMogoRegisterCenter = ( IMogoRegisterCenter ) ARouter.getInstance().build( MogoServicePaths.PATH_REGISTER_CENTER ).navigation( getContext() );
|
||||
mMApUIController = mService.getMapUIController();
|
||||
mMogoLocationClient = mService.getLocationClient( getContext() );
|
||||
mMogoNavi = mService.getNavi( getContext() );
|
||||
|
||||
mMogoRegisterCenter.registerMogoNaviListener( ExtensionsModuleConst.TYPE_ENTRANCE, this );
|
||||
mMogoRegisterCenter.registerMogoMapListener( ExtensionsModuleConst.TYPE_ENTRANCE, this );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onInitNaviFailure() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitNaviSuccess() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviInfoUpdate( MogoNaviInfo naviinfo ) {
|
||||
if ( naviinfo == null ) {
|
||||
return;
|
||||
}
|
||||
mNaviInfo.notifyChanged( naviinfo );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartNavi() {
|
||||
mCommonAddress.setVisibility( View.GONE );
|
||||
mNaviInfo.setVisibility( View.VISIBLE );
|
||||
mExitNavi.setVisibility( View.VISIBLE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopNavi() {
|
||||
mCommonAddress.setVisibility( View.VISIBLE );
|
||||
mNaviInfo.setVisibility( View.GONE );
|
||||
mExitNavi.setVisibility( View.GONE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCalculateSuccess() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onoCalculateFailed() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapLoaded() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouch( MotionEvent motionEvent ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPOIClick( MogoPoi poi ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapClick( MogoLatLng latLng ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLockMap( boolean isLock ) {
|
||||
mIsLock = isLock;
|
||||
if ( isLock ) {
|
||||
mExitNavi.setText( R.string.module_ext_str_exit_navi );
|
||||
} else {
|
||||
mExitNavi.setText( R.string.module_ext_str_continue_navi );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapModeChanged( EnumMapUI ui ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapChanged( MogoLatLng latLng, float zoom, float tilt, float bearing ) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,6 @@
|
||||
|
||||
<string name="module_map_str_search_hint">搜索目的地</string>
|
||||
<string name="module_map_str_upload_road_condition">上报\n路况</string>
|
||||
<string name="module_ext_str_exit_navi">退出导航</string>
|
||||
<string name="module_ext_str_continue_navi">继续导航</string>
|
||||
</resources>
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
android:id="@+id/module_main_id_cards_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:overScrollMode="never"
|
||||
android:layout_marginBottom="@dimen/dp_211"
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="@dimen/dp_20" />
|
||||
|
||||
@@ -87,7 +87,7 @@ class ChoosePathFragment : BaseFragment(), IMogoNaviListener {
|
||||
mAdapter.setOnClickListener {
|
||||
var position = it.getTag(R.id.tag_position) as Int
|
||||
mAdapter.setCurrent(position)
|
||||
mAdapter.currentItem.onItemClickInteraction.onItemClicked(mAdapter.currentItem.mTagId)
|
||||
SearchServiceHolder.getNavi(context!!).itemClickInteraction.onItemClicked(mAdapter.currentItem.tagId)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user