This commit is contained in:
wangcongtao
2020-03-26 19:22:39 +08:00
parent d77b63e6fa
commit bb1de8acac
12 changed files with 150 additions and 26 deletions

View File

@@ -83,6 +83,7 @@ public class AMapNaviViewWrapper implements IMogoMapView,
// 自定义定位源的回调信息,前瞻线
private LocationSource.OnLocationChangedListener mOnLocationChangedListener;
private boolean mIsCarLockced = false;
public AMapNaviViewWrapper( AMapNaviView mapView ) {
this.mMapView = mapView;
@@ -334,6 +335,7 @@ public class AMapNaviViewWrapper implements IMogoMapView,
@Override
public void onLockMap( boolean isLock ) {
Logger.d( TAG, "lock status = %s", isLock );
mIsCarLockced = isLock;
Trace.beginSection( "timer.onCameraChangeFinish" );
MogoMapListenerHandler.getInstance().onLockMap( isLock );
Trace.endSection();
@@ -799,4 +801,9 @@ public class AMapNaviViewWrapper implements IMogoMapView,
mOnLocationChangedListener.onLocationChanged( location );
}
}
@Override
public synchronized boolean isCarLocked() {
return mIsCarLockced;
}
}

View File

@@ -53,9 +53,10 @@ public class BnHooker implements InvocationHandler {
@Override
public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable {
if ( method.getName().equals( "setRenderFps" ) ) {
Logger.d( TAG, "setRenderFps" );
if ( !NaviClient.getInstance( mContext ).isNaviing() ) {
return method.invoke( host, 10 );
}
return method.invoke( host, 10 );
}
if ( method.getName().equals( "drawFrame" ) ) {
Logger.d( TAG, "drawFrame" );

View File

@@ -241,4 +241,12 @@ public class AMapUIController implements IMogoMapUIController {
mClient.changeMyLocation( location );
}
}
@Override
public boolean isCarLocked() {
if ( mClient != null ) {
return mClient.isCarLocked();
}
return false;
}
}

View File

@@ -180,4 +180,10 @@ public interface IMogoMapUIController {
* @return
*/
EnumMapUI getCurrentUiMode();
/**
* 锁车状态
* @return
*/
boolean isCarLocked();
}

View File

@@ -234,4 +234,12 @@ public class MogoMapUIController implements IMogoMapUIController {
mDelegate.changeMyLocation( location );
}
}
@Override
public boolean isCarLocked() {
if ( mDelegate != null ) {
return mDelegate.isCarLocked();
}
return false;
}
}

View File

@@ -58,7 +58,7 @@ public class AppNavigatorFragment extends MvpFragment<AppNavigatorView, AppNavig
private IMogoAnalytics mMogoAnalytics;
private DiscreteScrollView scroller;
private static final int CARD_SIZE = 6;
private static int CARD_SIZE = 6;
private AppIndicatorAdapter appIndicatorAdapter;
@Override
@@ -84,6 +84,7 @@ public class AppNavigatorFragment extends MvpFragment<AppNavigatorView, AppNavig
scroller.addScrollStateChangeListener(this);
//scroller.setItemTransitionTimeMillis(DiscreteScrollViewOptions.getTransitionTime());
apps = NavigatorApps.getApps();
CARD_SIZE = apps.size();
scroller.setItemTransformer(new CardScaleTransformer.Builder()
.setMinScale(0.84f)
.build());

View File

@@ -2,6 +2,8 @@ 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;
@@ -14,13 +16,6 @@ import java.util.List;
*/
public class NavigatorApps {
//integers.add(R.drawable.module_apps_ic_online_car);
//integers.add(R.drawable.module_apps_ic_interest);
//integers.add(R.drawable.module_apps_ic_news);
//integers.add(R.drawable.module_apps_ic_media_center);
//integers.add(R.drawable.module_apps_ic_chat_icon);
//integers.add(R.drawable.module_apps_ic_tanlu);
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 ) );
@@ -31,4 +26,38 @@ public class NavigatorApps {
apps.add( new NavigatorApp( R.drawable.module_apps_ic_tanlu, R.drawable.module_apps_ic_tanlu_unchecked,"探路", ModuleNames.CARD_TYPE_ROAD_CONDITION ) );
return apps;
}
// 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;
// }
}

View File

@@ -0,0 +1,64 @@
package com.mogo.module.common.utils;
import java.lang.reflect.Method;
/**
* @author congtaowang
* @since 2020-03-26
* <p>
* 车机类型
*/
public class CarSeries {
public static final int CAR_SERIES_C80X = 10;
public static final int CAR_SERIES_D80X = 20;
public static final int CAR_SERIES_D81X = 21;
public static final int CAR_SERIES_D82X = 22;
public static final int CAR_SERIES_D84X = 23;
public static final int CAR_SERIES_F80X = 30;
public static final int CAR_SERIES_G80X = 40;
public static int CAR_SERIES = 0;
public static int getSeries() {
if ( CAR_SERIES != 0 ) {
return CAR_SERIES;
}
synchronized ( CarSeries.class ) {
if ( CAR_SERIES != 0 ) {
return CAR_SERIES;
}
String device = get( "ro.fota.device" );
if ( "FG166".equals( device ) ) {
CAR_SERIES = CAR_SERIES_C80X;
} else if ( "D801-802".equals( device ) ) {
CAR_SERIES = CAR_SERIES_D80X;
} else if ( "D811-812".equals( device ) ) {
CAR_SERIES = CAR_SERIES_D81X;
} else if ( "D821-822".equals( device ) ) {
CAR_SERIES = CAR_SERIES_D82X;
} else if ( "D841-842".equals( device ) ) {
CAR_SERIES = CAR_SERIES_D84X;
} else if ( "G801-802".equals( device ) ) {
CAR_SERIES = CAR_SERIES_G80X;
} else if ( "F801-802".equals( device ) ) {
CAR_SERIES = CAR_SERIES_F80X;
} else {
CAR_SERIES = CAR_SERIES_F80X;
}
return CAR_SERIES;
}
}
private static String get( String key ) {
String value = "";
try {
Class< ? > c = Class.forName( "android.os.SystemProperties" );
Method get = c.getMethod( "get", new Class[]{String.class, String.class} );
value = ( String ) get.invoke( c, new Object[]{key, "unknown"} );
} catch ( Exception e ) {
value = "";
}
return value;
}
}

