Merge remote-tracking branch 'origin/feature/v2.0.0' into feature/v2.0.0
This commit is contained in:
@@ -1,37 +1,20 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.module.apps.adapter.AppIndicatorAdapter;
|
||||
import com.mogo.module.apps.adapter.base.RecycleViewHolder;
|
||||
import com.mogo.module.apps.model.NavigatorApp;
|
||||
import com.mogo.module.apps.applaunch.AppLauncher;
|
||||
import com.mogo.module.apps.applaunch.BaseAppLauncher;
|
||||
import com.mogo.module.apps.applaunch.InternalFunctionLauncher;
|
||||
import com.mogo.module.apps.model.NavigatorApps;
|
||||
import com.mogo.module.apps.utils.CardScaleTransformer;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.analytics.IMogoAnalytics;
|
||||
import com.mogo.service.cardmanager.IMogoCardChangedListener;
|
||||
import com.mogo.service.fragmentmanager.FragmentDescriptor;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.yarolegovich.discretescrollview.DiscreteScrollLayoutManager;
|
||||
import com.yarolegovich.discretescrollview.DiscreteScrollView;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -40,27 +23,14 @@ import java.util.Map;
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AppNavigatorFragment extends MvpFragment<AppNavigatorView, AppNavigatorPresenter>
|
||||
implements AppNavigatorView, DiscreteScrollView.OnItemChangedListener<RecycleViewHolder>,
|
||||
DiscreteScrollView.ScrollStateChangeListener<RecycleViewHolder>,
|
||||
IMogoCardChangedListener {
|
||||
public class AppNavigatorFragment extends MvpFragment< AppNavigatorView, AppNavigatorPresenter > implements AppNavigatorView {
|
||||
|
||||
private static final String TAG = "AppNavigatorFragment";
|
||||
private View mApps;
|
||||
|
||||
private IMogoFragmentManager mMogoFragmentManager;
|
||||
List<NavigatorApp> apps;
|
||||
private RecyclerView mNavigatorAppsList;
|
||||
private AppIndicatorAdapter mAppIndicatorAdapter;
|
||||
|
||||
/**
|
||||
* 搜索莫模块
|
||||
*/
|
||||
private IMogoModuleProvider mSearchProvider;
|
||||
|
||||
private IMogoAnalytics mMogoAnalytics;
|
||||
private DiscreteScrollView scroller;
|
||||
|
||||
private static int CARD_SIZE = 6;
|
||||
private AppIndicatorAdapter appIndicatorAdapter;
|
||||
private BaseAppLauncher mLauncher;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
@@ -69,228 +39,49 @@ public class AppNavigatorFragment extends MvpFragment<AppNavigatorView, AppNavig
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
// mApps.setOnClickListener( view -> {
|
||||
// openAppsPanel();
|
||||
// trackNavigatorClickEvent( 4 );
|
||||
// } );
|
||||
mLauncher = new InternalFunctionLauncher( getActivity() );
|
||||
mLauncher.setNext( new AppLauncher() );
|
||||
|
||||
mMogoFragmentManager = (IMogoFragmentManager) ARouter.getInstance()
|
||||
.build(MogoServicePaths.PATH_FRAGMENT_MANAGER)
|
||||
.navigation();
|
||||
|
||||
mApps = findViewById(R.id.module_apps_id_apps);
|
||||
|
||||
scroller = findViewById(R.id.module_apps_id_scroller);
|
||||
|
||||
scroller.setRatio(330 / 523F);
|
||||
//scroller.setRatio(176/279F);
|
||||
scroller.setSlideOnFling(true);
|
||||
scroller.addOnItemChangedListener(this);
|
||||
scroller.addScrollStateChangeListener(this);
|
||||
//scroller.setItemTransitionTimeMillis(DiscreteScrollViewOptions.getTransitionTime());
|
||||
apps = NavigatorApps.getApps();
|
||||
CARD_SIZE = apps.size();
|
||||
scroller.setItemTransformer(new CardScaleTransformer.Builder()
|
||||
.setMinScale(0.84f)
|
||||
.build());
|
||||
|
||||
appIndicatorAdapter = new AppIndicatorAdapter(getContext(), apps);
|
||||
|
||||
appIndicatorAdapter.setOnClickListener(new View.OnClickListener() {
|
||||
@Override public void onClick(View v) {
|
||||
NavigatorApp item = (NavigatorApp) v.getTag();
|
||||
AppServiceHandler.getMogoCardManager().switch2(item.mModuleType);
|
||||
}
|
||||
});
|
||||
|
||||
scroller.setAdapter(appIndicatorAdapter);
|
||||
scroller.scrollToPosition(Integer.MAX_VALUE / 2 - 1);
|
||||
//mNavigation.setOnClickListener( view -> {
|
||||
// openSearchPanel();
|
||||
// trackNavigatorClickEvent( 1 );
|
||||
//} );
|
||||
//mMediaCenter.setOnClickListener( view -> {
|
||||
// try {
|
||||
// LaunchUtils.launchByPkg( getContext(), AppsConst.APP_PKG_MUSIC );
|
||||
// trackNavigatorClickEvent( 2 );
|
||||
// } catch ( Exception e ) {
|
||||
// TipToast.shortTip( R.string.module_apps_str_no_app );
|
||||
// }
|
||||
//} );
|
||||
//mCarSettings.setOnClickListener( view -> {
|
||||
// try {
|
||||
// LaunchUtils.launchByPkg( getContext(), AppsConst.APP_PKG_CAR_SETTINGS );
|
||||
// trackNavigatorClickEvent( 3 );
|
||||
// } catch ( Exception e ) {
|
||||
// TipToast.shortTip( R.string.module_apps_str_no_app );
|
||||
// }
|
||||
//} );
|
||||
mApps.setOnClickListener(view -> {
|
||||
openAppsPanel();
|
||||
|
||||
//AppServiceHandler.getMogoCardManager()
|
||||
// .switch2(apps.get((int) (Math.random() * 6)).mModuleType);
|
||||
|
||||
trackNavigatorClickEvent(4);
|
||||
});
|
||||
AppServiceHandler.init(getContext());
|
||||
|
||||
AppServiceHandler.getMogoCardManager().registerCardChangedListener(TAG, this);
|
||||
}
|
||||
|
||||
private void scrollToCenter(int index) {
|
||||
|
||||
mNavigatorAppsList = findViewById( R.id.module_apps_id_apps_list );
|
||||
mNavigatorAppsList.setLayoutManager( new LinearLayoutManager( getActivity(), RecyclerView.VERTICAL, false ) );
|
||||
mAppIndicatorAdapter = new AppIndicatorAdapter( getContext(), NavigatorApps.getApps() );
|
||||
mAppIndicatorAdapter.setOnItemClickedListener( ( data, position ) -> {
|
||||
mLauncher.launch( getContext(), data );
|
||||
} );
|
||||
mNavigatorAppsList.setAdapter( mAppIndicatorAdapter );
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected AppNavigatorPresenter createPresenter() {
|
||||
return new AppNavigatorPresenter(this);
|
||||
return new AppNavigatorPresenter( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
mMogoFragmentManager = (IMogoFragmentManager) ARouter.getInstance()
|
||||
.build(MogoServicePaths.PATH_FRAGMENT_MANAGER)
|
||||
.navigation(getContext());
|
||||
mMogoAnalytics = (IMogoAnalytics) ARouter.getInstance()
|
||||
.build(MogoServicePaths.PATH_UTILS_ANALYTICS)
|
||||
.navigation(getContext());
|
||||
public void onActivityCreated( @Nullable Bundle savedInstanceState ) {
|
||||
super.onActivityCreated( savedInstanceState );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openAppsPanel() {
|
||||
AppsListActivity.start(getActivity());
|
||||
AppsListActivity.start( getActivity() );
|
||||
}
|
||||
|
||||
private void trackNavigatorClickEvent(int type) {
|
||||
final Map<String, Object> properties = new HashMap<>();
|
||||
properties.put("type", type);
|
||||
mMogoAnalytics.track("Launcher_APP_Icon", properties);
|
||||
private void trackNavigatorClickEvent( int type ) {
|
||||
final Map< String, Object > properties = new HashMap<>();
|
||||
properties.put( "type", type );
|
||||
AppServiceHandler.getMogoAnalytics().track( "Launcher_APP_Icon", properties );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
if (mPresenter != null) {
|
||||
mPresenter.onDestroy(getViewLifecycleOwner());
|
||||
if ( mPresenter != null ) {
|
||||
mPresenter.onDestroy( getViewLifecycleOwner() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCurrentItemChanged(@Nullable RecycleViewHolder viewHolder, int i) {
|
||||
Logger.d(TAG, "onCurrentItemChanged--position--" + i % CARD_SIZE);
|
||||
int currentPosition = (i - 2) % CARD_SIZE;
|
||||
|
||||
//if (!scroller.isComputingLayout()) {
|
||||
// appIndicatorAdapter.setCurrentPos(i);
|
||||
//}
|
||||
//this.currentPosition=currentPosition;
|
||||
AppServiceHandler.getMogoCardManager().switch2(apps.get(i % CARD_SIZE).mModuleType, true);
|
||||
|
||||
//holder.showText();
|
||||
|
||||
//ImageView view = viewHolder.getView(R.id.module_apps_id_app_icon);
|
||||
//view.setImageResource(apps.get(currentPosition).getmIconId());
|
||||
//
|
||||
//TextView tvTitle = viewHolder.getView(R.id.module_apps_id_app_name);
|
||||
//tvTitle.setTextColor(getResources().getColor(R.color.white));
|
||||
|
||||
}
|
||||
|
||||
@Override public void onScrollStart(@NonNull RecycleViewHolder viewHolder, int i) {
|
||||
int currentPosition = i % CARD_SIZE - 2;
|
||||
//
|
||||
//ImageView view = viewHolder.getView(R.id.module_apps_id_app_icon);
|
||||
//
|
||||
//
|
||||
//view.setImageResource(apps.get(currentPosition).mUncheckedIconId);
|
||||
//TextView tvTitle = viewHolder.getView(R.id.module_apps_id_app_name);
|
||||
//tvTitle.setTextColor(getResources().getColor(R.color.white_80));
|
||||
|
||||
}
|
||||
|
||||
@Override public void onScrollEnd(@NonNull RecycleViewHolder viewHolder, int i) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScroll(float v, int i, int i1, @Nullable RecycleViewHolder viewHolder,
|
||||
@Nullable RecycleViewHolder t1) {
|
||||
|
||||
}
|
||||
|
||||
//private int currentPosition = 0;
|
||||
|
||||
@Override public void onSwitched(int position, String moduleName) {
|
||||
//int index = (position - scroller.getCurrentItem() % CARD_SIZE + 2) % CARD_SIZE;
|
||||
//int i = scroller.getCurrentItem() + index;
|
||||
DiscreteScrollLayoutManager layoutManager =
|
||||
(DiscreteScrollLayoutManager) scroller.getLayoutManager();
|
||||
|
||||
int currentPosition = (scroller.getCurrentItem() - 2) % CARD_SIZE;
|
||||
|
||||
int index = position - currentPosition;
|
||||
|
||||
if (index == 0) {
|
||||
return;
|
||||
}
|
||||
if (index <= -3) {
|
||||
index += CARD_SIZE;
|
||||
} else if (index >= 3) {
|
||||
index = index - CARD_SIZE;
|
||||
}
|
||||
//RecyclerView 的特性,如果是否在屏幕内
|
||||
//if (index < 0) {
|
||||
// index -= 2;
|
||||
//}
|
||||
|
||||
Logger.d(TAG, "position--"
|
||||
+ position
|
||||
+ "index--"
|
||||
+ index
|
||||
+ "scroll-->"
|
||||
+ scroller.getCurrentItem()
|
||||
+ index);
|
||||
|
||||
//scroller.setPendingScroll(getResources().getDimensionPixelSize(R.dimen.dp_137)*index);
|
||||
//layoutManager.scrollToPositionWithOffset(scroller.getCurrentItem() + index,0);
|
||||
//scroller.smoothScrollBy(getResources().getDimensionPixelSize(R.dimen.dp_137)*index,0);
|
||||
|
||||
if (Math.abs(index) == 1) {
|
||||
scroller.smoothScrollBy(getResources().getDimensionPixelSize(R.dimen.dp_137) * index,
|
||||
0, null, 10);
|
||||
} else {
|
||||
layoutManager.startSmoothPendingScroll(layoutManager.getCurrentPosition() + index);
|
||||
}
|
||||
//layoutManager.smoothScrollToPosition(scroller.getCurrentItem() + index);
|
||||
//currentPosition = position;
|
||||
}
|
||||
|
||||
private void printIds(View view) {
|
||||
System.out.println(view.getId());
|
||||
if (view instanceof ViewGroup) {
|
||||
int childCount = ((ViewGroup) view).getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
printIds(((ViewGroup) view).getChildAt(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void print(View view) {
|
||||
|
||||
ArrayList<View> views = new ArrayList<>();
|
||||
views.add(view);
|
||||
|
||||
while (views.size() > 0) {
|
||||
System.out.println(view.getId());
|
||||
View remove = views.remove(0);
|
||||
|
||||
if (remove instanceof ViewGroup) {
|
||||
|
||||
int childCount = ((ViewGroup) view).getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
views.add(((ViewGroup) view).getChildAt(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ public class AppNavigatorPresenter extends Presenter< AppNavigatorView > impleme
|
||||
@Override
|
||||
public void onCreate( @NonNull LifecycleOwner owner ) {
|
||||
super.onCreate( owner );
|
||||
mIntentManager = ( IMogoIntentManager ) ARouter.getInstance().build( MogoServicePaths.PATH_INTENT_MANAGER ).navigation( getContext() );
|
||||
mMogoStatusManager = ( IMogoStatusManager ) ARouter.getInstance().build( MogoServicePaths.PATH_STATUS_MANAGER ).navigation( getContext() );
|
||||
mIntentManager = AppServiceHandler.getApis().getIntentManagerApi();
|
||||
mMogoStatusManager = AppServiceHandler.getApis().getStatusManagerApi();
|
||||
// 预加载应用列表,空间换时间
|
||||
AppsModel.getInstance( getContext() ).load( null );
|
||||
}
|
||||
@@ -68,6 +68,7 @@ public class AppNavigatorPresenter extends Presenter< AppNavigatorView > impleme
|
||||
return;
|
||||
}
|
||||
try {
|
||||
AppServiceHandler.getApis().getAdasControllerApi().closeADAS();
|
||||
JSONObject object = new JSONObject( intent.getStringExtra( "data" ) );
|
||||
String app = object.optString( "object" );
|
||||
String operation = object.optString( "operation" );
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
import com.mogo.map.marker.IMogoMarkerManager;
|
||||
import com.mogo.map.navi.IMogoNavi;
|
||||
@@ -27,6 +29,7 @@ import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
* version: 1.0
|
||||
*/
|
||||
public class AppServiceHandler {
|
||||
|
||||
private static final String TAG = "AppServiceHandler";
|
||||
|
||||
private static IMogoServiceApis mApis;
|
||||
@@ -34,17 +37,18 @@ public class AppServiceHandler {
|
||||
private static IMogoAnalytics mMogoAnalytics;
|
||||
private static IGuideShowProvider mMogoGuideShow;
|
||||
|
||||
|
||||
public static void init( final Context context ) {
|
||||
mApis = ( IMogoServiceApis ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation( context );
|
||||
mMogoCardManager = mApis.getCardManagerApi();
|
||||
mMogoAnalytics = mApis.getAnalyticsApi();
|
||||
mMogoGuideShow = (IGuideShowProvider) ARouter.getInstance().build(GuideShowProviderConstant.GUIDE_SHOW_PROVIDER).navigation(context);
|
||||
mMogoGuideShow = ( IGuideShowProvider ) ARouter.getInstance().build( GuideShowProviderConstant.GUIDE_SHOW_PROVIDER ).navigation( context );
|
||||
|
||||
}
|
||||
|
||||
public static IMogoCardManager getMogoCardManager() {
|
||||
return mMogoCardManager;
|
||||
}
|
||||
|
||||
public static IMogoAnalytics getMogoAnalytics() {
|
||||
return mMogoAnalytics;
|
||||
}
|
||||
@@ -52,4 +56,11 @@ public class AppServiceHandler {
|
||||
public static IGuideShowProvider getMogoGuideShow() {
|
||||
return mMogoGuideShow;
|
||||
}
|
||||
|
||||
public static IMogoServiceApis getApis() {
|
||||
if ( mApis == null ) {
|
||||
mApis = ( IMogoServiceApis ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation( AbsMogoApplication.getApp() );
|
||||
}
|
||||
return mApis;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class AppsFragmentProvider implements IMogoModuleProvider {
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
|
||||
AppServiceHandler.init( context );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,6 +6,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.module.apps.applaunch.AppLaunchFilter;
|
||||
import com.mogo.module.apps.applaunch.AppLauncher;
|
||||
@@ -36,7 +37,7 @@ import java.util.Set;
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AppsPresenter extends Presenter<AppsView> {
|
||||
public class AppsPresenter extends Presenter< AppsView > {
|
||||
|
||||
private static final String TAG = "AppsPresenter";
|
||||
|
||||
@@ -48,61 +49,62 @@ public class AppsPresenter extends Presenter<AppsView> {
|
||||
private IMogoCardManager mCardManager;
|
||||
private IMogoStatusManager mMogoStatusManager;
|
||||
|
||||
public AppsPresenter(AppsView view) {
|
||||
super(view);
|
||||
mApis = (IMogoServiceApis)ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation(getContext());
|
||||
public AppsPresenter( AppsView view ) {
|
||||
super( view );
|
||||
mApis = ( IMogoServiceApis ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation( getContext() );
|
||||
mCardManager = mApis.getCardManagerApi();
|
||||
CardAppLauncher cardAppLauncher = new CardAppLauncher(this, mCardManager);
|
||||
GuideShowLauncher guideShowLauncher = new GuideShowLauncher(mApis.getMapServiceApi().getNavi( getContext() ));
|
||||
cardAppLauncher.setNext(guideShowLauncher);
|
||||
guideShowLauncher.setNext(new AppLauncher());
|
||||
CardAppLauncher cardAppLauncher = new CardAppLauncher( this, mCardManager );
|
||||
GuideShowLauncher guideShowLauncher = new GuideShowLauncher( mApis.getMapServiceApi().getNavi( getContext() ) );
|
||||
cardAppLauncher.setNext( guideShowLauncher );
|
||||
guideShowLauncher.setNext( new AppLauncher() );
|
||||
mLauncher = cardAppLauncher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@NonNull LifecycleOwner owner) {
|
||||
super.onCreate(owner);
|
||||
public void onCreate( @NonNull LifecycleOwner owner ) {
|
||||
super.onCreate( owner );
|
||||
renderAppsList();
|
||||
AppsListChangedLiveData.getInstance().observeForever(bool -> {
|
||||
if (mView != null) {
|
||||
AppsListChangedLiveData.getInstance().observeForever( bool -> {
|
||||
if ( mView != null ) {
|
||||
renderAppsList();
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
mAnalytics = mApis.getAnalyticsApi();
|
||||
mMogoStatusManager = mApis.getStatusManagerApi();
|
||||
mMogoStatusManager.setAppListUIShow(TAG, true);
|
||||
mMogoStatusManager.setAppListUIShow( TAG, true );
|
||||
}
|
||||
|
||||
private void renderAppsList() {
|
||||
ThreadPoolService.execute(() -> {
|
||||
AppsModel.getInstance(getContext()).load(appInfoList -> {
|
||||
ThreadPoolService.execute( () -> {
|
||||
AppsModel.getInstance( getContext() ).load( appInfoList -> {
|
||||
|
||||
Logger.d(TAG, "apps: %s", appInfoList);
|
||||
final Map<Integer, List<AppInfo>> result = addOthersEntrances( appInfoList );
|
||||
UiThreadHandler.post(() -> {
|
||||
if (mView != null) {
|
||||
Logger.d( TAG, "apps: %s", appInfoList );
|
||||
final Map< Integer, List< AppInfo > > result = addOthersEntrances( appInfoList );
|
||||
UiThreadHandler.post( () -> {
|
||||
if ( mView != null ) {
|
||||
mView.renderApps( result );
|
||||
}
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增入口
|
||||
*
|
||||
* @param appInfoMap
|
||||
* @return
|
||||
*/
|
||||
private Map<Integer, List<AppInfo>> addOthersEntrances( Map<Integer, List<AppInfo>> appInfoMap) {
|
||||
Map<Integer, List<AppInfo>> result = new HashMap<>();
|
||||
private Map< Integer, List< AppInfo > > addOthersEntrances( Map< Integer, List< AppInfo > > appInfoMap ) {
|
||||
Map< Integer, List< AppInfo > > result = new HashMap<>();
|
||||
|
||||
if ( appInfoMap != null && !appInfoMap.isEmpty() ) {
|
||||
// val deep copy
|
||||
Set<Integer> keys = appInfoMap.keySet();
|
||||
Set< Integer > keys = appInfoMap.keySet();
|
||||
for ( Integer key : keys ) {
|
||||
List<AppInfo> val = appInfoMap.get( key );
|
||||
List< AppInfo > val = appInfoMap.get( key );
|
||||
try {
|
||||
result.put( key, new ArrayList<>( val ) );
|
||||
} catch ( Exception e ) {
|
||||
@@ -112,16 +114,16 @@ public class AppsPresenter extends Presenter<AppsView> {
|
||||
}
|
||||
|
||||
// 手动添加无法识别到的app
|
||||
List<AppInfo> apps = UnScannedApps.getUnScannedApps();
|
||||
List< AppInfo > apps = UnScannedApps.getUnScannedApps();
|
||||
if ( apps != null && !apps.isEmpty() ) {
|
||||
for ( AppInfo app : apps ) {
|
||||
if ( app == null ) {
|
||||
continue;
|
||||
}
|
||||
Set<Integer> keys = result.keySet();
|
||||
Set< Integer > keys = result.keySet();
|
||||
boolean addFlag = true;
|
||||
for ( Integer key : keys ) {
|
||||
List<AppInfo> val = result.get( key );
|
||||
List< AppInfo > val = result.get( key );
|
||||
// 无法扫描到蓝牙电话app,这里手动添加
|
||||
for ( AppInfo appInfo : val ) {
|
||||
if ( appInfo == null ) {
|
||||
@@ -137,71 +139,77 @@ public class AppsPresenter extends Presenter<AppsView> {
|
||||
}
|
||||
}
|
||||
if ( addFlag ) {
|
||||
growthCapacity(result);
|
||||
result.get(result.size() - 1).add(app);
|
||||
growthCapacity( result );
|
||||
result.get( result.size() - 1 ).add( app );
|
||||
}
|
||||
}
|
||||
}
|
||||
growthCapacity(result);
|
||||
growthCapacity( result );
|
||||
// 添加介绍入口
|
||||
result.get(result.size() - 1).add(new AppInfo(GuideShowLauncher.APP_INFO_NAME_GUIDE_SHOW, getContext().getPackageName(), null, 0, null, R.drawable.module_apps_ic_guide_show));
|
||||
result.get( result.size() - 1 ).add( new AppInfo( GuideShowLauncher.APP_INFO_NAME_GUIDE_SHOW, getContext().getPackageName(), null, 0, null, R.drawable.module_apps_ic_guide_show ) );
|
||||
if ( DebugConfig.isDebug() ) {
|
||||
// 添加测试入口
|
||||
growthCapacity( result );
|
||||
result.get( result.size() - 1 ).add( new AppInfo( "包管理程序", "com.mogo.packages.manager", null, 0, null, -1 ) );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 扩容
|
||||
*
|
||||
* @param target
|
||||
*/
|
||||
private void growthCapacity( Map<Integer, List<AppInfo>> target ){
|
||||
private void growthCapacity( Map< Integer, List< AppInfo > > target ) {
|
||||
if ( target == null ) {
|
||||
return;
|
||||
}
|
||||
if (target.isEmpty()) {
|
||||
target.put(0, new ArrayList<>());
|
||||
} else if (target.get(target.size() - 1) == null) {
|
||||
target.put(target.size() - 1, new ArrayList<>());
|
||||
} else if (target.get(target.size() - 1).size() == AppsConst.TOTAL_SIZE_EACH_PAGE) {
|
||||
target.put(target.size(), new ArrayList<>());
|
||||
if ( target.isEmpty() ) {
|
||||
target.put( 0, new ArrayList<>() );
|
||||
} else if ( target.get( target.size() - 1 ) == null ) {
|
||||
target.put( target.size() - 1, new ArrayList<>() );
|
||||
} else if ( target.get( target.size() - 1 ).size() == AppsConst.TOTAL_SIZE_EACH_PAGE ) {
|
||||
target.put( target.size(), new ArrayList<>() );
|
||||
}
|
||||
}
|
||||
|
||||
public void launch(AppInfo appInfo) {
|
||||
if (appInfo == null) {
|
||||
public void launch( AppInfo appInfo ) {
|
||||
if ( appInfo == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
trackAppClicked(appInfo);
|
||||
trackAppClicked( appInfo );
|
||||
try {
|
||||
mLauncher.launch(getContext(), appInfo);
|
||||
} catch (Exception e) {
|
||||
mLauncher.launch( getContext(), appInfo );
|
||||
} catch ( Exception e ) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void trackAppClicked(AppInfo appInfo) {
|
||||
if (appInfo == null) {
|
||||
private void trackAppClicked( AppInfo appInfo ) {
|
||||
if ( appInfo == null ) {
|
||||
return;
|
||||
}
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put("appname", appInfo.getName());
|
||||
properties.put("packagename", appInfo.getPackageName());
|
||||
properties.put("appversion", appInfo.getVersionName());
|
||||
properties.put("from", 1);
|
||||
mAnalytics.track("appenterfront", properties);
|
||||
Map< String, Object > properties = new HashMap<>();
|
||||
properties.put( "appname", appInfo.getName() );
|
||||
properties.put( "packagename", appInfo.getPackageName() );
|
||||
properties.put( "appversion", appInfo.getVersionName() );
|
||||
properties.put( "from", 1 );
|
||||
mAnalytics.track( "appenterfront", properties );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy(@NonNull LifecycleOwner owner) {
|
||||
super.onDestroy(owner);
|
||||
mMogoStatusManager.setAppListUIShow(TAG, false);
|
||||
public void onDestroy( @NonNull LifecycleOwner owner ) {
|
||||
super.onDestroy( owner );
|
||||
mMogoStatusManager.setAppListUIShow( TAG, false );
|
||||
AppsListChangedLiveData.getInstance().release();
|
||||
mView = null;
|
||||
mLauncher.destroy();
|
||||
}
|
||||
|
||||
public void exit() {
|
||||
if (mView != null) {
|
||||
if ( mView != null ) {
|
||||
mView.exit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,62 +1,34 @@
|
||||
package com.mogo.module.apps.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.mogo.module.apps.R;
|
||||
import com.mogo.module.apps.adapter.base.RecycleBaseAdapter;
|
||||
import com.mogo.module.apps.adapter.base.RecycleViewHolder;
|
||||
import com.mogo.module.apps.model.AppInfo;
|
||||
import com.mogo.module.apps.model.NavigatorApp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
* 2020-03-09.
|
||||
*/
|
||||
public class AppIndicatorAdapter extends RecycleBaseAdapter<NavigatorApp> {
|
||||
public class AppIndicatorAdapter extends RecycleBaseAdapter< AppInfo > {
|
||||
|
||||
|
||||
private int currentPos;
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public AppIndicatorAdapter(Context context, List<NavigatorApp> list
|
||||
) {
|
||||
super(context, list, R.layout.module_apps_item_app_indicator);
|
||||
public AppIndicatorAdapter( Context context, List< AppInfo > list ) {
|
||||
super( context, list, R.layout.module_apps_item_app_indicator );
|
||||
}
|
||||
|
||||
@Override public int getItemCount() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override public void onBindViewHolder(RecycleViewHolder holder, NavigatorApp integer) {
|
||||
ImageView ivIndicator = holder.getView(R.id.module_apps_id_app_icon);
|
||||
ivIndicator.setImageResource(integer.getmIconId());
|
||||
holder.setText(R.id.module_apps_id_app_name,integer.getmName() );
|
||||
|
||||
TextView tvTitle = holder.getView(R.id.module_apps_id_app_name);
|
||||
if (currentPos==holder.getLayoutPosition()) {
|
||||
ivIndicator.setImageResource(integer.getmIconId());
|
||||
tvTitle.setTextColor(ContextCompat.getColor(context,R.color.white));
|
||||
}else {
|
||||
tvTitle.setTextColor(ContextCompat.getColor(context,R.color.white_80));
|
||||
ivIndicator.setImageResource(integer.getmUncheckedIconId());
|
||||
}
|
||||
holder.itemView.setTag(integer);
|
||||
holder.itemView.setOnClickListener(onClickListener);
|
||||
|
||||
}
|
||||
|
||||
public void setOnClickListener(View.OnClickListener onClickListener) {
|
||||
this.onClickListener = onClickListener;
|
||||
}
|
||||
|
||||
public void setCurrentPos(int currentPos){
|
||||
this.currentPos=currentPos;
|
||||
notifyDataSetChanged();
|
||||
@Override
|
||||
public void onBindViewHolder( RecycleViewHolder holder, AppInfo app, int position ) {
|
||||
ImageView ivIndicator = holder.getView( R.id.module_apps_id_app_icon );
|
||||
ivIndicator.setImageResource( app.getIconResId() );
|
||||
holder.itemView.setOnClickListener( view -> {
|
||||
if ( getOnItemClickedListener() != null ) {
|
||||
getOnItemClickedListener().onItemClicked( app, position );
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -21,20 +23,19 @@ import java.util.List;
|
||||
* <p>
|
||||
* </p>
|
||||
*/
|
||||
public abstract class RecycleBaseAdapter<T> extends
|
||||
RecyclerView.Adapter<RecycleViewHolder>
|
||||
{
|
||||
public abstract class RecycleBaseAdapter< T > extends
|
||||
RecyclerView.Adapter< RecycleViewHolder > {
|
||||
|
||||
protected Context context;
|
||||
protected List<T> list;
|
||||
protected List< T > list;
|
||||
private int resourceID;
|
||||
private Toast toast;
|
||||
|
||||
protected OnItemClickListener<T> mOnItemClickedListener;
|
||||
|
||||
/**
|
||||
* @param context
|
||||
*/
|
||||
public RecycleBaseAdapter(Context context, List<T> list, int resourceID)
|
||||
{
|
||||
public RecycleBaseAdapter( Context context, List< T > list, int resourceID ) {
|
||||
super();
|
||||
this.context = context;
|
||||
this.list = list;
|
||||
@@ -42,81 +43,75 @@ public abstract class RecycleBaseAdapter<T> extends
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecycleViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType)
|
||||
{
|
||||
View v = LayoutInflater.from(context).inflate(resourceID, viewGroup,
|
||||
false);
|
||||
public RecycleViewHolder onCreateViewHolder( ViewGroup viewGroup, int viewType ) {
|
||||
View v = LayoutInflater.from( context ).inflate( resourceID, viewGroup,
|
||||
false );
|
||||
|
||||
RecycleViewHolder holder = RecycleViewHolder
|
||||
.get(v);
|
||||
.get( v );
|
||||
|
||||
initHolder(holder);
|
||||
initHolder( holder );
|
||||
|
||||
return holder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(
|
||||
RecycleViewHolder viewHolder, int position)
|
||||
{
|
||||
onBindViewHolder(viewHolder, list.get(position % list.size()));
|
||||
public void onBindViewHolder( RecycleViewHolder viewHolder, int position ) {
|
||||
onBindViewHolder( viewHolder, list.get( position % list.size()), position );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount()
|
||||
{
|
||||
public int getItemCount() {
|
||||
return list == null ? 0 : list.size();
|
||||
}
|
||||
|
||||
public abstract void onBindViewHolder(
|
||||
RecycleViewHolder holder, T t);
|
||||
public abstract void onBindViewHolder( RecycleViewHolder holder, T t, int position );
|
||||
|
||||
public void initHolder(RecycleViewHolder holder)
|
||||
{
|
||||
public void initHolder( RecycleViewHolder holder ) {
|
||||
|
||||
}
|
||||
public void setDatas(List<T> list)
|
||||
{
|
||||
setDatas(list, false);
|
||||
|
||||
public void setDatas( List< T > list ) {
|
||||
setDatas( list, false );
|
||||
}
|
||||
|
||||
public void setDatas(List<T> list, boolean add)
|
||||
{
|
||||
if (add)
|
||||
{
|
||||
this.list.addAll(list);
|
||||
}
|
||||
else
|
||||
{
|
||||
public void setDatas( List< T > list, boolean add ) {
|
||||
if ( add ) {
|
||||
this.list.addAll( list );
|
||||
} else {
|
||||
this.list = list;
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
public void clear(){
|
||||
if (list != null) {
|
||||
|
||||
public void clear() {
|
||||
if ( list != null ) {
|
||||
list.clear();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
public void messageShow(String mes)
|
||||
{
|
||||
if (toast==null){
|
||||
toast= Toast.makeText(context,mes, Toast.LENGTH_LONG);
|
||||
}
|
||||
else{
|
||||
toast.setText(mes);
|
||||
}
|
||||
toast.show();
|
||||
}
|
||||
|
||||
public T getItem(int position){
|
||||
if (list==null||list.size()==0){
|
||||
public T getItem( int position ) {
|
||||
if ( list == null || list.size() == 0 ) {
|
||||
return null;
|
||||
}
|
||||
return list.get(position);
|
||||
return list.get( position );
|
||||
}
|
||||
|
||||
public List<T> getList() {
|
||||
public List< T > getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public interface OnItemClickListener< T > {
|
||||
void onItemClicked( T data, int position );
|
||||
}
|
||||
|
||||
public RecycleBaseAdapter< T > setOnItemClickedListener( OnItemClickListener< T > onItemClickedListener ) {
|
||||
this.mOnItemClickedListener = onItemClickedListener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public OnItemClickListener< T > getOnItemClickedListener() {
|
||||
return mOnItemClickedListener;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mogo.module.apps.applaunch;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.module.apps.AppServiceHandler;
|
||||
import com.mogo.module.apps.R;
|
||||
import com.mogo.module.apps.model.AppInfo;
|
||||
import com.mogo.module.apps.utils.LaunchUtils;
|
||||
@@ -21,6 +22,7 @@ public class AppLauncher extends BaseAppLauncher {
|
||||
@Override
|
||||
public void launch( Context context, AppInfo appInfo ) {
|
||||
try {
|
||||
AppServiceHandler.getApis().getAdasControllerApi().closeADAS();
|
||||
LaunchUtils.launchByPkg( context, appInfo.getPackageName() );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.mogo.module.apps.applaunch;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.module.apps.AppServiceHandler;
|
||||
import com.mogo.module.apps.AppsListActivity;
|
||||
import com.mogo.module.apps.model.AppInfo;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-05-14
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class InternalFunctionLauncher extends BaseAppLauncher {
|
||||
|
||||
private Activity mActivity;
|
||||
|
||||
public InternalFunctionLauncher( Activity activity ) {
|
||||
this.mActivity = activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launch( Context context, AppInfo appInfo ) {
|
||||
switch ( appInfo.getPackageName() ) {
|
||||
case "com.mogo.launcher.navi.search":
|
||||
AppServiceHandler.getApis().getSearchManagerApi().showSearch();
|
||||
break;
|
||||
case "com.mogo.launcher.applist":
|
||||
AppServiceHandler.getApis().getAdasControllerApi().closeADAS();
|
||||
AppsListActivity.start( mActivity );
|
||||
break;
|
||||
default:
|
||||
if ( getNext() != null ) {
|
||||
getNext().launch( context, appInfo );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if ( getNext() != null ) {
|
||||
getNext().destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,44 +15,18 @@ public class NavigatorApp {
|
||||
@DrawableRes
|
||||
public int mUncheckedIconId;
|
||||
public String mName;
|
||||
public String mModuleType;
|
||||
|
||||
public NavigatorApp( int mIconId,int mUncheckedIconId, String mName, String mModuleType ) {
|
||||
public NavigatorApp( int mIconId, int mUncheckedIconId, String mName ) {
|
||||
this.mIconId = mIconId;
|
||||
this.mUncheckedIconId = mUncheckedIconId;
|
||||
this.mName = mName;
|
||||
this.mModuleType = mModuleType;
|
||||
}
|
||||
|
||||
public int getmIconId() {
|
||||
public int getIconId() {
|
||||
return mIconId;
|
||||
}
|
||||
|
||||
public void setmIconId(int mIconId) {
|
||||
this.mIconId = mIconId;
|
||||
}
|
||||
|
||||
public int getmUncheckedIconId() {
|
||||
return mUncheckedIconId;
|
||||
}
|
||||
|
||||
public void setmUncheckedIconId(int mUncheckedIconId) {
|
||||
this.mUncheckedIconId = mUncheckedIconId;
|
||||
}
|
||||
|
||||
public String getmName() {
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
|
||||
public void setmName(String mName) {
|
||||
this.mName = mName;
|
||||
}
|
||||
|
||||
public String getmModuleType() {
|
||||
return mModuleType;
|
||||
}
|
||||
|
||||
public void setmModuleType(String mModuleType) {
|
||||
this.mModuleType = mModuleType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package com.mogo.module.apps.model;
|
||||
|
||||
import com.mogo.module.apps.R;
|
||||
import com.mogo.module.common.ModuleNames;
|
||||
import com.mogo.module.common.MogoModule;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -16,48 +13,15 @@ import java.util.List;
|
||||
*/
|
||||
public class NavigatorApps {
|
||||
|
||||
public static List< NavigatorApp > getApps() {
|
||||
List< NavigatorApp > apps = new ArrayList<>();
|
||||
apps.add( new NavigatorApp( R.drawable.module_apps_ic_online_car,R.drawable.module_apps_ic_online_car_unchecked, "在线车辆", ModuleNames.CARD_TYPE_USER_DATA ) );
|
||||
apps.add( new NavigatorApp( R.drawable.module_apps_ic_interest, R.drawable.module_apps_ic_interest_unchecked,"新鲜事", ModuleNames.CARD_TYPE_NOVELTY ) );
|
||||
apps.add( new NavigatorApp( R.drawable.module_apps_ic_news,R.drawable.module_apps_ic_news_unchecked, "首页", ModuleNames.CARD_TYPE_BUSINESS_OPERATION ) );
|
||||
apps.add( new NavigatorApp( R.drawable.module_apps_ic_media_center, R.drawable.module_apps_ic_media_center_checked, "媒体中心", ModuleNames.CARD_TYPE_SHARE_MUSIC ) );
|
||||
apps.add( new NavigatorApp( R.drawable.module_apps_ic_chat_icon, R.drawable.module_apps_ic_chat_unchecked,"车聊聊", ModuleNames.CARD_TYPE_CARS_CHATTING ) );
|
||||
apps.add( new NavigatorApp( R.drawable.module_apps_ic_tanlu, R.drawable.module_apps_ic_tanlu_unchecked,"探路", ModuleNames.CARD_TYPE_ROAD_CONDITION ) );
|
||||
return apps;
|
||||
}
|
||||
private static List< AppInfo > sApps = new ArrayList<>();
|
||||
|
||||
// public static List< NavigatorApp > getApps() {
|
||||
// List< NavigatorApp > apps = new ArrayList<>();
|
||||
// List< MogoModule > modules = MogoModulePaths.getModules();
|
||||
// for ( MogoModule module : modules ) {
|
||||
// NavigatorApp app = getApp( module );
|
||||
// if ( app == null ) {
|
||||
// continue;
|
||||
// }
|
||||
// apps.add( app );
|
||||
// }
|
||||
// return apps;
|
||||
// }
|
||||
//
|
||||
// private static NavigatorApp getApp( MogoModule module ) {
|
||||
// if ( module == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// switch ( module.getName() ) {
|
||||
// case ModuleNames.CARD_TYPE_USER_DATA:
|
||||
// return new NavigatorApp( R.drawable.module_apps_ic_online_car, R.drawable.module_apps_ic_online_car_unchecked, "在线车辆", ModuleNames.CARD_TYPE_USER_DATA );
|
||||
// case ModuleNames.CARD_TYPE_NOVELTY:
|
||||
// return new NavigatorApp( R.drawable.module_apps_ic_interest, R.drawable.module_apps_ic_interest_unchecked, "新鲜事", ModuleNames.CARD_TYPE_NOVELTY );
|
||||
// case ModuleNames.CARD_TYPE_BUSINESS_OPERATION:
|
||||
// return new NavigatorApp( R.drawable.module_apps_ic_news, R.drawable.module_apps_ic_news_unchecked, "首页", ModuleNames.CARD_TYPE_BUSINESS_OPERATION );
|
||||
// case ModuleNames.CARD_TYPE_SHARE_MUSIC:
|
||||
// return new NavigatorApp( R.drawable.module_apps_ic_media_center, R.drawable.module_apps_ic_media_center_checked, "媒体中心", ModuleNames.CARD_TYPE_SHARE_MUSIC );
|
||||
// case ModuleNames.CARD_TYPE_CARS_CHATTING:
|
||||
// return new NavigatorApp( R.drawable.module_apps_ic_chat_icon, R.drawable.module_apps_ic_chat_unchecked, "车聊聊", ModuleNames.CARD_TYPE_CARS_CHATTING );
|
||||
// case ModuleNames.CARD_TYPE_ROAD_CONDITION:
|
||||
// return new NavigatorApp( R.drawable.module_apps_ic_tanlu, R.drawable.module_apps_ic_tanlu_unchecked, "探路", ModuleNames.CARD_TYPE_ROAD_CONDITION );
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
public static List< AppInfo > getApps() {
|
||||
if ( sApps.isEmpty() ) {
|
||||
sApps.add( new AppInfo( "导航", "com.mogo.launcher.navi.search", "", 0, null, R.drawable.module_apps_ic_apps ) );
|
||||
sApps.add( new AppInfo( "音乐", "com.pvetec.musics", "", 0, null, R.drawable.module_apps_ic_apps ) );
|
||||
sApps.add( new AppInfo( "个人中心", "com.zhidao.auto.personal", "", 0, null, R.drawable.module_apps_ic_apps ) );
|
||||
sApps.add( new AppInfo( "全部应用", "com.mogo.launcher.applist", "", 0, null, R.drawable.module_apps_ic_apps ) );
|
||||
}
|
||||
return sApps;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
package com.mogo.module.apps.utils;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.FloatRange;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.mogo.module.apps.R;
|
||||
import com.mogo.module.apps.model.NavigatorApp;
|
||||
import com.yarolegovich.discretescrollview.transform.DiscreteScrollItemTransformer;
|
||||
import com.yarolegovich.discretescrollview.transform.Pivot;
|
||||
import com.yarolegovich.discretescrollview.transform.ScaleTransformer;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
* 2020-03-11.
|
||||
*/
|
||||
public class CardScaleTransformer implements DiscreteScrollItemTransformer {
|
||||
|
||||
private Pivot pivotX;
|
||||
private Pivot pivotY;
|
||||
private float minScale;
|
||||
private float maxMinDiff;
|
||||
private static final int CARD_SIZE = 6;
|
||||
|
||||
List<NavigatorApp> apps;
|
||||
|
||||
public CardScaleTransformer() {
|
||||
pivotX = Pivot.X.CENTER.create();
|
||||
pivotY = Pivot.Y.BOTTOM.create();
|
||||
minScale = 0.8f;
|
||||
maxMinDiff = 0.2f;
|
||||
}
|
||||
|
||||
public void setApps(List<NavigatorApp> apps) {
|
||||
this.apps = apps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transformItem(View item, RecyclerView.ViewHolder childViewHolder, float position) {
|
||||
|
||||
ImageView ivItem = item.findViewById(R.id.module_apps_id_app_icon);
|
||||
|
||||
TextView tvTitle = item.findViewById(R.id.module_apps_id_app_name);
|
||||
NavigatorApp tag = (NavigatorApp) item.getTag();
|
||||
|
||||
pivotX.setOn(ivItem);
|
||||
pivotY.setOn(ivItem);
|
||||
float closenessToCenter = 1f - Math.abs(position);
|
||||
float scale = minScale + maxMinDiff * closenessToCenter;
|
||||
ivItem.setScaleX(scale);
|
||||
ivItem.setScaleY(scale);
|
||||
|
||||
if (tag != null) {
|
||||
if (scale == 1) {
|
||||
ivItem.setImageResource(tag.getmIconId());
|
||||
tvTitle.setTextColor(ContextCompat.getColor(item.getContext(),R.color.white));
|
||||
} else {
|
||||
ivItem.setImageResource(tag.getmUncheckedIconId());
|
||||
tvTitle.setTextColor(ContextCompat.getColor(item.getContext(),R.color.white_80));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//int currentPosition = (position - 2) % CARD_SIZE;
|
||||
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private CardScaleTransformer transformer;
|
||||
private float maxScale;
|
||||
|
||||
public Builder() {
|
||||
transformer = new CardScaleTransformer();
|
||||
maxScale = 1f;
|
||||
}
|
||||
|
||||
public Builder setMinScale(@FloatRange(from = 0.01) float scale) {
|
||||
transformer.minScale = scale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setMaxScale(@FloatRange(from = 0.01) float scale) {
|
||||
maxScale = scale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setPivotX(Pivot.X pivotX) {
|
||||
return setPivotX(pivotX.create());
|
||||
}
|
||||
|
||||
public Builder setPivotX(Pivot pivot) {
|
||||
assertAxis(pivot, Pivot.AXIS_X);
|
||||
transformer.pivotX = pivot;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setPivotY(Pivot.Y pivotY) {
|
||||
return setPivotY(pivotY.create());
|
||||
}
|
||||
|
||||
public Builder setPivotY(Pivot pivot) {
|
||||
assertAxis(pivot, Pivot.AXIS_Y);
|
||||
transformer.pivotY = pivot;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CardScaleTransformer build() {
|
||||
transformer.maxMinDiff = maxScale - transformer.minScale;
|
||||
return transformer;
|
||||
}
|
||||
|
||||
private void assertAxis(Pivot pivot, @Pivot.Axis int axis) {
|
||||
if (pivot.getAxis() != axis) {
|
||||
throw new IllegalArgumentException("You passed a Pivot for wrong axis.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,46 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="bottom"
|
||||
android:paddingBottom="@dimen/module_apps_navigation_icon_paddingBottom"
|
||||
>
|
||||
android:paddingBottom="@dimen/module_apps_navigation_icon_paddingBottom">
|
||||
|
||||
<com.yarolegovich.discretescrollview.DiscreteScrollView
|
||||
android:id="@+id/module_apps_id_scroller"
|
||||
android:layout_width="@dimen/apps_id_scroller_width"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
android:layout_height="@dimen/module_apps_navigation_icon_container_height"
|
||||
>
|
||||
</com.yarolegovich.discretescrollview.DiscreteScrollView>
|
||||
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_apps_id_apps"
|
||||
android:layout_width="@dimen/module_apps_all_icon_width"
|
||||
android:layout_marginTop="@dimen/apps_margin_top"
|
||||
android:layout_height="@dimen/module_apps_all_icon_height"
|
||||
app:layout_constraintLeft_toRightOf="@id/module_apps_id_scroller"
|
||||
app:layout_constraintTop_toTopOf="@id/module_apps_id_scroller"
|
||||
android:layout_marginLeft="@dimen/module_apps_navigation_icon_marginLeft"
|
||||
android:src="@drawable/module_apps_ic_apps"
|
||||
/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:gravity="center"
|
||||
android:layout_marginLeft="@dimen/apps_margin_left"
|
||||
app:layout_constraintLeft_toRightOf="@id/module_apps_id_scroller"
|
||||
app:layout_constraintTop_toBottomOf="@id/module_apps_id_apps"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="全部应用"
|
||||
android:maxLines="1"
|
||||
android:layout_marginTop="@dimen/dp_24"
|
||||
android:textColor="@color/white_80"
|
||||
android:textSize="@dimen/dp_26"
|
||||
/>
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/module_apps_id_apps_list"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -2,23 +2,13 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="@dimen/dp_137"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="@dimen/dp_137"
|
||||
android:gravity="center|bottom"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_apps_id_app_icon"
|
||||
android:layout_width="@dimen/dp_112"
|
||||
android:scaleType="fitXY"
|
||||
android:layout_height="@dimen/dp_112" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_apps_id_app_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_24"
|
||||
android:gravity="center"
|
||||
android:maxLines="1"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="@dimen/dp_26" />
|
||||
android:layout_width="@dimen/module_apps_all_icon_width"
|
||||
android:layout_height="@dimen/module_apps_all_icon_height"
|
||||
android:scaleType="fitXY" />
|
||||
</LinearLayout>
|
||||
@@ -64,7 +64,9 @@ class MogoAuthorizeProvider : IMogoModuleProvider {
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
if (isDeviceOfD() && hasGuide() && mogoAuthShow.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_MAIN)) {
|
||||
//todo 引导判断暂时去掉 后续引导流程更改完再放开
|
||||
// todo if (isDeviceOfD() && hasGuide() && mogoAuthShow.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_MAIN)) {
|
||||
if (isDeviceOfD() && mogoAuthShow.needAuthorize(AUTHORIZE_TYPE_LAUNCHER_MAIN)) {
|
||||
mogoAuthShow.invokeAuthorizeForShow()
|
||||
} else {
|
||||
//首次进入Launcher同步一下授权状态,防止由于用户清除数据造成首次加载还会出现授权状态不同步问题
|
||||
|
||||
@@ -10,15 +10,12 @@ import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.alibaba.idst.nls.internal.utils.L;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||
@@ -104,7 +101,7 @@ public class BackToLauncherModuleProvider implements IMogoModuleProvider, IMogoI
|
||||
mServiceApis = ( IMogoServiceApis ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation();
|
||||
mIntentManager = mServiceApis.getIntentManagerApi();
|
||||
mIntentManager.registerIntentListener( COMMAND_BACK, this );
|
||||
BackToMainHomeManager.init( mServiceApis.getFragmentManagerApi(), mServiceApis.getStatusManagerApi() );
|
||||
BackToMainHomeManager.init( mServiceApis );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,6 +11,7 @@ import android.view.WindowManager;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.module.back.utils.WindowManagerViewHelper;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.utils.AppUtils;
|
||||
@@ -24,10 +25,12 @@ public class BackToMainHomeManager {
|
||||
|
||||
private static IMogoFragmentManager mFragmentManager;
|
||||
private static IMogoStatusManager mStatusManager;
|
||||
private static IMogoServiceApis mApis;
|
||||
|
||||
public static void init( IMogoFragmentManager manager, IMogoStatusManager statusManager ) {
|
||||
mFragmentManager = manager;
|
||||
mStatusManager = statusManager;
|
||||
public static void init( IMogoServiceApis apis ) {
|
||||
mApis = apis;
|
||||
mFragmentManager = apis.getFragmentManagerApi();
|
||||
mStatusManager = apis.getStatusManagerApi();
|
||||
}
|
||||
|
||||
public static void backToLauncher() {
|
||||
|
||||
@@ -202,7 +202,7 @@ public class ExtensionsPresenter extends Presenter< ExtensionsView > implements
|
||||
switch ( descriptor ) {
|
||||
case APP_LIST_UI:
|
||||
case SEARCH_UI:
|
||||
changeAutoSwitchVoiceTipsWordsStatus( !isTrue );
|
||||
// changeAutoSwitchVoiceTipsWordsStatus( !isTrue );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -210,13 +210,13 @@ public class ExtensionsPresenter extends Presenter< ExtensionsView > implements
|
||||
@Override
|
||||
public void onResume( @NonNull LifecycleOwner owner ) {
|
||||
super.onResume( owner );
|
||||
changeAutoSwitchVoiceTipsWordsStatus( true );
|
||||
// changeAutoSwitchVoiceTipsWordsStatus( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause( @NonNull LifecycleOwner owner ) {
|
||||
super.onPause( owner );
|
||||
changeAutoSwitchVoiceTipsWordsStatus( true );
|
||||
// changeAutoSwitchVoiceTipsWordsStatus( true );
|
||||
}
|
||||
|
||||
private void changeAutoSwitchVoiceTipsWordsStatus( boolean autoChange ) {
|
||||
|
||||
@@ -77,12 +77,6 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
|
||||
private static final String TAG = "EntranceFragment";
|
||||
|
||||
private View mSearch;
|
||||
|
||||
private View mCommonAddress;
|
||||
private View mHome;
|
||||
private View mCompany;
|
||||
|
||||
private View mUploadRoadCondition;
|
||||
private TextView mUpload;
|
||||
private ImageView mUploading;
|
||||
@@ -188,29 +182,6 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
|
||||
mStatusManager = mApis.getStatusManagerApi();
|
||||
|
||||
mCommonAddress = findViewById( R.id.module_entrance_id_common_address );
|
||||
|
||||
mSearch = findViewById( R.id.module_entrance_id_search );
|
||||
|
||||
mSearch.setOnClickListener( view -> {
|
||||
mApis.getAddressManagerApi().goSearch();
|
||||
mApis.getAdasControllerApi().closeADAS();
|
||||
} );
|
||||
|
||||
mHome = findViewById( R.id.module_entrance_id_home );
|
||||
mHome.setOnClickListener( view -> {
|
||||
mMogoAddressManager.goHome();
|
||||
mApis.getAdasControllerApi().closeADAS();
|
||||
|
||||
} );
|
||||
|
||||
mCompany = findViewById( R.id.module_entrance_id_company );
|
||||
mCompany.setOnClickListener( view -> {
|
||||
mMogoAddressManager.goCompany();
|
||||
mApis.getAdasControllerApi().closeADAS();
|
||||
|
||||
} );
|
||||
|
||||
mUploadRoadCondition = findViewById( R.id.module_entrance_id_upload_road_condition );
|
||||
mUpload = findViewById( R.id.module_entrance_id_upload );
|
||||
mUploading = findViewById( R.id.module_entrance_id_uploading );
|
||||
@@ -354,14 +325,6 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitNaviFailure() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitNaviSuccess() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviInfoUpdate( MogoNaviInfo naviinfo ) {
|
||||
if ( naviinfo == null ) {
|
||||
@@ -372,8 +335,6 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
|
||||
@Override
|
||||
public void onStartNavi() {
|
||||
mSearch.setVisibility( View.GONE );
|
||||
mCommonAddress.setVisibility( View.GONE );
|
||||
mNaviInfo.setVisibility( View.VISIBLE );
|
||||
mCameraMode.setVisibility( View.VISIBLE );
|
||||
mExitNavi.setVisibility( View.VISIBLE );
|
||||
@@ -386,8 +347,6 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
|
||||
@Override
|
||||
public void onStopNavi() {
|
||||
mSearch.setVisibility( View.VISIBLE );
|
||||
mCommonAddress.setVisibility( View.VISIBLE );
|
||||
mNaviInfo.setVisibility( View.GONE );
|
||||
mCameraMode.setVisibility( View.GONE );
|
||||
mExitNavi.setVisibility( View.GONE );
|
||||
@@ -396,18 +355,6 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
MapCenterPointStrategy.setMapCenterPointByScene( mMApUIController, Scene.AIMLESS );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCalculateSuccess() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onoCalculateFailed() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateTraffic( MogoTraffic traffic ) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateTraffic2( MogoTraffic traffic ) {
|
||||
if ( traffic == null ) {
|
||||
@@ -423,31 +370,6 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateCongestion( MogoCongestionInfo info ) {
|
||||
|
||||
}
|
||||
|
||||
@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;
|
||||
@@ -461,16 +383,6 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapModeChanged( EnumMapUI ui ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapChanged( MogoLatLng latLng, float zoom, float tilt, float bearing ) {
|
||||
|
||||
}
|
||||
|
||||
private void traceData( String from ) {
|
||||
Map< String, Object > properties = new HashMap<>();
|
||||
properties.put( "from", from );
|
||||
|
||||
@@ -5,73 +5,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_entrance_id_search"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/module_ext_search_height"
|
||||
android:layout_marginLeft="@dimen/module_ext_search_marginLeft"
|
||||
android:layout_marginTop="@dimen/module_ext_search_marginTop"
|
||||
android:background="@drawable/module_ext_dw_common_corner_bkg"
|
||||
android:drawableLeft="@drawable/module_map_ic_search"
|
||||
android:drawablePadding="@dimen/module_ext_search_drawablePadding"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="@dimen/module_ext_search_paddingLeft"
|
||||
android:paddingRight="@dimen/module_ext_search_paddingRight"
|
||||
android:text="@string/module_map_str_search_hint"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="@dimen/module_ext_search_textSize"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/module_entrance_id_common_address"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/module_ext_common_address_height"
|
||||
android:layout_marginLeft="@dimen/module_ext_common_address_marginLeft"
|
||||
android:layout_marginTop="@dimen/module_ext_common_address_marginTop"
|
||||
android:background="@drawable/module_ext_dw_common_corner_bkg"
|
||||
android:gravity="center_vertical"
|
||||
app:layout_constraintLeft_toRightOf="@+id/module_entrance_id_search"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/module_entrance_id_home"
|
||||
android:layout_width="@dimen/module_ext_common_address_home_width"
|
||||
android:layout_height="@dimen/module_ext_common_address_home_height"
|
||||
android:background="@drawable/module_ext_dw_left_corner_bkg">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:src="@drawable/module_map_ic_home" />
|
||||
|
||||
<View
|
||||
android:layout_width="@dimen/module_ext_common_address_divider_width"
|
||||
android:layout_height="@dimen/module_ext_common_address_divider_height"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:background="#1ED8D8D8" />
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/module_entrance_id_company"
|
||||
android:layout_width="@dimen/module_ext_common_address_company_width"
|
||||
android:layout_height="@dimen/module_ext_common_address_company_height"
|
||||
android:background="@drawable/module_ext_dw_right_corner_bkg"
|
||||
android:gravity="center">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/module_map_ic_company" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/module_entrance_id_speed_limit_container"
|
||||
android:layout_width="@dimen/module_ext_speed_limit_width"
|
||||
@@ -182,13 +115,14 @@
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/module_entrance_id_upload_road_condition"
|
||||
android:layout_width="@dimen/module_ext_operation_panel_share_width"
|
||||
android:layout_height="@dimen/module_ext_operation_panel_share_height"
|
||||
android:layout_marginBottom="@dimen/module_ext_operation_panel_share_marginBottom"
|
||||
app:layout_constraintBottom_toTopOf="@+id/module_entrance_id_operation_panel"
|
||||
app:layout_constraintRight_toRightOf="@+id/module_entrance_id_operation_panel"
|
||||
app:layout_goneMarginBottom="@dimen/module_ext_operation_panel_share_goneMarginBottom"
|
||||
app:layout_goneMarginRight="@dimen/module_ext_operation_panel_share_goneMarginRight"
|
||||
android:layout_width="@dimen/module_ext_operation_panel_share_width"
|
||||
android:layout_marginBottom="@dimen/module_ext_operation_panel_share_marginBottom"
|
||||
android:layout_height="@dimen/module_ext_operation_panel_share_height">
|
||||
app:layout_goneMarginRight="@dimen/module_ext_operation_panel_share_goneMarginRight">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_entrance_id_upload"
|
||||
android:layout_width="match_parent"
|
||||
@@ -198,16 +132,17 @@
|
||||
android:text="@string/module_map_str_upload_road_condition"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="@dimen/module_ext_operation_panel_share_textSize" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_entrance_id_uploading"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"
|
||||
android:background="@drawable/module_ext_dw_upload_road_condition_bkg"
|
||||
android:gravity="center"
|
||||
android:text="@string/module_map_str_upload_road_condition"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="@dimen/module_ext_operation_panel_share_textSize" />
|
||||
android:textSize="@dimen/module_ext_operation_panel_share_textSize"
|
||||
android:visibility="gone" />
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
android:id="@+id/module_ext_id_voice_msg_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toRightOf="@+id/module_ext_id_voice"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
@@ -24,17 +24,12 @@ import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.common.map.MapCenterPointStrategy;
|
||||
import com.mogo.module.common.map.Scene;
|
||||
import com.mogo.module.main.cards.CardIntroduceConfigs;
|
||||
import com.mogo.module.main.cards.CardModulesAdapter;
|
||||
import com.mogo.module.main.cards.HorizentalStackTransformer;
|
||||
import com.mogo.module.main.cards.MogoModulesHandler;
|
||||
import com.mogo.module.main.cards.MogoModulesManager;
|
||||
import com.mogo.module.main.cards.OnPageChangeListenerAdapter;
|
||||
import com.mogo.module.main.cards.OrientedViewPager;
|
||||
import com.mogo.module.main.windowview.FloatingViewHandler;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.cardmanager.IMogoCardManager;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
@@ -59,22 +54,14 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
private IMogoMapService mMogoMapService;
|
||||
private IMogoMapUIController mMogoMapUIController;
|
||||
private MogoModulesHandler mMogoModuleHandler;
|
||||
private IMogoCardManager mMogoCardManager;
|
||||
private IMogoFragmentManager mMogoFragmentManager;
|
||||
private IMogoStatusManager mMogoStatusManager;
|
||||
|
||||
private OrientedViewPager mCardsContainer;
|
||||
private HorizentalStackTransformer mTransformer;
|
||||
private CardModulesAdapter mCardModulesAdapter;
|
||||
|
||||
private View mHeader;
|
||||
private View mCards;
|
||||
private View mCardsBkg;
|
||||
private View mApps;
|
||||
private View mEntrance;
|
||||
private FrameLayout mFloatingLayout;
|
||||
private FrameLayout mCoverUpLayout;
|
||||
private FrameLayout mCardCoverUpBottomLayout;
|
||||
private View mLeftShadowFrame;
|
||||
private View mTopShadowFrame;
|
||||
|
||||
@@ -104,90 +91,13 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
|
||||
getWindow().setBackgroundDrawable( null );
|
||||
|
||||
mCardsContainer = findViewById( R.id.module_main_id_cards_container );
|
||||
mCardsContainer.setOrientation( OrientedViewPager.Orientation.HORIZONTAL );
|
||||
mTransformer = new HorizentalStackTransformer( this );
|
||||
mCardsContainer.setOnPageChangeListener( mOnPageChangeListener = new OnPageChangeListenerAdapter() {
|
||||
private boolean mIsLast = true;
|
||||
private boolean mCardFlipStatus = false;
|
||||
|
||||
@Override
|
||||
public void onPageSelected( int position ) {
|
||||
final long start = System.currentTimeMillis();
|
||||
try {
|
||||
IMogoModuleProvider provider = mCardModulesAdapter.getProvider( mCurrentPosition );
|
||||
if ( mCurrentPosition != position ) {
|
||||
mPresenter.postTrackLastCardShowEvent( provider );
|
||||
}
|
||||
mCurrentPosition = position;
|
||||
provider = mCardModulesAdapter.getProvider( mCurrentPosition );
|
||||
mMogoModuleHandler.setModuleEnable( provider.getModuleName() );
|
||||
mMogoCardManager.invoke( position, mMogoModuleHandler.getCurrentModuleName() );
|
||||
|
||||
if ( mLockCarStatus ) {
|
||||
mMogoStatusManager.setUserInteractionStatus( TAG, true, false );
|
||||
mMogoMapUIController.setLockZoom( 16 );
|
||||
mMogoMapUIController.recoverLockMode();
|
||||
}
|
||||
mLockCarStatus = true;
|
||||
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Logger.i( TAG, "onPageSelected cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged( int state ) {
|
||||
final long start = System.currentTimeMillis();
|
||||
super.onPageScrollStateChanged( state );
|
||||
if ( state == ViewPager.SCROLL_STATE_DRAGGING ) {
|
||||
if ( !mCardFlipStatus ) {
|
||||
mCardFlipStatus = true;
|
||||
final IMogoModuleProvider provider = mCardModulesAdapter.getProvider( mCurrentPosition );
|
||||
mPresenter.postTrackCardFlipEvent( provider );
|
||||
}
|
||||
} else if ( state == ViewPager.SCROLL_STATE_IDLE ) {
|
||||
mCardFlipStatus = false;
|
||||
mTransformer.resetOffsetScroll();
|
||||
}
|
||||
|
||||
int cardSize = mCardModulesAdapter.getCount();
|
||||
|
||||
if ( state == ViewPager.SCROLL_STATE_SETTLING ) {
|
||||
mIsLast = false;
|
||||
} else if ( state == ViewPager.SCROLL_STATE_IDLE && mIsLast ) {
|
||||
//此处为你需要的情况,再加入当前页码判断可知道是第一页还是最后一页
|
||||
if ( cardSize != 1 && mCurrentPosition == ( cardSize - 1 ) ) {
|
||||
mCardsContainer.setCurrentItem( 0, false );
|
||||
} else if ( cardSize != 1 && mCurrentPosition == 0 ) {
|
||||
mCardsContainer.setCurrentItem( cardSize - 1, false );
|
||||
}
|
||||
} else {
|
||||
mIsLast = true;
|
||||
}
|
||||
Logger.i( TAG, "onPageScrollStateChanged cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrolled( int position, float positionOffset,
|
||||
int positionOffsetPixels ) {
|
||||
super.onPageScrolled( position, positionOffset, positionOffsetPixels );
|
||||
Logger.d( TAG, "pageScrolled : offset --- " + positionOffset );
|
||||
mTransformer.offsetScrollChanged( positionOffset );
|
||||
}
|
||||
} );
|
||||
|
||||
mHeader = findViewById( R.id.module_main_id_header_fragment_container );
|
||||
mCards = findViewById( R.id.module_main_id_cards_container );
|
||||
mCardsBkg = findViewById( R.id.module_main_id_cards_bkg );
|
||||
mApps = findViewById( R.id.module_main_id_apps_fragment_container );
|
||||
mEntrance = findViewById( R.id.module_main_id_entrance_fragment_container );
|
||||
mFloatingLayout = findViewById( R.id.module_main_id_floating_view );
|
||||
mLeftShadowFrame = findViewById( R.id.module_main_id_map_left_shadow_frame );
|
||||
mTopShadowFrame = findViewById( R.id.module_main_id_map_top_shadow_frame );
|
||||
mCoverUpLayout = findViewById( R.id.module_main_id_cover_up );
|
||||
mCardCoverUpBottomLayout = findViewById( R.id.module_main_id_card_cover_up_bottom );
|
||||
|
||||
// 避免事件穿透导致地图被滑动
|
||||
mLeftShadowFrame.setOnClickListener( view -> {
|
||||
@@ -198,27 +108,21 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
// 隐藏布局
|
||||
private void hideLayout() {
|
||||
mHeader.setVisibility( View.GONE );
|
||||
mCards.setVisibility( View.GONE );
|
||||
mApps.setVisibility( View.GONE );
|
||||
mEntrance.setVisibility( View.GONE );
|
||||
mFloatingLayout.setVisibility( View.GONE );
|
||||
mLeftShadowFrame.setVisibility( View.GONE );
|
||||
mTopShadowFrame.setVisibility( View.GONE );
|
||||
mCardsBkg.setVisibility( View.GONE );
|
||||
mCardCoverUpBottomLayout.setVisibility( View.GONE );
|
||||
}
|
||||
|
||||
// 显示布局
|
||||
private void showLayout() {
|
||||
mHeader.setVisibility( View.VISIBLE );
|
||||
mCards.setVisibility( View.VISIBLE );
|
||||
mApps.setVisibility( View.VISIBLE );
|
||||
mEntrance.setVisibility( View.VISIBLE );
|
||||
mFloatingLayout.setVisibility( View.VISIBLE );
|
||||
mLeftShadowFrame.setVisibility( View.VISIBLE );
|
||||
mTopShadowFrame.setVisibility( View.VISIBLE );
|
||||
mCardsBkg.setVisibility( View.VISIBLE );
|
||||
mCardCoverUpBottomLayout.setVisibility( View.VISIBLE );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -257,6 +161,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
loadContainerModules();
|
||||
mMogoModuleHandler.loadModules();
|
||||
mPresenter.delayOperations();
|
||||
mPresenter.initADAS();
|
||||
hideCoverUpLayout();
|
||||
|
||||
// 显示左边遮罩
|
||||
@@ -272,8 +177,6 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
} );
|
||||
mMogoModuleHandler.loadMapModule( R.id.module_main_id_map_fragment_container );
|
||||
|
||||
mMogoCardManager = mServiceApis.getCardManagerApi();
|
||||
|
||||
mMogoFragmentManager = mServiceApis.getFragmentManagerApi();
|
||||
mMogoFragmentManager.init( this, R.id.module_main_id_search_fragment );
|
||||
mMogoFragmentManager.registerMainFragmentStackTransactionListener( ( size ) -> {
|
||||
@@ -299,29 +202,20 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
mMogoModuleHandler.loadEntrancesModule( R.id.module_main_id_entrance_fragment_container );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postPickFirstCardEvent() {
|
||||
if ( mOnPageChangeListener != null ) {
|
||||
// 默认触发第一个卡片
|
||||
mOnPageChangeListener.onPageSelected( 0 );
|
||||
}
|
||||
mCardCoverUpBottomLayout.setVisibility( View.VISIBLE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideCoverUpLayout() {
|
||||
mCoverUpLayout.setVisibility( View.GONE );
|
||||
mCardsBkg.setVisibility( View.VISIBLE );
|
||||
mServiceApis.getAdasControllerApi().showADAS();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCardModules() {
|
||||
|
||||
List< IMogoModuleProvider > providers = mMogoModuleHandler.loadCardsModule();
|
||||
mCardModulesAdapter = new CardModulesAdapter( this, providers );
|
||||
mCardsContainer.setOffscreenPageLimit( providers.size() );
|
||||
mCardsContainer.setPageTransformer( true, mTransformer );
|
||||
mCardsContainer.setAdapter( mCardModulesAdapter );
|
||||
// mCardModulesAdapter = new CardModulesAdapter( this, providers );
|
||||
// mCardsContainer.setOffscreenPageLimit( providers.size() );
|
||||
// mCardsContainer.setPageTransformer( true, mTransformer );
|
||||
// mCardsContainer.setAdapter( mCardModulesAdapter );
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -346,23 +240,15 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
|
||||
@Override
|
||||
public void switch2Card( String cardType, boolean lockCar ) {
|
||||
if ( mCardModulesAdapter == null ) {
|
||||
return;
|
||||
}
|
||||
mLockCarStatus = lockCar;
|
||||
int position = mCardModulesAdapter.getProviderPosition( cardType );
|
||||
if ( position != -1 ) {
|
||||
int lastFactPosition = mCardModulesAdapter.getFactPosition( mCurrentPosition );
|
||||
mCardsContainer.setCurrentItem( mCurrentPosition + position - lastFactPosition, Math.abs( lastFactPosition - position ) == 1 );
|
||||
} else {
|
||||
Logger.e( TAG, "Can't find type of %s's position", cardType );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mMogoStatusManager.setMainPageResumeStatus( TAG, true );
|
||||
if ( mCoverUpLayout.getVisibility() == View.VISIBLE ) {
|
||||
mServiceApis.getAdasControllerApi().showADAS();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -370,6 +256,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
super.onPause();
|
||||
mMogoStatusManager.setMainPageResumeStatus( TAG, false );
|
||||
CardIntroduceConfigs.flush( getApplicationContext() );
|
||||
mServiceApis.getAdasControllerApi().closeADAS();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -410,7 +297,6 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
mMogoModuleHandler = null;
|
||||
mMogoMapService = null;
|
||||
mMogoMapUIController = null;
|
||||
mMogoCardManager = null;
|
||||
mMogoFragmentManager = null;
|
||||
AIAssist.getInstance( this ).release();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.mogo.module.main;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
@@ -12,7 +11,6 @@ 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;
|
||||
@@ -33,8 +31,6 @@ public class MainPresenter extends Presenter< MainView > {
|
||||
// 埋点接口
|
||||
private IMogoAnalytics mAnalytics;
|
||||
|
||||
private long mCardStartShowTime = 0;
|
||||
|
||||
private Handler mMsgHandler = new Handler( Looper.getMainLooper() ) {
|
||||
@Override
|
||||
public void handleMessage( Message msg ) {
|
||||
@@ -42,16 +38,6 @@ public class MainPresenter extends Presenter< MainView > {
|
||||
switch ( msg.what ) {
|
||||
case MainConstants.MSG_LOAD_CARD_MODULES:
|
||||
mView.loadCardModules();
|
||||
mMsgHandler.sendEmptyMessageDelayed( MainConstants.MSG_LOAD_INVOKE_FIRST_CARD_PERFORM_EVENT, 1_000L );
|
||||
break;
|
||||
case MainConstants.MSG_LOAD_INVOKE_FIRST_CARD_PERFORM_EVENT:
|
||||
mView.postPickFirstCardEvent();
|
||||
break;
|
||||
case MainConstants.MSG_TRACK_LAST_CARD_DISPLAY_EVENT:
|
||||
trackLastCardShowEvent( ( IMogoModuleProvider ) msg.obj );
|
||||
break;
|
||||
case MainConstants.MSG_TRACK_CARD_FLIP_EVENT:
|
||||
trackCardFlipEvent( ( IMogoModuleProvider ) msg.obj );
|
||||
break;
|
||||
case MainConstants.MSG_HIDE_MAP_COVER_FRAME:
|
||||
mView.hideCoverUpLayout();
|
||||
@@ -65,7 +51,6 @@ public class MainPresenter extends Presenter< MainView > {
|
||||
|
||||
public MainPresenter( MainView view ) {
|
||||
super( view );
|
||||
mCardStartShowTime = System.currentTimeMillis();
|
||||
SchemeIntent.getInstance().init( getContext(), mView.getApis() );
|
||||
}
|
||||
|
||||
@@ -81,38 +66,6 @@ public class MainPresenter extends Presenter< MainView > {
|
||||
mAnalytics = ( IMogoAnalytics ) ARouter.getInstance().build( MogoServicePaths.PATH_UTILS_ANALYTICS ).navigation( getContext() );
|
||||
}
|
||||
|
||||
/**
|
||||
* 卡片展示时长埋点
|
||||
*
|
||||
* @param provider
|
||||
*/
|
||||
public void trackLastCardShowEvent( IMogoModuleProvider provider ) {
|
||||
if ( provider == null ) {
|
||||
return;
|
||||
}
|
||||
Map< String, Object > properties = new HashMap<>();
|
||||
properties.put( "appname", provider.getAppName() );
|
||||
properties.put( "packagename", provider.getAppPackage() );
|
||||
properties.put( "activeTime", System.currentTimeMillis() - mCardStartShowTime );
|
||||
properties.put( "type", provider.getModuleName() );
|
||||
mAnalytics.track( "Launcher_Card_Show", properties );
|
||||
mCardStartShowTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* 卡片滑动埋点,WTF
|
||||
*/
|
||||
public void trackCardFlipEvent( IMogoModuleProvider provider ) {
|
||||
if ( provider == null ) {
|
||||
return;
|
||||
}
|
||||
Map< String, Object > properties = new HashMap<>();
|
||||
properties.put( "appname", provider.getAppName() );
|
||||
properties.put( "packagename", provider.getAppPackage() );
|
||||
properties.put( "type", provider.getModuleName() );
|
||||
mAnalytics.track( "Launcher_Card_Slide", properties );
|
||||
}
|
||||
|
||||
/**
|
||||
* 延时操作
|
||||
*/
|
||||
@@ -121,20 +74,6 @@ public class MainPresenter extends Presenter< MainView > {
|
||||
mMsgHandler.sendEmptyMessageDelayed( MainConstants.MSG_HIDE_MAP_COVER_FRAME, 150L );
|
||||
}
|
||||
|
||||
public void postTrackLastCardShowEvent( IMogoModuleProvider provider ) {
|
||||
Message msg = Message.obtain();
|
||||
msg.what = MainConstants.MSG_TRACK_LAST_CARD_DISPLAY_EVENT;
|
||||
msg.obj = provider;
|
||||
mMsgHandler.sendMessage( msg );
|
||||
}
|
||||
|
||||
public void postTrackCardFlipEvent( IMogoModuleProvider provider ) {
|
||||
Message msg = Message.obtain();
|
||||
msg.what = MainConstants.MSG_TRACK_CARD_FLIP_EVENT;
|
||||
msg.obj = provider;
|
||||
mMsgHandler.sendMessage( msg );
|
||||
}
|
||||
|
||||
public void postLoadModuleMsg() {
|
||||
Message msg = Message.obtain();
|
||||
msg.what = MainConstants.MSG_LOAD_MODULES;
|
||||
@@ -144,4 +83,8 @@ public class MainPresenter extends Presenter< MainView > {
|
||||
public void handleSchemeIntent( Intent intent ) {
|
||||
SchemeIntent.getInstance().handle( intent );
|
||||
}
|
||||
|
||||
public void initADAS(){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,11 +23,6 @@ public interface MainView extends IView {
|
||||
*/
|
||||
void loadCardModules();
|
||||
|
||||
/**
|
||||
* 触发第一张卡片选中
|
||||
*/
|
||||
void postPickFirstCardEvent();
|
||||
|
||||
/**
|
||||
* 隐藏背景
|
||||
*/
|
||||
|
||||
@@ -1,21 +1,9 @@
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.navi.IMogoAimlessModeListener;
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener;
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.security.auth.callback.Callback;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-24
|
||||
@@ -64,22 +52,8 @@ public interface MogoModulesHandler {
|
||||
*/
|
||||
void loadEntrancesModule( int containerId );
|
||||
|
||||
/**
|
||||
* 设置某一个module可用
|
||||
*
|
||||
* @param module
|
||||
*/
|
||||
void setModuleEnable( String module );
|
||||
|
||||
/**
|
||||
* 销毁
|
||||
*/
|
||||
void destroy();
|
||||
|
||||
/**
|
||||
* 当前卡片名称
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getCurrentModuleName();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
@@ -11,24 +10,13 @@ import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.extensions.ExtensionsModuleConst;
|
||||
import com.mogo.module.main.EventDispatchCenter;
|
||||
import com.mogo.module.main.MainActivity;
|
||||
import com.mogo.module.main.registercenter.MogoRegisterCenterHandler;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
import com.mogo.service.module.ModuleType;
|
||||
import com.mogo.utils.ResourcesHelper;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
import com.mogo.utils.storage.SharedPrefsMgr;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -38,7 +26,7 @@ import java.util.Map;
|
||||
* <p>
|
||||
* 卡片加载
|
||||
*/
|
||||
public class MogoModulesManager implements MogoModulesHandler{
|
||||
public class MogoModulesManager implements MogoModulesHandler {
|
||||
|
||||
private static final String TAG = "MogoModulesManager";
|
||||
|
||||
@@ -48,17 +36,12 @@ public class MogoModulesManager implements MogoModulesHandler{
|
||||
// 空间换效率
|
||||
private Map< String, IMogoModuleProvider > mModuleNameProviders = new HashMap<>();
|
||||
|
||||
private String mEnableModuleName = null;
|
||||
|
||||
public static final String KEY_SORTED_CARD_MODULES = "sortedCards";
|
||||
private List< String > mSortedCards = new ArrayList<>();
|
||||
|
||||
public MogoModulesManager( MainActivity activity , IMogoServiceApis apis) {
|
||||
public MogoModulesManager( MainActivity activity, IMogoServiceApis apis ) {
|
||||
if ( activity == null ) {
|
||||
throw new NullPointerException( "activity can't be null." );
|
||||
}
|
||||
this.mActivity = activity;
|
||||
EventDispatchCenter.getInstance().registerReceiver(apis.getIntentManagerApi());
|
||||
EventDispatchCenter.getInstance().registerReceiver( apis.getIntentManagerApi() );
|
||||
CardIntroduceConfigs.init( getContext(), apis );
|
||||
}
|
||||
|
||||
@@ -88,61 +71,13 @@ public class MogoModulesManager implements MogoModulesHandler{
|
||||
@Override
|
||||
public List< IMogoModuleProvider > loadCardsModule() {
|
||||
|
||||
String sortedJson = SharedPrefsMgr.getInstance( getContext() ).getString( KEY_SORTED_CARD_MODULES );
|
||||
try {
|
||||
JSONArray array = new JSONArray( sortedJson );
|
||||
mSortedCards = new ArrayList<>( array.length() );
|
||||
for ( int i = 0; i < array.length(); i++ ) {
|
||||
mSortedCards.add( array.getString( i ) );
|
||||
}
|
||||
Logger.d( TAG, "Last cache card: %s", mSortedCards );
|
||||
} catch ( JSONException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
final List< MogoModule > modules = MogoModulePaths.getModules();
|
||||
final ArrayList< IMogoModuleProvider > providers = new ArrayList<>();
|
||||
for ( MogoModule module : modules ) {
|
||||
IMogoModuleProvider provider = mModuleProviders.get( module );
|
||||
if ( provider.getType() == ModuleType.TYPE_CARD_FRAGMENT ) {
|
||||
if ( mEnableModuleName == null ) {
|
||||
mEnableModuleName = provider.getModuleName();
|
||||
}
|
||||
providers.add( provider );
|
||||
}
|
||||
providers.add( provider );
|
||||
}
|
||||
return providers;
|
||||
// return sort( providers ); v2.0.2暂不支持变顺序
|
||||
}
|
||||
|
||||
private List< IMogoModuleProvider > sort( List< IMogoModuleProvider > modules ) {
|
||||
if ( modules == null || modules.size() == 0 ) {
|
||||
return modules;
|
||||
}
|
||||
if ( mSortedCards == null ) {
|
||||
mSortedCards = new ArrayList<>();
|
||||
}
|
||||
List< IMogoModuleProvider > sortedList = new ArrayList<>( modules.size() );
|
||||
|
||||
for ( String sortedCard : mSortedCards ) {
|
||||
for ( IMogoModuleProvider module : modules ) {
|
||||
if ( TextUtils.equals( module.getModuleName(), sortedCard ) ) {
|
||||
sortedList.add( module );
|
||||
Logger.d( TAG, "%s sorted.", sortedCard );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for ( IMogoModuleProvider module : modules ) {
|
||||
if ( !sortedList.contains( module ) ) {
|
||||
sortedList.add( module );
|
||||
}
|
||||
}
|
||||
mSortedCards.clear();
|
||||
for ( IMogoModuleProvider provider : sortedList ) {
|
||||
mSortedCards.add( provider.getModuleName() );
|
||||
}
|
||||
return sortedList;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -183,14 +118,12 @@ public class MogoModulesManager implements MogoModulesHandler{
|
||||
|
||||
private void addFragment( IMogoModuleProvider provider, int containerId ) {
|
||||
if ( provider == null ) {
|
||||
Logger.e( TAG, "add fragment fail cause provider == null, container is %s",
|
||||
ResourcesHelper.getResNameById( getApplicationContext(), containerId ) );
|
||||
Logger.e( TAG, "add fragment fail cause provider == null, container is %s", ResourcesHelper.getResNameById( getApplicationContext(), containerId ) );
|
||||
return;
|
||||
}
|
||||
final Fragment fragment = provider.createFragment( getContext(), null );
|
||||
if ( fragment == null ) {
|
||||
Logger.e( TAG, "add fragment fail cause fragment == null, container is %s",
|
||||
ResourcesHelper.getResNameById( getApplicationContext(), containerId ) );
|
||||
Logger.e( TAG, "add fragment fail cause fragment == null, container is %s", ResourcesHelper.getResNameById( getApplicationContext(), containerId ) );
|
||||
return;
|
||||
}
|
||||
mActivity.getSupportFragmentManager().beginTransaction()
|
||||
@@ -198,52 +131,6 @@ public class MogoModulesManager implements MogoModulesHandler{
|
||||
.commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setModuleEnable( String module ) {
|
||||
final long start1 = System.currentTimeMillis();
|
||||
// 仅操作上一个模块和当前模块
|
||||
Iterator< IMogoModuleProvider > iterator = mModuleProviders.values().iterator();
|
||||
int counter = 0;
|
||||
|
||||
// 上一个卡片设置为 disable
|
||||
IMogoModuleProvider prev = mModuleNameProviders.get( mEnableModuleName );
|
||||
if ( prev != null ) {
|
||||
final IMogoModuleLifecycle lifecycle = MogoRegisterCenterHandler.getInstance().getLifecycleListener( mEnableModuleName );
|
||||
if ( lifecycle != null ) {
|
||||
try {
|
||||
final long start = System.currentTimeMillis();
|
||||
lifecycle.onDisable();
|
||||
Logger.i( TAG, "set %s module disable event cost " + ( System.currentTimeMillis() - start ) + "ms", mEnableModuleName );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 当前卡片设置为 perform
|
||||
IMogoModuleProvider current = mModuleNameProviders.get( module );
|
||||
if ( current != null ) {
|
||||
final IMogoModuleLifecycle lifecycle = MogoRegisterCenterHandler.getInstance().getLifecycleListener( module );
|
||||
if ( lifecycle != null ) {
|
||||
try {
|
||||
final long start = System.currentTimeMillis();
|
||||
lifecycle.onPerform();
|
||||
Logger.i( TAG, "set %s module perform event cost " + ( System.currentTimeMillis() - start ) + "ms", module );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mEnableModuleName = module;
|
||||
mSortedCards.remove( mEnableModuleName );
|
||||
mSortedCards.add( 0, mEnableModuleName );
|
||||
SharedPrefsMgr.getInstance( getContext() ).putString( KEY_SORTED_CARD_MODULES, GsonUtil.jsonFromObject( mSortedCards ) );
|
||||
Logger.i( TAG, "enable & disable card cost " + ( System.currentTimeMillis() - start1 ) + "ms" );
|
||||
|
||||
CardIntroduceConfigs.broadcastCardIntroduce( mActivity, mEnableModuleName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
mActivity = null;
|
||||
@@ -251,11 +138,5 @@ public class MogoModulesManager implements MogoModulesHandler{
|
||||
mModuleProviders.clear();
|
||||
}
|
||||
mModuleProviders = null;
|
||||
mEnableModuleName = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrentModuleName() {
|
||||
return mEnableModuleName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,21 +13,6 @@ public class MainConstants {
|
||||
*/
|
||||
public static final int MSG_LOAD_CARD_MODULES = 5000;
|
||||
|
||||
/**
|
||||
* 消息:触发第一张卡片的onPerform 时间
|
||||
*/
|
||||
public static final int MSG_LOAD_INVOKE_FIRST_CARD_PERFORM_EVENT = 5001;
|
||||
|
||||
/**
|
||||
* 消息:卡片展示事件
|
||||
*/
|
||||
public static final int MSG_TRACK_LAST_CARD_DISPLAY_EVENT = 5002;
|
||||
|
||||
/**
|
||||
* 消息:卡片滑动事件
|
||||
*/
|
||||
public static final int MSG_TRACK_CARD_FLIP_EVENT = 5003;
|
||||
|
||||
/**
|
||||
* 消息:隐藏地图遮罩(避免地图加载白屏)
|
||||
*/
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 713 B |
Binary file not shown.
|
Before Width: | Height: | Size: 1.5 KiB |
@@ -37,40 +37,14 @@
|
||||
android:layout_marginLeft="@dimen/module_main_card_container_marginLeft"
|
||||
android:layout_marginTop="@dimen/module_main_card_container_marginTop">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_main_id_cards_bkg"
|
||||
android:layout_width="match_parent"
|
||||
android:visibility="invisible"
|
||||
android:src="@drawable/module_apps_bg_card"
|
||||
android:layout_height="@dimen/dp_797"/>
|
||||
<com.mogo.module.main.cards.OrientedViewPager
|
||||
android:id="@+id/module_main_id_cards_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_marginLeft="@dimen/dp_30"
|
||||
android:layout_marginRight="@dimen/dp_30"
|
||||
android:layout_height="@dimen/cards_container_dp_600"
|
||||
android:clipToPadding="false"
|
||||
android:overScrollMode="never" />
|
||||
|
||||
<!-- 应用入口-->
|
||||
<FrameLayout
|
||||
android:id="@+id/module_main_id_apps_fragment_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/module_main_id_card_cover_up_bottom"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_26"
|
||||
android:layout_marginTop="@dimen/cards_container_shadow_dp_margin_top"
|
||||
android:layout_marginLeft="@dimen/dp_64"
|
||||
android:layout_marginRight="@dimen/dp_64"
|
||||
android:visibility="invisible"
|
||||
android:background="@drawable/module_main_card_cover_up_bottom"
|
||||
/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<!--快捷操作浮层-->
|
||||
|
||||
@@ -20,11 +20,8 @@ import com.mogo.map.navi.IMogoNavi;
|
||||
import com.mogo.map.navi.IMogoNaviListener2;
|
||||
import com.mogo.map.navi.MogoNaviConfig;
|
||||
import com.mogo.map.navi.MogoNaviInfo;
|
||||
import com.mogo.map.navi.MogoTraffic;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.map.uicontroller.MapControlResult;
|
||||
import com.mogo.module.common.map.MapCenterPointStrategy;
|
||||
import com.mogo.module.common.map.Scene;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
@@ -242,7 +239,7 @@ public class MapPresenter extends Presenter< MapView > implements
|
||||
Logger.d( TAG, "未开始导航." );
|
||||
return;
|
||||
}
|
||||
if ( mStatusManager.isADASShow() ) {
|
||||
if ( mStatusManager.isV2XShow() ) {
|
||||
Logger.d( TAG, "ADAS模式忽略该请求." );
|
||||
return;
|
||||
}
|
||||
@@ -282,8 +279,8 @@ public class MapPresenter extends Presenter< MapView > implements
|
||||
mMogoMapService.getMapUIController().recoverLockMode();//缩放地图会导致锁车发生改变,这里强制锁车
|
||||
}, 1_000 );
|
||||
} else {
|
||||
// 20s后锁车刷新
|
||||
mRefreshStrategyController.restartAutoRefreshAtTime( 20_000 );
|
||||
// 30s后锁车刷新
|
||||
mRefreshStrategyController.restartAutoRefreshAtTime( 30_000 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -461,46 +458,6 @@ public class MapPresenter extends Presenter< MapView > implements
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCmdAction( String speakText ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCmdCancel( String speakText ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpeakEnd( String speakText ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpeakSelectTimeOut( String speakText ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArriveDestination() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEndEmulatorNavi() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitNaviFailure() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitNaviSuccess() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviInfoUpdate( MogoNaviInfo naviinfo ) {
|
||||
MapBroadCastHelper.getInstance( getContext() ).notifyXiaozhi( naviinfo );
|
||||
@@ -515,19 +472,4 @@ public class MapPresenter extends Presenter< MapView > implements
|
||||
public void onStopNavi() {
|
||||
MapBroadCastHelper.getInstance( getContext() ).stopNavi();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCalculateSuccess() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onoCalculateFailed() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateTraffic( MogoTraffic traffic ) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,4 +47,6 @@ public class AMapConstants {
|
||||
*/
|
||||
public static final String COMMAND_START_NAVI = "com.ileja.navi.route.confirm";
|
||||
|
||||
public static final String COMMAND_CHOOSE_PATH = "com.zhidao.route.choice";
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@ package com.mogo.module.navi.constants;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
* @since 2019-10-02
|
||||
@@ -42,4 +45,32 @@ public class DataConstants {
|
||||
public static final String COMPANY_ADDRESS_LATITUDE = "companyAddressLatitude";
|
||||
public static final String COMPANY_ADDRESS_LONGITUDE = "companyAddressLongitude";
|
||||
|
||||
// 泛化语义
|
||||
public static final String STRATEGY_THE_TIME_SHORTEST_PATH = "STRATEGY_THE_TIME_SHORTEST_PATH";
|
||||
public static final String[] WORDS_STRATEGY_THE_TIME_SHORTEST_PATH = {"最快的"};
|
||||
public static final String STRATEGY_THE_DISTANCE_SHORTEST_PATH = "STRATEGY_THE_DISTANCE_SHORTEST_PATH";
|
||||
public static final String[] WORDS_STRATEGY_THE_DISTANCE_SHORTED_PATH = {"路程最短的"};
|
||||
|
||||
// 第x个选个
|
||||
public static final String STRATEGY_THE_FIRST_PATH = "STRATEGY_THE_FIRST_PATH";
|
||||
public static final String[] WORDS_STRATEGY_THE_FIRST_PATH = {"第一个"};
|
||||
public static final String STRATEGY_THE_SECOND_PATH = "STRATEGY_THE_SECOND_PATH";
|
||||
public static final String[] WORDS_STRATEGY_THE_SECOND_PATH = {"第二个"};
|
||||
public static final String STRATEGY_THE_THIRD_PATH = "STRATEGY_THE_THIRD_PATH";
|
||||
public static final String[] WORDS_STRATEGY_THE_THIRD_PATH = {"第三个"};
|
||||
|
||||
// 开始导航
|
||||
public static final String STRATEGY_START_NAVI = "STRATEGY_START_NAVI";
|
||||
public static final String[] WORDS_STRATEGY_START_NAVI = {"开始导航", "开始"};
|
||||
|
||||
public static final Map< String, String[] > sCmds = new HashMap<>();
|
||||
|
||||
static {
|
||||
sCmds.put( STRATEGY_THE_TIME_SHORTEST_PATH, WORDS_STRATEGY_THE_TIME_SHORTEST_PATH );
|
||||
sCmds.put( STRATEGY_THE_DISTANCE_SHORTEST_PATH, WORDS_STRATEGY_THE_DISTANCE_SHORTED_PATH );
|
||||
sCmds.put( STRATEGY_THE_FIRST_PATH, WORDS_STRATEGY_THE_FIRST_PATH );
|
||||
sCmds.put( STRATEGY_THE_SECOND_PATH, WORDS_STRATEGY_THE_SECOND_PATH );
|
||||
sCmds.put( STRATEGY_THE_THIRD_PATH, WORDS_STRATEGY_THE_THIRD_PATH );
|
||||
sCmds.put( STRATEGY_START_NAVI, WORDS_STRATEGY_START_NAVI );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.mogo.module.gps.simulator.GpsSimulatorConstants
|
||||
import com.mogo.module.gps.simulator.IMogoGpsSimulatorManager
|
||||
import com.mogo.module.guideshow.provider.GuideShowProviderConstant
|
||||
import com.mogo.module.guideshow.provider.IGuideShowProvider
|
||||
import com.mogo.service.IMogoServiceApis
|
||||
import com.mogo.service.MogoServicePaths
|
||||
import com.mogo.service.analytics.IMogoAnalytics
|
||||
import com.mogo.service.fragmentmanager.FragmentDescriptor
|
||||
@@ -42,7 +43,7 @@ object SearchServiceHolder {
|
||||
val mogoLauncher: IMogoLauncher = ARouter.getInstance().build(MogoServicePaths.PATH_LAUNCHER_API).navigation() as IMogoLauncher
|
||||
val gpsSimulator = ARouter.getInstance().build(GpsSimulatorConstants.API_PATH).navigation() as IMogoGpsSimulatorManager
|
||||
val intentManager = ARouter.getInstance().build(MogoServicePaths.PATH_INTENT_MANAGER).navigation() as IMogoIntentManager
|
||||
|
||||
val apis = ARouter.getInstance().navigation(IMogoServiceApis::class.java)
|
||||
var geoSearch: IMogoGeoSearch? = null
|
||||
fun init(context: Context) {
|
||||
this.context = context
|
||||
|
||||
@@ -122,6 +122,7 @@ object AddressManager {
|
||||
* 回家
|
||||
*/
|
||||
fun goHome() {
|
||||
closeADAS()
|
||||
SearchServiceHolder.statusManager.setSearchUIShow(TAG, true)
|
||||
if (homeAddress == null) {
|
||||
choosePoint(DataConstants.TYPE_HOME_ADDRESS)
|
||||
@@ -134,6 +135,7 @@ object AddressManager {
|
||||
* 去公司
|
||||
*/
|
||||
fun goCompany() {
|
||||
closeADAS()
|
||||
SearchServiceHolder.statusManager.setSearchUIShow(TAG, true)
|
||||
if (companyAddress == null) {
|
||||
choosePoint( DataConstants.TYPE_COMPANY_ADDRESS)
|
||||
@@ -146,6 +148,7 @@ object AddressManager {
|
||||
* 搜索
|
||||
*/
|
||||
fun goSearch() {
|
||||
closeADAS()
|
||||
SearchServiceHolder.statusManager.setSearchUIShow(TAG, true)
|
||||
SearchServiceHolder.fragmentManager.push(
|
||||
FragmentDescriptor.Builder().fragment(SearchFragment())
|
||||
@@ -160,12 +163,14 @@ object AddressManager {
|
||||
*/
|
||||
fun calculatePath(destination: MogoLatLng?) {
|
||||
destination?.let {
|
||||
closeADAS()
|
||||
var newInstance = ChoosePathFragment.newInstance(destination)
|
||||
SearchServiceHolder.push(newInstance, AMapConstants.PATH_FRAGMENT_CHOOSE_PATH)
|
||||
}
|
||||
}
|
||||
|
||||
fun categorySearch(category: String){
|
||||
closeADAS()
|
||||
val searchFragment = CategorySearchFragment.newInstance(category)
|
||||
SearchServiceHolder.fragmentManager.push(FragmentDescriptor.Builder().fragment(searchFragment)
|
||||
.tag(AMapConstants.PATH_FRAGMENT_SEARCH_CATEGORY)
|
||||
@@ -174,6 +179,7 @@ object AddressManager {
|
||||
}
|
||||
|
||||
fun goSettings(){
|
||||
closeADAS()
|
||||
val naviSettingFragment = NaviSettingFragment()
|
||||
SearchServiceHolder.fragmentManager.push(FragmentDescriptor.Builder().fragment(naviSettingFragment)
|
||||
.tag(AMapConstants.PATH_FRAGMENT_NAVI_SETTING)
|
||||
@@ -181,4 +187,13 @@ object AddressManager {
|
||||
.build())
|
||||
}
|
||||
|
||||
|
||||
private fun closeADAS() {
|
||||
try {
|
||||
SearchServiceHolder.apis.adasControllerApi.closeADAS()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.module.navi.manager;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.module.navi.constants.SearchServiceHolder;
|
||||
@@ -14,11 +15,13 @@ import com.mogo.service.module.IMogoAddressManager;
|
||||
@Route( path = MogoServicePaths.PATH_ADDRESS_MANAGER )
|
||||
public class MogoAddressManager implements IMogoAddressManager {
|
||||
|
||||
@Override public void goHome() {
|
||||
@Override
|
||||
public void goHome() {
|
||||
AddressManager.INSTANCE.goHome();
|
||||
}
|
||||
|
||||
@Override public void goCompany() {
|
||||
@Override
|
||||
public void goCompany() {
|
||||
AddressManager.INSTANCE.goCompany();
|
||||
}
|
||||
|
||||
@@ -42,9 +45,10 @@ public class MogoAddressManager implements IMogoAddressManager {
|
||||
AddressManager.INSTANCE.goSettings();
|
||||
}
|
||||
|
||||
@Override public void init( Context context) {
|
||||
AddressManager.INSTANCE.init(context);
|
||||
SearchServiceHolder.INSTANCE.init(context);
|
||||
SettingManager.INSTANCE.init(context);
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
AddressManager.INSTANCE.init( context );
|
||||
SearchServiceHolder.INSTANCE.init( context );
|
||||
SettingManager.INSTANCE.init( context );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import com.mogo.map.navi.MogoCalculatePath;
|
||||
import com.mogo.map.search.inputtips.MogoTip;
|
||||
import com.mogo.module.navi.R;
|
||||
import com.mogo.module.navi.ui.adapter.base.RecycleBaseAdapter;
|
||||
import com.mogo.module.navi.ui.adapter.base.RecycleViewHolder;
|
||||
@@ -53,8 +52,8 @@ public class CalculatePathAdapter extends RecycleBaseAdapter<MogoCalculatePath>
|
||||
if (holder.getLayoutPosition() >= 2) {
|
||||
mName.setVisibility(View.GONE);
|
||||
}
|
||||
holder.setText(R.id.amap_calculate_item_strategy_time, item.getTime());
|
||||
holder.setText(R.id.amap_calculate_item_strategy_distance, item.getDistance());
|
||||
holder.setText(R.id.amap_calculate_item_strategy_time, item.getFormattedTime());
|
||||
holder.setText(R.id.amap_calculate_item_strategy_distance, item.getFormattedDistance());
|
||||
holder.setText(R.id.amap_calculate_item_strategy_desc, item.getDesc());
|
||||
|
||||
if (TextUtils.isEmpty(item.getDesc())) {
|
||||
|
||||
@@ -11,25 +11,26 @@ import com.mogo.commons.voice.IMogoVoiceCmdCallBack
|
||||
import com.mogo.map.MogoLatLng
|
||||
import com.mogo.map.navi.IMogoNaviListener
|
||||
import com.mogo.map.navi.MogoCalculatePath
|
||||
import com.mogo.map.navi.MogoNaviInfo
|
||||
import com.mogo.map.navi.MogoTraffic
|
||||
import com.mogo.module.common.MogoModulePaths
|
||||
import com.mogo.map.navi.MogoNaviConfig
|
||||
import com.mogo.module.common.map.MapCenterPointStrategy
|
||||
import com.mogo.module.common.map.Scene
|
||||
import com.mogo.module.navi.R
|
||||
import com.mogo.module.navi.constants.AMapConstants
|
||||
import com.mogo.module.navi.constants.DataConstants
|
||||
import com.mogo.module.navi.constants.SearchServiceHolder
|
||||
import com.mogo.module.navi.manager.SettingManager
|
||||
import com.mogo.module.navi.ui.adapter.CalculatePathAdapter
|
||||
import com.mogo.module.navi.ui.base.BaseFragment
|
||||
import com.mogo.service.intent.IMogoIntentListener
|
||||
import com.mogo.utils.UiThreadHandler
|
||||
import com.mogo.utils.logger.Logger
|
||||
import kotlinx.android.synthetic.main.fragment_search_category.group_path
|
||||
import kotlinx.android.synthetic.main.fragment_search_category.pb_path
|
||||
import kotlinx.android.synthetic.main.fragment_search_category.rv_search_result
|
||||
import kotlinx.android.synthetic.main.fragment_search_category.tv_navi_navi
|
||||
import kotlinx.android.synthetic.main.include_search_bar.et_navi_search
|
||||
import kotlinx.android.synthetic.main.include_search_bar.iv_navi_back
|
||||
import org.json.JSONObject
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
@@ -37,24 +38,34 @@ import kotlinx.android.synthetic.main.include_search_bar.iv_navi_back
|
||||
*/
|
||||
class ChoosePathFragment : BaseFragment(), IMogoNaviListener, IMogoVoiceCmdCallBack, IMogoIntentListener {
|
||||
|
||||
private var mTimeShortestPosition = -1
|
||||
private var mDistanceShortestPosition = -1
|
||||
|
||||
override fun onCmdSelected(cmd: String?) {
|
||||
when (cmd) {
|
||||
"firstPath" -> {
|
||||
DataConstants.STRATEGY_THE_FIRST_PATH -> {
|
||||
selectItem(0)
|
||||
startNavi()
|
||||
|
||||
}
|
||||
"secondPath" -> {
|
||||
DataConstants.STRATEGY_THE_SECOND_PATH -> {
|
||||
selectItem(1)
|
||||
startNavi()
|
||||
|
||||
}
|
||||
"thirdPath" -> {
|
||||
DataConstants.STRATEGY_THE_THIRD_PATH -> {
|
||||
selectItem(2)
|
||||
startNavi()
|
||||
|
||||
}
|
||||
"startNavi" -> {
|
||||
DataConstants.STRATEGY_START_NAVI -> {
|
||||
startNavi()
|
||||
}
|
||||
DataConstants.STRATEGY_THE_DISTANCE_SHORTEST_PATH -> {
|
||||
// 路程最短
|
||||
selectItem(mDistanceShortestPosition)
|
||||
startNavi()
|
||||
}
|
||||
DataConstants.STRATEGY_THE_TIME_SHORTEST_PATH -> {
|
||||
// 时间最短
|
||||
selectItem(mTimeShortestPosition)
|
||||
startNavi()
|
||||
}
|
||||
"retry" -> {
|
||||
@@ -63,45 +74,15 @@ class ChoosePathFragment : BaseFragment(), IMogoNaviListener, IMogoVoiceCmdCallB
|
||||
"cancel" -> {
|
||||
SearchServiceHolder.fragmentManager.clearAll()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun selectItem(index: Int) {
|
||||
|
||||
if (mAdapter.list.size > index) {
|
||||
if (mAdapter.list.size > index && index > 0) {
|
||||
selectPath(mAdapter.list[index])
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCmdAction(speakText: String?) {
|
||||
}
|
||||
|
||||
override fun onCmdCancel(speakText: String?) {
|
||||
}
|
||||
|
||||
override fun onSpeakEnd(speakText: String?) {
|
||||
}
|
||||
|
||||
override fun onSpeakSelectTimeOut(speakText: String?) {
|
||||
}
|
||||
|
||||
override fun onInitNaviFailure() {
|
||||
}
|
||||
|
||||
override fun onInitNaviSuccess() {
|
||||
}
|
||||
|
||||
override fun onNaviInfoUpdate(naviinfo: MogoNaviInfo?) {
|
||||
}
|
||||
|
||||
override fun onStartNavi() {
|
||||
}
|
||||
|
||||
override fun onStopNavi() {
|
||||
}
|
||||
|
||||
override fun onCalculateSuccess() {
|
||||
var calculatedStrategies = SearchServiceHolder.getNavi().calculatedStrategies
|
||||
if (calculatedStrategies != null && calculatedStrategies.size > 0) {
|
||||
@@ -115,9 +96,33 @@ class ChoosePathFragment : BaseFragment(), IMogoNaviListener, IMogoVoiceCmdCallB
|
||||
return@postDelayed
|
||||
}
|
||||
SearchServiceHolder.getNavi().itemClickInteraction.onItemClicked(calculatedStrategies[0].tagId)
|
||||
|
||||
if (calculatedStrategies.size == 1) {
|
||||
// 一条路线,自动开启导航
|
||||
startNavi()
|
||||
}
|
||||
}, 500L)
|
||||
|
||||
if (calculatedStrategies.size > 1) {
|
||||
|
||||
var timeShortest = Integer.MAX_VALUE
|
||||
var distanceShortest = Integer.MAX_VALUE
|
||||
|
||||
for (i in 0 until calculatedStrategies.size) {
|
||||
if (timeShortest > calculatedStrategies[i].time) {
|
||||
timeShortest = calculatedStrategies[i].time
|
||||
mTimeShortestPosition = i
|
||||
}
|
||||
if (distanceShortest > calculatedStrategies[i].distance) {
|
||||
distanceShortest = calculatedStrategies[i].distance
|
||||
mDistanceShortestPosition = i
|
||||
}
|
||||
}
|
||||
|
||||
Logger.d(TAG, "mTimeShortestPosition = ${mTimeShortestPosition}, mDistanceShortestPosition = $mDistanceShortestPosition")
|
||||
AIAssist.getInstance(context).speakTTSVoice(String.format("已为你规划处%d条路线,请选择", calculatedStrategies.size))
|
||||
}
|
||||
}
|
||||
AIAssist.getInstance(context).speakTTSVoice(String.format("已为你规划处%d条路线,请选择", calculatedStrategies.size))
|
||||
pb_path.visibility = View.GONE
|
||||
group_path.visibility = View.GONE
|
||||
tv_navi_navi.text = getString(R.string.start_navi)
|
||||
@@ -132,10 +137,6 @@ class ChoosePathFragment : BaseFragment(), IMogoNaviListener, IMogoVoiceCmdCallB
|
||||
pb_path.visibility = View.GONE
|
||||
|
||||
registerRetryVoice()
|
||||
|
||||
}
|
||||
|
||||
override fun onUpdateTraffic(traffic: MogoTraffic?) {
|
||||
}
|
||||
|
||||
private lateinit var mAdapter: CalculatePathAdapter
|
||||
@@ -143,24 +144,16 @@ class ChoosePathFragment : BaseFragment(), IMogoNaviListener, IMogoVoiceCmdCallB
|
||||
return R.layout.fragment_search_category
|
||||
}
|
||||
|
||||
val firstPath: String = "第一个"
|
||||
val secondPath: String = "第二个"
|
||||
val thirdPath: String = "第三个"
|
||||
val startNavi: String = "开始导航"
|
||||
|
||||
var mogoTip: MogoLatLng? = null
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
mogoTip = arguments?.getParcelable<MogoLatLng>(AMapConstants.KEY_PARCELABLE)
|
||||
|
||||
}
|
||||
|
||||
// 是否开启导航
|
||||
var isStartedNavi = false
|
||||
|
||||
override fun onViewCreated(
|
||||
view: View,
|
||||
savedInstanceState: Bundle?) {
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
iv_navi_back.setOnClickListener {
|
||||
@@ -199,13 +192,14 @@ class ChoosePathFragment : BaseFragment(), IMogoNaviListener, IMogoVoiceCmdCallB
|
||||
|
||||
SearchServiceHolder.getMarkerManger().removeMarkers()
|
||||
|
||||
AIAssist.getInstance(context).registerUnWakeupCommand("firstPath", arrayOf<String>(firstPath), this)
|
||||
AIAssist.getInstance(context).registerUnWakeupCommand("secondPath", arrayOf<String>(secondPath), this)
|
||||
AIAssist.getInstance(context).registerUnWakeupCommand("thirdPath", arrayOf<String>(thirdPath), this)
|
||||
AIAssist.getInstance(context).registerUnWakeupCommand("startNavi", arrayOf<String>(startNavi, "开始"), this)
|
||||
DataConstants.sCmds.entries.filter {
|
||||
it != null && !TextUtils.isEmpty(it.key) && (it.value?.isNotEmpty() ?: false)
|
||||
}.forEach {
|
||||
AIAssist.getInstance(mContext).registerUnWakeupCommand(it.key, it.value, this@ChoosePathFragment)
|
||||
}
|
||||
|
||||
SearchServiceHolder.intentManager.registerIntentListener(AMapConstants.COMMAND_START_NAVI, this)
|
||||
|
||||
SearchServiceHolder.intentManager.registerIntentListener(AMapConstants.COMMAND_CHOOSE_PATH, this)
|
||||
}
|
||||
|
||||
private fun registerRetryVoice() {
|
||||
@@ -214,7 +208,6 @@ class ChoosePathFragment : BaseFragment(), IMogoNaviListener, IMogoVoiceCmdCallB
|
||||
|
||||
private fun unregisterRetryVoice() {
|
||||
AIAssist.getInstance(context).unregisterUnWakeupCommand("retry")
|
||||
|
||||
}
|
||||
|
||||
private fun retry() {
|
||||
@@ -227,7 +220,6 @@ class ChoosePathFragment : BaseFragment(), IMogoNaviListener, IMogoVoiceCmdCallB
|
||||
if (TextUtils.isEmpty(mAdapter.selectTag)) {
|
||||
return
|
||||
}
|
||||
// moveMapToRight()
|
||||
|
||||
SearchServiceHolder.getNavi().startNavi(!SettingManager.isMonitor())
|
||||
SearchServiceHolder.getMapUIController().recoverLockMode()
|
||||
@@ -253,21 +245,54 @@ class ChoosePathFragment : BaseFragment(), IMogoNaviListener, IMogoVoiceCmdCallB
|
||||
SearchServiceHolder.getNavi().clearCalculatePaths()
|
||||
}
|
||||
|
||||
AIAssist.getInstance(context).unregisterUnWakeupCommand("firstPath")
|
||||
AIAssist.getInstance(context).unregisterUnWakeupCommand("secondPath")
|
||||
AIAssist.getInstance(context).unregisterUnWakeupCommand("thirdPath")
|
||||
AIAssist.getInstance(context).unregisterUnWakeupCommand("startNavi")
|
||||
DataConstants.sCmds.entries.filter {
|
||||
it != null && !TextUtils.isEmpty(it.key) && (it.value?.isNotEmpty() ?: false)
|
||||
}.forEach {
|
||||
AIAssist.getInstance(mContext).unregisterUnWakeupCommand(it.key)
|
||||
}
|
||||
|
||||
SearchServiceHolder.intentManager.unregisterIntentListener(AMapConstants.COMMAND_START_NAVI, this)
|
||||
SearchServiceHolder.intentManager.unregisterIntentListener(AMapConstants.COMMAND_CHOOSE_PATH, this)
|
||||
}
|
||||
|
||||
override fun onIntentReceived(intentStr: String?, intent: Intent?) {
|
||||
if (TextUtils.equals(AMapConstants.COMMAND_START_NAVI, intentStr)) {
|
||||
startNavi()
|
||||
when (intentStr) {
|
||||
AMapConstants.COMMAND_START_NAVI -> {
|
||||
startNavi()
|
||||
}
|
||||
AMapConstants.COMMAND_CHOOSE_PATH -> {
|
||||
choosePath(intent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun choosePath(intent: Intent?) {
|
||||
var dataJsonStr = intent?.getStringExtra("data") ?: ""
|
||||
try {
|
||||
var jsonObj = JSONObject(dataJsonStr)
|
||||
var routePlan = jsonObj.optString("route_choice", " ")
|
||||
when (routePlan) {
|
||||
"fastest" -> {
|
||||
// 时间最短
|
||||
selectItem(mTimeShortestPosition)
|
||||
startNavi()
|
||||
}
|
||||
"nearest" -> {
|
||||
// 路程最短
|
||||
selectItem(mDistanceShortestPosition)
|
||||
startNavi()
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@JvmField
|
||||
val TAG: String = "ChoosePathFragment"
|
||||
|
||||
fun newInstance(searchPoi: MogoLatLng): Fragment {
|
||||
MapCenterPointStrategy.setMapCenterPointByScene(SearchServiceHolder.getMapUIController(), Scene.CALCULATE_PATH)
|
||||
var bundle = Bundle()
|
||||
|
||||
@@ -172,7 +172,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
super.handleMessage( msg );
|
||||
switch ( msg.what ) {
|
||||
case ServiceConst.MSG_TYPE_REFRESH_DECREASE:
|
||||
if ( mStatusManager.isSearchUIShow() || mStatusManager.isADASShow() ) {
|
||||
if ( mStatusManager.isSearchUIShow() || mStatusManager.isV2XShow() ) {
|
||||
stopAutoRefreshStrategy();
|
||||
return;
|
||||
}
|
||||
@@ -185,7 +185,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
}
|
||||
break;
|
||||
case ServiceConst.MSG_LOOP_REQUEST:
|
||||
if ( mStatusManager.isSearchUIShow() || mStatusManager.isADASShow() ) {
|
||||
if ( mStatusManager.isSearchUIShow() || mStatusManager.isV2XShow() ) {
|
||||
return;
|
||||
}
|
||||
if ( mLoopRequest ) {
|
||||
@@ -200,7 +200,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
* 自动刷新:锁车、缩放比例:16、半径 2KM
|
||||
*/
|
||||
private void invokeAutoRefresh() {
|
||||
if ( mStatusManager.isSearchUIShow() || mStatusManager.isADASShow() ) {
|
||||
if ( mStatusManager.isSearchUIShow() || mStatusManager.isV2XShow() ) {
|
||||
mStatusManager.setUserInteractionStatus( TAG, true, false );
|
||||
mUiController.recoverLockMode();
|
||||
return;
|
||||
@@ -230,7 +230,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
*/
|
||||
private RefreshCallback mCustomRefreshCallback = new RefreshCallback() {
|
||||
@Override
|
||||
public void onSuccess(Object o) {
|
||||
public void onSuccess( Object o ) {
|
||||
mLoopRequest = false;
|
||||
// 用户手动操作地图刷新成功后,设置状态为 true,引发延时策略
|
||||
mStatusManager.setUserInteractionStatus( ServiceConst.TYPE, true, true );
|
||||
@@ -248,7 +248,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
*/
|
||||
private RefreshCallback mAutoRefreshCallback = new RefreshCallback() {
|
||||
@Override
|
||||
public void onSuccess(Object o) {
|
||||
public void onSuccess( Object o ) {
|
||||
mLoopRequest = false;
|
||||
Logger.d( TAG, "request Success." );
|
||||
invokeAutoRefreshStrategy();
|
||||
@@ -348,11 +348,11 @@ public class MogoServices implements IMogoMapListener,
|
||||
if ( msg.obj instanceof RefreshObject ) {
|
||||
RefreshObject ro = ( ( RefreshObject ) msg.obj );
|
||||
mRefreshModel.refreshData( ro.mLonLat, ro.mRadius, ro.mAmount, ro.mCallback );
|
||||
MapMarkerManager.getInstance().getOnlineCarData(ro.mLonLat);
|
||||
MapMarkerManager.getInstance().getOnlineCarData( ro.mLonLat );
|
||||
|
||||
Logger.i( TAG, "刷新半径 = %s, 点 = %s, zoomLevel = %s, amount = %s", ro.mRadius, ro.mLonLat, mLastZoomLevel, ro.mAmount );
|
||||
}
|
||||
} else if( msg.what == ServiceConst.MSG_LOCK_CAR ){
|
||||
} else if ( msg.what == ServiceConst.MSG_LOCK_CAR ) {
|
||||
if ( mStatusManager.isSearchUIShow() ) {
|
||||
return;
|
||||
}
|
||||
@@ -436,8 +436,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
*/
|
||||
private float getMapCameraFactHeight() {
|
||||
try {
|
||||
return Utils.calculateLineDistance( mCameraSouthWestPosition,
|
||||
new MogoLatLng( mCameraNorthEastPosition.lat, mCameraSouthWestPosition.lng ) );
|
||||
return Utils.calculateLineDistance( mCameraSouthWestPosition, new MogoLatLng( mCameraNorthEastPosition.lat, mCameraSouthWestPosition.lng ) );
|
||||
} catch ( Exception e ) {
|
||||
return ServiceConst.DEFAULT_AUTO_REFRESH_DATA_RADIUS;
|
||||
}
|
||||
@@ -468,16 +467,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
mHandler.removeMessages( ServiceConst.MSG_TYPE_REFRESH_DECREASE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPOIClick( MogoPoi poi ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapClick( MogoLatLng latLng ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLockMap( boolean isLock ) {
|
||||
mThreadHandler.removeMessages( ServiceConst.MSG_LOCK_CAR );
|
||||
@@ -486,15 +475,10 @@ public class MogoServices implements IMogoMapListener,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapModeChanged( EnumMapUI ui ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapChanged( MogoLatLng latLng, float zoom, float tilt, float bearing ) {
|
||||
|
||||
MapMarkerManager.getInstance().syncLocation( latLng.lon, latLng. lat );
|
||||
MapMarkerManager.getInstance().syncLocation( latLng.lon, latLng.lat );
|
||||
|
||||
if ( mIsCameraInited ) {
|
||||
mLastZoomLevel = zoom;
|
||||
@@ -513,7 +497,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
}
|
||||
|
||||
// v2x // adas 状态下不做任何操作
|
||||
if ( mStatusManager.isADASShow() ) {
|
||||
if ( mStatusManager.isV2XShow() ) {
|
||||
mLastCustomRefreshCenterLocation = latLng;
|
||||
mLastZoomLevel = zoom;
|
||||
return;
|
||||
@@ -585,7 +569,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
|
||||
@Override
|
||||
public void onCarLocationChanged2( Location latLng ) {
|
||||
if ( mStatusManager.isADASShow() ) {
|
||||
if ( mStatusManager.isV2XShow() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -637,28 +621,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
mThreadHandler.sendMessage( msg );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitNaviFailure() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitNaviSuccess() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviInfoUpdate( MogoNaviInfo naviinfo ) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartNavi() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopNavi() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged( StatusDescriptor descriptor, boolean isTrue ) {
|
||||
//Logger.d( TAG, "状态发生改变---descriptor---" + descriptor + "----isTrue---" + isTrue );
|
||||
@@ -675,7 +637,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
} else {
|
||||
// 搜索后,打开打点策略
|
||||
if ( mAutoRefreshCallback != null ) {
|
||||
mAutoRefreshCallback.onSuccess(null);
|
||||
mAutoRefreshCallback.onSuccess( null );
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -730,7 +692,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
refreshStrategy();
|
||||
// ADAS关闭后,打开打点策略
|
||||
if ( mAutoRefreshCallback != null ) {
|
||||
mAutoRefreshCallback.onSuccess(null);
|
||||
mAutoRefreshCallback.onSuccess( null );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -756,21 +718,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
notifyRefreshData( mLastAutoRefreshLocation, getQueryRadius(), mAutoRefreshCallback );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCalculateSuccess() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onoCalculateFailed() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateTraffic( MogoTraffic traffic ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateTraffic2( MogoTraffic traffic ) {
|
||||
|
||||
@@ -816,9 +763,9 @@ public class MogoServices implements IMogoMapListener,
|
||||
mStatusManager.setVoiceUIShow( TAG, true );
|
||||
}
|
||||
} else if ( ServiceConst.COMMAND_NEXT.equals( command ) ) {
|
||||
onActionDown( MogoAction.Next );
|
||||
onActionDone( MogoAction.Next );
|
||||
} else if ( ServiceConst.COMMAND_PREVIOUS.equals( command ) ) {
|
||||
onActionDown( MogoAction.Prev );
|
||||
onActionDone( MogoAction.Prev );
|
||||
} else if ( ServiceConst.COMMAND_SWITCH_CARD.equals( command ) ) {
|
||||
IntentHandlerFactory.getInstance().handle( mContext, command, intent );
|
||||
} else if ( MogoReceiver.ACTION_ADAS_STATUS.equals( command ) ) {
|
||||
@@ -909,9 +856,9 @@ public class MogoServices implements IMogoMapListener,
|
||||
@Override
|
||||
public void onCmdSelected( String cmd ) {
|
||||
if ( TextUtils.equals( ServiceConst.CMD_UN_WAKE_PREV, cmd ) ) {
|
||||
onActionDown( MogoAction.Prev );
|
||||
onActionDone( MogoAction.Prev );
|
||||
} else if ( TextUtils.equals( ServiceConst.CMD_UN_WAKE_NEXT, cmd ) ) {
|
||||
onActionDown( MogoAction.Next );
|
||||
onActionDone( MogoAction.Next );
|
||||
} else if ( TextUtils.equals( ServiceConst.CMD_UN_WAKEUP_MY_LOCATION, cmd ) ) {
|
||||
if ( mStatusManager.isMainPageOnResume() ) {
|
||||
mUiController.recoverLockMode();
|
||||
@@ -921,11 +868,11 @@ public class MogoServices implements IMogoMapListener,
|
||||
}
|
||||
}
|
||||
|
||||
private void onActionDown(MogoAction action){
|
||||
private void onActionDone( MogoAction action ) {
|
||||
if ( !mStatusManager.isMainPageOnResume() ) {
|
||||
return;
|
||||
}
|
||||
if ( mStatusManager.isADASShow() ) {
|
||||
if ( mStatusManager.isV2XShow() ) {
|
||||
// 分发到V2X
|
||||
mActionManager.invoke( "V2X_UI", action );
|
||||
} else {
|
||||
@@ -934,26 +881,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCmdAction( String speakText ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCmdCancel( String speakText ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpeakEnd( String speakText ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpeakSelectTimeOut( String speakText ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransaction( int size ) {
|
||||
if ( size == 0 ) {
|
||||
@@ -968,6 +895,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
MapCenterPointStrategy.setMapCenterPointByScene( mUiController, Scene.AIMLESS );
|
||||
}
|
||||
mUiController.recoverLockMode();
|
||||
mADASController.showADAS();
|
||||
} else {
|
||||
mUiController.showMyLocation( false );
|
||||
AIAssist.getInstance( mContext ).registerUnWakeupCommand( ServiceConst.CMD_BACK, ServiceConst.CMD_BACK_WORDS, this );
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.mogo.module.service.marker;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.animation.BounceInterpolator;
|
||||
import android.view.animation.OvershootInterpolator;
|
||||
|
||||
@@ -104,8 +105,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
|
||||
// 长连接
|
||||
MarkerServiceHandler.getMogoSocketManager().registerOnMessageListener( 401001, this );
|
||||
MarkerServiceHandler.getMogoCardManager().registerCardChangedListener(
|
||||
"LAUNCHER_MARKER_MODULE", this );
|
||||
MarkerServiceHandler.getMogoCardManager().registerCardChangedListener( TAG, this );
|
||||
MarkerServiceHandler.getActionManager().registerBizActionDoneListener( this );
|
||||
}
|
||||
|
||||
@@ -257,20 +257,6 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭 Marker 详情
|
||||
*
|
||||
* @param marker 要关闭的Marker
|
||||
*/
|
||||
public synchronized void closeMarkerSelect( IMogoMarker marker ) {
|
||||
// 将上次选中 Marker 设置为未选中状态
|
||||
if ( marker != null ) {
|
||||
Logger.i( TAG, "closeMarkerSelect 将出Marker详情关闭:" + marker );
|
||||
closeMarker( marker );
|
||||
mLastCheckMarker = null;
|
||||
}
|
||||
}
|
||||
|
||||
// 展开气泡
|
||||
private void openMarker( IMogoMarker mogoMarker ) {
|
||||
if ( mogoMarker == null ) {
|
||||
@@ -282,6 +268,8 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
if ( !mogoMarker.isDestroyed() ) {
|
||||
mogoMarker.setInfoWindowAdapter( UserDataMarkerInfoWindowAdapter.getInstance( mContext ) );
|
||||
mogoMarker.showInfoWindow();
|
||||
MarkerServiceHandler.getMogoStatusManager().setUserInteractionStatus( TAG, true, false );
|
||||
MarkerServiceHandler.getMapUIController().moveToCenter( mogoMarker.getPosition() );
|
||||
Logger.d( TAG, "打开info window" );
|
||||
}
|
||||
} else {
|
||||
@@ -358,7 +346,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
} else {
|
||||
mLastCheckMarker = null;
|
||||
// 清空所有地图上绘制的Marker
|
||||
MarkerServiceHandler.getMarkerManager().removeMarkers();
|
||||
MarkerServiceHandler.getMarkerManager().removeMarkersExcept( ModuleNames.CARD_TYPE_USER_DATA );
|
||||
}
|
||||
|
||||
drawMarkerByCurrentType( mLastDataResult );
|
||||
@@ -402,29 +390,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
mCurrentModuleName = ServiceConst.CARD_TYPE_BUSINESS_OPERATION;
|
||||
}
|
||||
|
||||
List< MarkerOnlineCar > onlineCarList = markerCardResult.getOnlineCar();
|
||||
List< MarkerExploreWay > exploreWayList = markerCardResult.getExploreWay();
|
||||
List< MarkerShareMusic > shareMusicList = markerCardResult.getShareMusic();
|
||||
List< MarkerNoveltyInfo > noveltyInfoList = markerCardResult.getNoveltyInfo();
|
||||
|
||||
switch ( mCurrentModuleName ) {
|
||||
case ServiceConst.CARD_TYPE_BUSINESS_OPERATION:
|
||||
drawAllMarker( markerCardResult );
|
||||
break;
|
||||
case ServiceConst.CARD_TYPE_NOVELTY:
|
||||
drawNoveltyMarker( noveltyInfoList, ServiceConst.MAX_AMOUNT_SINGLE_CARD );
|
||||
break;
|
||||
// case ServiceConst.CARD_TYPE_CARS_CHATTING:
|
||||
// case ServiceConst.CARD_TYPE_USER_DATA:
|
||||
// drawOnlineCarMarkers(onlineCarList, ServiceConst.MAX_AMOUNT_SINGLE_CARD);
|
||||
// break;
|
||||
case ServiceConst.CARD_TYPE_ROAD_CONDITION:
|
||||
drawRoadConditionMarker( exploreWayList, ServiceConst.MAX_AMOUNT_SINGLE_CARD );
|
||||
break;
|
||||
case ServiceConst.CARD_TYPE_SHARE_MUSIC:
|
||||
drawShareMusicMarker( shareMusicList, ServiceConst.MAX_AMOUNT_SINGLE_CARD );
|
||||
break;
|
||||
}
|
||||
drawAllMarker( markerCardResult );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -457,6 +423,9 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
|
||||
double nearlyDistance = Float.MAX_VALUE;
|
||||
int size = getAppropriateSize( maxAmount, onlineCarList );
|
||||
|
||||
Map< String, IMogoMarker > existCarMap = purgeCarsData( onlineCarList );
|
||||
|
||||
for ( int i = 0; i < size; i++ ) {
|
||||
MarkerOnlineCar markerOnlineCar = onlineCarList.get( i );
|
||||
MarkerLocation markerLocation = markerOnlineCar.getLocation();
|
||||
@@ -470,9 +439,15 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
markerShowEntity.setIconUrl( markerOnlineCar.getUserInfo().getUserHead() );
|
||||
}
|
||||
|
||||
IMogoMarker iMogoMarker = drawMapMarker( markerShowEntity );
|
||||
// iMogoMarker.setInfoWindowAdapter(this);
|
||||
startSmooth( iMogoMarker, markerOnlineCar, markerLocation );
|
||||
if ( markerOnlineCar.getUserInfo() == null || TextUtils.isEmpty( markerOnlineCar.getUserInfo().getSn() ) ) {
|
||||
continue;
|
||||
}
|
||||
IMogoMarker mogoMarker = existCarMap.get( markerOnlineCar.getUserInfo().getSn() );
|
||||
if ( mogoMarker == null ) {
|
||||
Logger.d( TAG, "car [%s] need be create.", markerOnlineCar.getUserInfo().getSn() );
|
||||
mogoMarker = drawMapMarker( markerShowEntity );
|
||||
}
|
||||
startSmooth( mogoMarker, markerOnlineCar, markerLocation );
|
||||
|
||||
// 计算在线车辆距离当前车辆的距离,每次都与最后一次距离最近的进行比较,保留距离最近的车辆,进行卡片展示
|
||||
try {
|
||||
@@ -489,7 +464,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
// 进行比较,保留最近的一个数据
|
||||
if ( calculateDistance < nearlyDistance ) {
|
||||
nearlyDistance = calculateDistance;
|
||||
mNearlyMarker = iMogoMarker;
|
||||
mNearlyMarker = mogoMarker;
|
||||
}
|
||||
|
||||
} catch ( Exception e ) {
|
||||
@@ -519,6 +494,66 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据新的在线车辆列表,选出已存在的在线车辆,并从视图和内存中移除不存在的在线车辆
|
||||
*
|
||||
* @param newCarsList
|
||||
* @return
|
||||
*/
|
||||
private Map< String, IMogoMarker > purgeCarsData( List< MarkerOnlineCar > newCarsList ) {
|
||||
|
||||
final long start = System.currentTimeMillis();
|
||||
Map< String, IMogoMarker > existCarsMap = new HashMap<>();
|
||||
List< IMogoMarker > allCarsList = MarkerServiceHandler.getMarkerManager().getMarkers( ModuleNames.CARD_TYPE_USER_DATA );
|
||||
if ( allCarsList == null || allCarsList.isEmpty() ) {
|
||||
return existCarsMap;
|
||||
}
|
||||
if ( newCarsList == null || newCarsList.isEmpty() ) {
|
||||
return existCarsMap;
|
||||
}
|
||||
|
||||
Map< String, IMogoMarker > allCarsMap = new HashMap<>();
|
||||
for ( IMogoMarker marker : allCarsList ) {
|
||||
String sn = getCarSnFromMarker( marker );
|
||||
Logger.d( TAG, "sn = [%s]", sn );
|
||||
allCarsMap.put( sn, marker );
|
||||
}
|
||||
for ( MarkerOnlineCar markerOnlineCar : newCarsList ) {
|
||||
String sn = markerOnlineCar.getUserInfo().getSn();
|
||||
if ( allCarsMap.containsKey( sn ) ) {
|
||||
Logger.d( TAG, " car [%s] is cached.", sn );
|
||||
existCarsMap.put( sn, allCarsMap.get( sn ) );
|
||||
}
|
||||
}
|
||||
for ( String sn : allCarsMap.keySet() ) {
|
||||
if ( !existCarsMap.containsKey( sn ) ) {
|
||||
IMogoMarker dirtyMarker = allCarsMap.get( sn );
|
||||
allCarsList.remove( dirtyMarker );
|
||||
dirtyMarker.destroy();
|
||||
Logger.d( TAG, " car [%s] is destroy.", sn );
|
||||
}
|
||||
}
|
||||
allCarsMap.clear();
|
||||
Logger.i( "timer", "purge data cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
return existCarsMap;
|
||||
}
|
||||
|
||||
private String getCarSnFromMarker( IMogoMarker marker ) {
|
||||
if ( marker == null || marker.getObject() == null || marker.isDestroyed() ) {
|
||||
return null;
|
||||
}
|
||||
if ( !( marker.getObject() instanceof MarkerShowEntity ) ) {
|
||||
return null;
|
||||
}
|
||||
if ( !( ( ( MarkerShowEntity ) marker.getObject() ).getBindObj() instanceof MarkerOnlineCar ) ) {
|
||||
return null;
|
||||
}
|
||||
if ( ( ( MarkerOnlineCar ) ( ( MarkerShowEntity ) marker.getObject() ).getBindObj() ).getUserInfo() == null ) {
|
||||
return null;
|
||||
}
|
||||
return ( ( MarkerOnlineCar ) ( ( MarkerShowEntity ) marker.getObject() ).getBindObj() ).getUserInfo().getSn();
|
||||
}
|
||||
|
||||
/**
|
||||
* 探路数据
|
||||
*
|
||||
@@ -869,7 +904,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
if ( result == null ) {
|
||||
return;
|
||||
}
|
||||
removeCarMarkers();
|
||||
|
||||
List< MarkerOnlineCar > onlineCarList = result.getOnlineCar();
|
||||
if ( !MarkerServiceHandler.getMogoStatusManager().isADASShow() ) {
|
||||
dispatchDataToBis( ServiceConst.CARD_TYPE_USER_DATA, onlineCarList == null ? new ArrayList<>() : onlineCarList );
|
||||
|
||||
@@ -71,6 +71,7 @@ public class MogoReceiver extends BroadcastReceiver {
|
||||
if (TextUtils.equals(VOICE_ACTION, action)) {
|
||||
String cmd = intent.getStringExtra(PARAM_COMMAND);
|
||||
if (!TextUtils.isEmpty(cmd)) {
|
||||
Logger.d( TAG, "receive command: %s", cmd );
|
||||
mMogoIntentManager.invoke(cmd, intent);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -13,12 +13,12 @@ public class AutoRefreshStrategy {
|
||||
/**
|
||||
* 距离(米)
|
||||
*/
|
||||
private int distance = 2_000;
|
||||
private int distance = 1_000;
|
||||
|
||||
/**
|
||||
* 时间间距(s)
|
||||
*/
|
||||
private long interval = 3 * ONE_MINUTE;
|
||||
private long interval = 3 * ONE_MINUTE / 6;
|
||||
|
||||
/**
|
||||
* 用户打断后的延时(s)【2.0.2后不再延时】
|
||||
|
||||
Reference in New Issue
Block a user