opt
This commit is contained in:
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -229,7 +229,9 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
}
|
||||
|
||||
private void init() {
|
||||
mServiceApis = ( IMogoServiceApis ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation();
|
||||
if ( mServiceApis == null ) {
|
||||
mServiceApis = ( IMogoServiceApis ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation();
|
||||
}
|
||||
mMogoStatusManager = mServiceApis.getStatusManagerApi();
|
||||
}
|
||||
|
||||
@@ -388,6 +390,14 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
mPresenter.handleSchemeIntent( intent );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoServiceApis getApis() {
|
||||
if ( mServiceApis == null ) {
|
||||
mServiceApis = ( IMogoServiceApis ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation();
|
||||
}
|
||||
return mServiceApis;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
@@ -12,6 +12,7 @@ import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.map.navi.IMogoNavi;
|
||||
import com.mogo.module.main.constants.MainConstants;
|
||||
import com.mogo.module.main.livedata.CardSwitchLiveData;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
@@ -140,14 +141,7 @@ public class MainPresenter extends Presenter< MainView > {
|
||||
}
|
||||
|
||||
public void handleSchemeIntent( Intent intent ) {
|
||||
if ( intent == null || intent.getData() == null ) {
|
||||
return;
|
||||
}
|
||||
Uri target = intent.getData();
|
||||
switch ( target.getPath() ) {
|
||||
case "/main/switch2":
|
||||
mView.switch2Card( target.getQueryParameter( "type" ), true );
|
||||
break;
|
||||
}
|
||||
SchemeIntent.getInstance().init( getContext(), mView.getApis() );
|
||||
SchemeIntent.getInstance().handle( intent );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.module.main;
|
||||
|
||||
import com.mogo.commons.mvp.IView;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -36,4 +37,11 @@ public interface MainView extends IView {
|
||||
* 加载模块
|
||||
*/
|
||||
void loadModules();
|
||||
|
||||
/**
|
||||
* 接口水龙头
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoServiceApis getApis();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.mogo.module.main;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.module.common.ModuleNames;
|
||||
import com.mogo.module.main.livedata.CardInfo;
|
||||
import com.mogo.module.main.livedata.CardSwitchLiveData;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.utils.TipToast;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-04-20
|
||||
* <p>
|
||||
* scheme 意图处理
|
||||
* <p>
|
||||
* 导航:adb shell am start -d "mogo://launcher/main/switch2?type=navi'&'lon=116.327007'&'lat=39.977639"
|
||||
*/
|
||||
public class SchemeIntent {
|
||||
|
||||
private static final String TAG = "SchemeIntent";
|
||||
|
||||
public static final String TYPE_NAVI = "navi";
|
||||
|
||||
private IMogoServiceApis mApis;
|
||||
private Context mContext;
|
||||
|
||||
private SchemeIntent() {
|
||||
// private constructor
|
||||
}
|
||||
|
||||
private static final class InstanceHolder {
|
||||
private static final SchemeIntent INSTANCE = new SchemeIntent();
|
||||
}
|
||||
|
||||
public static SchemeIntent getInstance() {
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
public void init( Context context, IMogoServiceApis apis ) {
|
||||
mContext = context;
|
||||
mApis = apis;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
public void handle( Intent intent ) {
|
||||
if ( intent == null || intent.getData() == null ) {
|
||||
return;
|
||||
}
|
||||
Uri target = intent.getData();
|
||||
String path = target.getPath();
|
||||
if ( path == null || path.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
switch ( path ) {
|
||||
case "/main/switch2":
|
||||
handleSwitch2Action( target );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleSwitch2Action( Uri target ) {
|
||||
String type = target.getQueryParameter( "type" );
|
||||
switch ( type ) {
|
||||
case ModuleNames.CARD_TYPE_BUSINESS_OPERATION:
|
||||
case ModuleNames.CARD_TYPE_CARS_CHATTING:
|
||||
case ModuleNames.CARD_TYPE_NOVELTY:
|
||||
case ModuleNames.CARD_TYPE_ROAD_CONDITION:
|
||||
case ModuleNames.CARD_TYPE_SHARE_MUSIC:
|
||||
case ModuleNames.CARD_TYPE_USER_DATA:
|
||||
handleSwitchCardIntent( type );
|
||||
break;
|
||||
case TYPE_NAVI:
|
||||
handleNaviIntent( target );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleSwitchCardIntent( String type ) {
|
||||
CardSwitchLiveData.getInstance().postValue( new CardInfo( type, true ) );
|
||||
}
|
||||
|
||||
private void handleNaviIntent( Uri naviUri ) {
|
||||
if ( mApis == null ) {
|
||||
return;
|
||||
}
|
||||
String lon = naviUri.getQueryParameter( "lon" );
|
||||
String lat = naviUri.getQueryParameter( "lat" );
|
||||
|
||||
// TODO: 2020-04-20 补充场景
|
||||
|
||||
try {
|
||||
double dlon = Double.valueOf( lon );
|
||||
double dlat = Double.valueOf( lat );
|
||||
if ( mApis.getMapServiceApi().getNavi( mContext ).isNaviing() ) {
|
||||
mApis.getMapServiceApi().getNavi( mContext ).naviTo( new MogoLatLng( dlat, dlon ) );
|
||||
} else {
|
||||
mApis.getAddressManagerApi().calculatePath( new MogoLatLng( dlat, dlon ) );
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
TipToast.shortTip( "目的地异常,不能导航" );
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
import com.mogo.service.launcher.IMogoLauncher;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.module.IMogoAddressManager;
|
||||
import com.mogo.service.module.IMogoRegisterCenter;
|
||||
import com.mogo.service.module.IMogoSearchManager;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
@@ -59,6 +60,7 @@ public class MapPresenter extends Presenter< MapView > implements
|
||||
private IMogoStatusManager mStatusManager;
|
||||
private IMogoRegisterCenter mRegisterCenter;
|
||||
private IMogoLauncher mLauncher;
|
||||
private IMogoAddressManager mMogoAddressManager;
|
||||
private Rect mDisplayOverviewBounds;
|
||||
|
||||
public MapPresenter( MapView view ) {
|
||||
@@ -133,6 +135,8 @@ public class MapPresenter extends Presenter< MapView > implements
|
||||
int navi_route_prefer = intent.getIntExtra( "NAVI_ROUTE_PREFER", type );
|
||||
|
||||
|
||||
}else if (key_type == 20009) {
|
||||
onOpenNavi();
|
||||
}
|
||||
|
||||
///**
|
||||
@@ -221,6 +225,13 @@ public class MapPresenter extends Presenter< MapView > implements
|
||||
}
|
||||
}
|
||||
|
||||
private void onOpenNavi(){
|
||||
mLauncher.backToLauncher( getContext() );
|
||||
if ( !mMogoMapService.getNavi( getContext() ).isNaviing() && !mStatusManager.isSearchUIShow() ) {
|
||||
mMogoAddressManager.goSearch();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate( @NonNull LifecycleOwner owner ) {
|
||||
super.onCreate( owner );
|
||||
@@ -234,6 +245,7 @@ public class MapPresenter extends Presenter< MapView > implements
|
||||
mRegisterCenter = apis.getRegisterCenterApi();
|
||||
mRegisterCenter.registerMogoNaviListener( TAG, this );
|
||||
mLauncher = apis.getLauncherApi();
|
||||
mMogoAddressManager = apis.getAddressManagerApi();
|
||||
|
||||
IMogoNavi mogoNavi = mMogoMapService.getNavi( getContext() );
|
||||
mogoNavi.setCalculatePathDisplayBounds( new Rect(
|
||||
@@ -350,7 +362,7 @@ public class MapPresenter extends Presenter< MapView > implements
|
||||
|
||||
case VoiceConstants.CMD_MAP_HISTORY_UN_WAKEUP:
|
||||
case VoiceConstants.CMD_MAP_HISTORY:
|
||||
mSearchManager.showSearch();
|
||||
onOpenNavi();
|
||||
break;
|
||||
|
||||
case VoiceConstants.CMD_MAP_STOP_NAVI_MODE_UN_WAKEUP:
|
||||
|
||||
@@ -28,17 +28,11 @@ public class MogoSearchManager implements IMogoSearchManager {
|
||||
}
|
||||
|
||||
@Override public void showSearch() {
|
||||
SearchFragment searchFragment = new SearchFragment();
|
||||
SearchServiceHolder.INSTANCE.getFragmentManager()
|
||||
.push(new FragmentDescriptor.Builder().fragment(searchFragment)
|
||||
.tag( AMapConstants.PATH_FRAGMENT_SEARCH)
|
||||
.notifyMainModule(true)
|
||||
.build());
|
||||
AddressManager.INSTANCE.goSearch();
|
||||
}
|
||||
|
||||
@Override public void showMain() {
|
||||
SearchServiceHolder.INSTANCE.getFragmentManager()
|
||||
.clearAll();
|
||||
SearchServiceHolder.INSTANCE.getFragmentManager().clearAll();
|
||||
}
|
||||
|
||||
@Override public void speakDraft() {
|
||||
|
||||
@@ -34,9 +34,7 @@ object NaviManager {
|
||||
choosePath(intent, key_type)
|
||||
} else if (key_type == 10021) {
|
||||
SearchServiceHolder.getNavi().stopNavi()
|
||||
} else if (key_type == 20009) {
|
||||
SearchServiceHolder.mogoLauncher.backToLauncher(context)
|
||||
} else if (key_type == 10005) {
|
||||
} else if (key_type == 10005) {
|
||||
|
||||
// * 仅在导航场景下,⽀持第三⽅进⾏路线偏好的重新选择。
|
||||
// * `避免收费` |`1` `多策略算路` |`2` `不走高速` |`3` ` 躲避拥堵` |`4` `不走高速且避免收费` |`5` `不走高速且躲避拥堵` |`6`
|
||||
|
||||
Reference in New Issue
Block a user