View File

@@ -1,9 +1,9 @@
package com.mogo.module.extensions.anim;
import android.graphics.drawable.AnimationDrawable;
import android.os.Build;
import android.widget.ImageView;
import com.mogo.module.common.utils.CarSeries;
import com.mogo.module.extensions.R;
import com.mogo.utils.ThreadPoolService;
import com.mogo.utils.UiThreadHandler;
@@ -27,7 +27,7 @@ public class AnimWrapper implements Anim {
public void initAnim( ImageView target ) {
mTarget = target;
if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ) {
if ( CarSeries.getSeries() == CarSeries.CAR_SERIES_F80X ) {
ThreadPoolService.execute( () -> {
final AnimationDrawable drawable = new AnimationDrawable();
for ( int i = 0; i < AnimRes.sRes.length; i++ ) {

View File

@@ -23,6 +23,7 @@ import com.mogo.service.intent.IMogoIntentListener;
import com.mogo.service.intent.IMogoIntentManager;
import com.mogo.service.map.IMogoMapService;
import com.mogo.service.module.IMogoSearchManager;
import com.mogo.service.strategy.IMogoRefreshStrategyController;
import com.mogo.service.voice.IMogoVoiceListener;
import com.mogo.service.voice.IMogoVoiceManager;
import com.mogo.utils.ResourcesHelper;
@@ -48,6 +49,7 @@ public class MapPresenter extends Presenter<MapView> implements
private IMogoMapService mMogoMapService;
private IMogoIntentManager mMogoIntentManager;
private IMogoSearchManager mSearchManager;
private IMogoRefreshStrategyController mRefreshStrategyController;
public MapPresenter(MapView view) {
super(view);
@@ -72,12 +74,19 @@ public class MapPresenter extends Presenter<MapView> implements
if (type == 0) {
mView.getUIController().setTrafficEnabled(opera_type == 0);
} else if (type == 1) {
boolean isLocked = mMogoMapService.getMapUIController().isCarLocked();
mView.getUIController().changeZoom(opera_type == 0);
UiThreadHandler.postDelayed( ()->{
int lockZoomLevel = opera_type == 0 ? ( ( int ) mView.getUIController().getZoomLevel() ) : ( ( int ) (mView.getUIController().getZoomLevel() + 0.5 ));
mView.getUIController().setLockZoom( lockZoomLevel );
mMogoMapService.getMapUIController().recoverLockMode();//缩放地图会导致锁车发生改变,这里强制锁车
}, 1_000 );
if ( isLocked ) {
// 保持锁车状态
UiThreadHandler.postDelayed( ()->{
int lockZoomLevel = opera_type == 0 ? ( ( int ) mView.getUIController().getZoomLevel() ) : ( ( int ) (mView.getUIController().getZoomLevel() + 0.5 ));
mView.getUIController().setLockZoom( lockZoomLevel );
mMogoMapService.getMapUIController().recoverLockMode();//缩放地图会导致锁车发生改变,这里强制锁车
}, 1_000 );
} else {
// 30s后锁车刷新
mRefreshStrategyController.restartAutoRefreshAtTime( 30 );
}
} else if (type == 2) {
if (opera_type == 0) {
mView.getUIController().changeMapMode(EnumMapUI.CarUp_2D);
@@ -161,6 +170,7 @@ public class MapPresenter extends Presenter<MapView> implements
mMogoMapService = apis.getMapServiceApi();
mMogoIntentManager = apis.getIntentManagerApi();
mSearchManager = apis.getSearchManagerApi();
mRefreshStrategyController = apis.getRefreshStrategyControllerApi();
IMogoNavi mogoNavi = mMogoMapService.getNavi(getContext());
mogoNavi.setCalculatePathDisplayBounds(new Rect(

View File

@@ -743,13 +743,6 @@ public class MogoServices implements IMogoMapListener,
}
int status = intent.getIntExtra( MogoReceiver.PARAM_ADAS_STATUS, 0 );
mStatusManager.setADASUIShow( ServiceConst.TYPE, status == 1 );
if ( status != 1 ) { // adas 关闭
mUiController.setLockZoom( ServiceConst.DEFAULT_LOCK_CAR_ZOOM_LEVEL );
// 延时两秒执行是为了让其它事物完成
UiThreadHandler.postDelayed( () -> {
mUiController.showMyLocation( true );
}, 2_000L );
}
} else if ( Intent.ACTION_POWER_CONNECTED.equals( command ) ) {
mStatusManager.setAccStatus( ServiceConst.TYPE, true );
} else if ( Intent.ACTION_POWER_DISCONNECTED.equals( command ) ) {

View File

@@ -16,7 +16,4 @@ public interface IMogoRefreshStrategyController extends IProvider {
* @param delay 单位ms 0 为则立即刷新,为负值则忽略
*/
void restartAutoRefreshAtTime( int delay );
}