删除无用类
优化地图中心点按照productFlavor来进行选择
This commit is contained in:
@@ -557,7 +557,6 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
Logger.d( TAG, Log.getStackTraceString( new Throwable() ) );
|
||||
}
|
||||
Logger.d( TAG, "Zoom锁定锁车比例尺 %s", var1 );
|
||||
// TODO: 2020/8/27 设置锁车比例尺
|
||||
// mMapView.setLockZoom( var1 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,14 +6,12 @@ import androidx.lifecycle.LifecycleOwner;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.module.apps.applaunch.AppLaunchFilter;
|
||||
import com.mogo.module.apps.applaunch.AppLauncher;
|
||||
import com.mogo.module.apps.applaunch.CardAppLauncher;
|
||||
import com.mogo.module.apps.applaunch.GuideShowLauncher;
|
||||
import com.mogo.module.apps.applaunch.InternalFunctionLauncher;
|
||||
import com.mogo.module.apps.model.AppInfo;
|
||||
import com.mogo.module.apps.model.AppsModel;
|
||||
import com.mogo.module.apps.model.UnScannedApps;
|
||||
import com.mogo.service.analytics.IMogoAnalytics;
|
||||
import com.mogo.service.cardmanager.IMogoCardManager;
|
||||
import com.mogo.utils.ThreadPoolService;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
@@ -38,16 +36,11 @@ public class AppsPresenter extends Presenter< AppsView > {
|
||||
private IMogoAnalytics mAnalytics;
|
||||
private AppLaunchFilter mLauncher;
|
||||
|
||||
private IMogoCardManager mCardManager;
|
||||
|
||||
public AppsPresenter( AppsView view ) {
|
||||
super( view );
|
||||
mCardManager = AppServiceHandler.getApis().getCardManagerApi();
|
||||
InternalFunctionLauncher internalFunctionLauncher = new InternalFunctionLauncher( getContext() );
|
||||
CardAppLauncher cardAppLauncher = new CardAppLauncher( this, mCardManager );
|
||||
GuideShowLauncher guideShowLauncher = new GuideShowLauncher( AppServiceHandler.getApis().getMapServiceApi().getNavi( getContext() ) );
|
||||
internalFunctionLauncher.setNext( cardAppLauncher );
|
||||
cardAppLauncher.setNext( guideShowLauncher );
|
||||
internalFunctionLauncher.setNext( guideShowLauncher );
|
||||
guideShowLauncher.setNext( new AppLauncher() );
|
||||
mLauncher = internalFunctionLauncher;
|
||||
}
|
||||
@@ -217,7 +210,6 @@ public class AppsPresenter extends Presenter< AppsView > {
|
||||
mView = null;
|
||||
mLauncher.destroy();
|
||||
mAnalytics = null;
|
||||
mCardManager = null;
|
||||
if ( mLauncher != null ) {
|
||||
mLauncher.destroy();
|
||||
}
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
package com.mogo.module.apps.applaunch;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.module.apps.AppsPresenter;
|
||||
import com.mogo.module.apps.model.AppInfo;
|
||||
import com.mogo.service.cardmanager.IMogoCardManager;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-09
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class CardAppLauncher extends BaseAppLauncher {
|
||||
|
||||
private static Map< String, String > sCardApps = new HashMap<>();
|
||||
|
||||
static {
|
||||
sCardApps.put( "com.zhidao.roadcondition.split", "CARD_TYPE_ROAD_CONDITION" );
|
||||
sCardApps.put( "com.zhidao.roadcondition", "CARD_TYPE_ROAD_CONDITION" );
|
||||
sCardApps.put( "com.zhidao.imdemo", "CARD_TYPE_CARS_CHATTING" );
|
||||
}
|
||||
|
||||
private AppsPresenter mAppsPresenter;
|
||||
private IMogoCardManager mCardManager;
|
||||
|
||||
public CardAppLauncher( AppsPresenter mAppsPresenter, IMogoCardManager mCardManager ) {
|
||||
this.mAppsPresenter = mAppsPresenter;
|
||||
this.mCardManager = mCardManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launch( Context context, AppInfo appInfo ) {
|
||||
if ( getNext() != null ) {
|
||||
getNext().launch( context, appInfo );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
mAppsPresenter = null;
|
||||
mCardManager = null;
|
||||
if ( getNext() != null ) {
|
||||
getNext().destroy();
|
||||
setNext( null );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.mogo.module.common.map;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.module.common.utils.CarSeries;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
@@ -18,112 +18,102 @@ public class MapCenterPointStrategy {
|
||||
|
||||
private static final String TAG = "MapCenterPointStrategy";
|
||||
|
||||
private static Map< Integer, Map< Integer, MapCenterPoint > > sStrategies = new HashMap<>();
|
||||
private static Map< Integer, Map< String, MapCenterPoint > > sStrategies = new HashMap<>();
|
||||
|
||||
public static final MapCenterPoint DEFAULT = new MapCenterPoint( 0.677734D, 0.5733333D );
|
||||
|
||||
private static MapCenterPoint sLastPoint = DEFAULT;
|
||||
|
||||
public static void init() {
|
||||
|
||||
{
|
||||
// 选点场景,定位中心点
|
||||
Map< Integer, MapCenterPoint > choosePoint = new HashMap<>();
|
||||
choosePoint.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.5D, 0.5D ) );
|
||||
choosePoint.put( CarSeries.CAR_SERIES_E84X, new MapCenterPoint( 0.5D, 0.5D ) );
|
||||
choosePoint.put( CarSeries.CAR_SERIES_E84XCD, new MapCenterPoint( 0.5D, 0.5D ) );
|
||||
choosePoint.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.5D, 0.5D ) );
|
||||
Map< String, MapCenterPoint > choosePoint = new HashMap<>();
|
||||
choosePoint.put( "d80x", new MapCenterPoint( 0.5D, 0.5D ) );
|
||||
choosePoint.put( "em4", new MapCenterPoint( 0.5D, 0.5D ) );
|
||||
choosePoint.put( "e8xx", new MapCenterPoint( 0.5D, 0.5D ) );
|
||||
choosePoint.put( "f80x", new MapCenterPoint( 0.5D, 0.5D ) );
|
||||
choosePoint.put( "f8xx", new MapCenterPoint( 0.5D, 0.5D ) );
|
||||
sStrategies.put( Scene.CHOOSE_POINT, choosePoint );
|
||||
}
|
||||
|
||||
{
|
||||
// 导航场景,定位视图右下角偏下
|
||||
Map< Integer, MapCenterPoint > navi = new HashMap<>();
|
||||
navi.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.669444444444444, 0.573333333333D ) );
|
||||
navi.put( CarSeries.CAR_SERIES_E84X, new MapCenterPoint( 0.734375D, 0.573333333333D ) );
|
||||
navi.put( CarSeries.CAR_SERIES_E84XCD, new MapCenterPoint( 0.734375D, 0.573333333333D ) );
|
||||
navi.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.705208333D, 0.575D ) );
|
||||
Map< String, MapCenterPoint > navi = new HashMap<>();
|
||||
navi.put( "d80x", new MapCenterPoint( 0.669444444444444, 0.573333333333D ) );
|
||||
navi.put( "em4", new MapCenterPoint( 0.734375D, 0.573333333333D ) );
|
||||
navi.put( "e8xx", new MapCenterPoint( 0.734375D, 0.573333333333D ) );
|
||||
navi.put( "f80x", new MapCenterPoint( 0.705208333D, 0.575D ) );
|
||||
navi.put( "f8xx", new MapCenterPoint( 0.705208333D, 0.575D ) );
|
||||
sStrategies.put( Scene.NAVI, navi );
|
||||
}
|
||||
|
||||
{
|
||||
// 导航场景 vs 道路事件展示场景,定位视图右下角偏下
|
||||
Map< Integer, MapCenterPoint > naviWithRoadEvent = new HashMap<>();
|
||||
naviWithRoadEvent.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.669444444444444, 0.73936170212766D ) );
|
||||
naviWithRoadEvent.put( CarSeries.CAR_SERIES_E84X, new MapCenterPoint( 0.734375D, 0.73936170212766D ) );
|
||||
naviWithRoadEvent.put( CarSeries.CAR_SERIES_E84XCD, new MapCenterPoint( 0.734375D, 0.73936170212766D ) );
|
||||
naviWithRoadEvent.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.705208333D, 0.683333333333D ) );
|
||||
Map< String, MapCenterPoint > naviWithRoadEvent = new HashMap<>();
|
||||
naviWithRoadEvent.put( "d80x", new MapCenterPoint( 0.669444444444444, 0.73936170212766D ) );
|
||||
naviWithRoadEvent.put( "em4", new MapCenterPoint( 0.734375D, 0.73936170212766D ) );
|
||||
naviWithRoadEvent.put( "e8xx", new MapCenterPoint( 0.734375D, 0.73936170212766D ) );
|
||||
naviWithRoadEvent.put( "f80x", new MapCenterPoint( 0.705208333D, 0.683333333333D ) );
|
||||
naviWithRoadEvent.put( "f8xx", new MapCenterPoint( 0.705208333D, 0.683333333333D ) );
|
||||
sStrategies.put( Scene.NAVI_WITH_ROAD_EVENT, naviWithRoadEvent );
|
||||
}
|
||||
|
||||
{
|
||||
// 巡航场景
|
||||
Map< Integer, MapCenterPoint > aimless = new HashMap<>();
|
||||
aimless.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.669444444444444, 0.5D ) );
|
||||
aimless.put( CarSeries.CAR_SERIES_E84X, new MapCenterPoint( 0.734375D, 0.5D ) );
|
||||
aimless.put( CarSeries.CAR_SERIES_E84XCD, new MapCenterPoint( 0.734375D, 0.5D ) );
|
||||
aimless.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.705208333D, 0.5D ) );
|
||||
Map< String, MapCenterPoint > aimless = new HashMap<>();
|
||||
aimless.put( "d80x", new MapCenterPoint( 0.669444444444444, 0.5D ) );
|
||||
aimless.put( "em4", new MapCenterPoint( 0.734375D, 0.5D ) );
|
||||
aimless.put( "e8xx", new MapCenterPoint( 0.734375D, 0.5D ) );
|
||||
aimless.put( "f80x", new MapCenterPoint( 0.705208333D, 0.5D ) );
|
||||
aimless.put( "f8xx", new MapCenterPoint( 0.705208333D, 0.5D ) );
|
||||
sStrategies.put( Scene.AIMLESS, aimless );
|
||||
}
|
||||
|
||||
{
|
||||
// 巡航场景 vs 道路事件展示场景
|
||||
Map< Integer, MapCenterPoint > aimlessWithRoadEvent = new HashMap<>();
|
||||
aimlessWithRoadEvent.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.669444444444444, 0.68617 ) );
|
||||
aimlessWithRoadEvent.put( CarSeries.CAR_SERIES_E84X, new MapCenterPoint( 0.734375D, 0.68617 ) );
|
||||
aimlessWithRoadEvent.put( CarSeries.CAR_SERIES_E84XCD, new MapCenterPoint( 0.734375D, 0.68617 ) );
|
||||
aimlessWithRoadEvent.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.705208333D, 0.599074074D ) );
|
||||
Map< String, MapCenterPoint > aimlessWithRoadEvent = new HashMap<>();
|
||||
aimlessWithRoadEvent.put( "d80x", new MapCenterPoint( 0.669444444444444, 0.68617 ) );
|
||||
aimlessWithRoadEvent.put( "em4", new MapCenterPoint( 0.734375D, 0.68617 ) );
|
||||
aimlessWithRoadEvent.put( "e8xx", new MapCenterPoint( 0.734375D, 0.68617 ) );
|
||||
aimlessWithRoadEvent.put( "f80x", new MapCenterPoint( 0.705208333D, 0.599074074D ) );
|
||||
aimlessWithRoadEvent.put( "f8xx", new MapCenterPoint( 0.705208333D, 0.599074074D ) );
|
||||
sStrategies.put( Scene.AIMLESS_WITH_ROAD_EVENT, aimlessWithRoadEvent );
|
||||
}
|
||||
|
||||
{
|
||||
// 规划路线,定位视图右边
|
||||
Map< Integer, MapCenterPoint > calculatePath = new HashMap<>();
|
||||
calculatePath.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.733398D, 0.610833D ) );
|
||||
calculatePath.put( CarSeries.CAR_SERIES_E84X, new MapCenterPoint( 0.733398D, 0.610833D ) );
|
||||
calculatePath.put( CarSeries.CAR_SERIES_E84XCD, new MapCenterPoint( 0.733398D, 0.610833D ) );
|
||||
calculatePath.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.703125D, 0.6083333D ) );
|
||||
Map< String, MapCenterPoint > calculatePath = new HashMap<>();
|
||||
calculatePath.put( "d80x", new MapCenterPoint( 0.733398D, 0.610833D ) );
|
||||
calculatePath.put( "em4", new MapCenterPoint( 0.733398D, 0.610833D ) );
|
||||
calculatePath.put( "e8xx", new MapCenterPoint( 0.733398D, 0.610833D ) );
|
||||
calculatePath.put( "f80x", new MapCenterPoint( 0.703125D, 0.6083333D ) );
|
||||
calculatePath.put( "f8xx", new MapCenterPoint( 0.703125D, 0.6083333D ) );
|
||||
sStrategies.put( Scene.CALCULATE_PATH, calculatePath );
|
||||
}
|
||||
|
||||
{
|
||||
// 分类搜索,定位视图右边
|
||||
Map< Integer, MapCenterPoint > categorySearch = new HashMap<>();
|
||||
categorySearch.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.733398D, 0.5D ) );
|
||||
categorySearch.put( CarSeries.CAR_SERIES_E84X, new MapCenterPoint( 0.733398D, 0.5D ) );
|
||||
categorySearch.put( CarSeries.CAR_SERIES_E84XCD, new MapCenterPoint( 0.733398D, 0.5D ) );
|
||||
categorySearch.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.733594D, 0.5D ) );
|
||||
Map< String, MapCenterPoint > categorySearch = new HashMap<>();
|
||||
categorySearch.put( "d80x", new MapCenterPoint( 0.733398D, 0.5D ) );
|
||||
categorySearch.put( "em4", new MapCenterPoint( 0.733398D, 0.5D ) );
|
||||
categorySearch.put( "e8xx", new MapCenterPoint( 0.733398D, 0.5D ) );
|
||||
categorySearch.put( "f80x", new MapCenterPoint( 0.733594D, 0.5D ) );
|
||||
categorySearch.put( "f8xx", new MapCenterPoint( 0.733594D, 0.5D ) );
|
||||
sStrategies.put( Scene.CATEGORY_SEARCH, categorySearch );
|
||||
}
|
||||
|
||||
{
|
||||
// V2X,场景视图右边
|
||||
Map< Integer, MapCenterPoint > categoryV2XEvent = new HashMap<>();
|
||||
categoryV2XEvent.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.669444444444444, 0.7D ) );
|
||||
categoryV2XEvent.put( CarSeries.CAR_SERIES_E84X, new MapCenterPoint( 0.677734375D, 0.7D ) );
|
||||
categoryV2XEvent.put( CarSeries.CAR_SERIES_E84XCD, new MapCenterPoint( 0.677734375D, 0.7D ) );
|
||||
categoryV2XEvent.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.6963541D, 0.65D ) );
|
||||
Map< String, MapCenterPoint > categoryV2XEvent = new HashMap<>();
|
||||
categoryV2XEvent.put( "d80x", new MapCenterPoint( 0.669444444444444, 0.7D ) );
|
||||
categoryV2XEvent.put( "em4", new MapCenterPoint( 0.677734375D, 0.7D ) );
|
||||
categoryV2XEvent.put( "e8xx", new MapCenterPoint( 0.677734375D, 0.7D ) );
|
||||
categoryV2XEvent.put( "f80x", new MapCenterPoint( 0.6963541D, 0.65D ) );
|
||||
categoryV2XEvent.put( "f8xx", new MapCenterPoint( 0.6963541D, 0.65D ) );
|
||||
sStrategies.put( Scene.CATEGORY_V2X_EVENT, categoryV2XEvent );
|
||||
}
|
||||
|
||||
try {
|
||||
sLastPoint = sStrategies.get( Scene.AIMLESS ).get( CarSeries.getSeries() );
|
||||
} catch ( Exception e ) {
|
||||
sLastPoint = DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
public static void restoreLastScene( IMogoMapUIController controller ) {
|
||||
if ( sLastPoint == null ) {
|
||||
return;
|
||||
}
|
||||
if ( controller == null ) {
|
||||
return;
|
||||
}
|
||||
controller.setPointToCenter( sLastPoint.x, sLastPoint.y );
|
||||
}
|
||||
|
||||
public static void addScene( int scene, Map< Integer, MapCenterPoint > config ) {
|
||||
public static void addScene( int scene, Map< String, MapCenterPoint > config ) {
|
||||
if ( sStrategies.containsKey( scene ) ) {
|
||||
Logger.w( TAG, "scene has already defined, append config..." );
|
||||
}
|
||||
@@ -147,25 +137,21 @@ public class MapCenterPointStrategy {
|
||||
if ( !sStrategies.containsKey( scene ) ) {
|
||||
Logger.w( TAG, "no strategy for scene: %s, use DEFAULT", scene );
|
||||
controller.setPointToCenter( DEFAULT.x, DEFAULT.y );
|
||||
sLastPoint = DEFAULT;
|
||||
return;
|
||||
}
|
||||
Map< Integer, MapCenterPoint > points = sStrategies.get( scene );
|
||||
int car = CarSeries.getSeries();
|
||||
Map< String, MapCenterPoint > points = sStrategies.get( scene );
|
||||
String car = DebugConfig.getProductFlavor();
|
||||
if ( !points.containsKey( car ) ) {
|
||||
Logger.w( TAG, "no strategy for series: %s, use DEFAULT", scene );
|
||||
controller.setPointToCenter( DEFAULT.x, DEFAULT.y );
|
||||
sLastPoint = DEFAULT;
|
||||
return;
|
||||
}
|
||||
MapCenterPoint point = points.get( car );
|
||||
if ( point == null ) {
|
||||
Logger.w( TAG, "no strategy config for series: %s, use DEFAULT", scene );
|
||||
controller.setPointToCenter( DEFAULT.x, DEFAULT.y );
|
||||
sLastPoint = DEFAULT;
|
||||
return;
|
||||
}
|
||||
sLastPoint = point;
|
||||
controller.setPointToCenter( point.x, point.y );
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,5 @@
|
||||
|
||||
## 应用内浮窗管理:车聊聊、音乐等
|
||||
|
||||
## 顶部弹窗管理
|
||||
|
||||
## scheme 跳转管理
|
||||
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
#-----MainModule-----
|
||||
-keep class com.mogo.module.main.cards.CardIntroduceConfig.*{*;}
|
||||
-keep class com.mogo.module.main.cards.MogoModulesHandler
|
||||
-keep class com.mogo.module.main.cards.HorizentalBaseTransformer
|
||||
-keep class com.mogo.module.main.cards.VerticalBaseTransformer
|
||||
-keep class com.mogo.module.main.constants.**{*;}
|
||||
-keep class com.mogo.module.main.livedata.**{*;}
|
||||
-keep class com.mogo.module.main.service.MogoMainService
|
||||
|
||||
2
modules/mogo-module-main/proguard-rules.pro
vendored
2
modules/mogo-module-main/proguard-rules.pro
vendored
@@ -23,8 +23,6 @@
|
||||
#-----MainModule-----
|
||||
-keep class com.mogo.module.main.cards.CardIntroduceConfig.*{*;}
|
||||
-keep class com.mogo.module.main.cards.MogoModulesHandler
|
||||
-keep class com.mogo.module.main.cards.HorizentalBaseTransformer
|
||||
-keep class com.mogo.module.main.cards.VerticalBaseTransformer
|
||||
-keep class com.mogo.module.main.constants.**{*;}
|
||||
-keep class com.mogo.module.main.livedata.**{*;}
|
||||
-keep class com.mogo.module.main.service.MogoMainService
|
||||
|
||||
@@ -3,15 +3,10 @@ package com.mogo.module.main;
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.module.main.livedata.CardInfo;
|
||||
import com.mogo.module.main.livedata.CardSwitchLiveData;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.cardmanager.IMogoCardChangedListener;
|
||||
import com.mogo.service.cardmanager.IMogoCardManager;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -19,42 +14,35 @@ import java.util.Map;
|
||||
* <p>
|
||||
* 卡片控制
|
||||
*/
|
||||
@Deprecated
|
||||
@Route( path = MogoServicePaths.PATH_CARD_MANAGER )
|
||||
public class MogoCardManager implements IMogoCardManager {
|
||||
|
||||
private static final Map< String, IMogoCardChangedListener > sListeners = new HashMap<>();
|
||||
private static final String TAG = "MogoCardManager";
|
||||
|
||||
@Override
|
||||
public void switch2( String cardType ) {
|
||||
CardSwitchLiveData.getInstance().postValue( new CardInfo( cardType, false ) );
|
||||
Logger.w( TAG, "Useless, do not invoke anymore." );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCardChangedListener( String tag, IMogoCardChangedListener listener ) {
|
||||
sListeners.put( tag, listener );
|
||||
Logger.w( TAG, "Useless, do not invoke anymore." );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterCardChangedListener( String tag ) {
|
||||
sListeners.remove( tag );
|
||||
Logger.w( TAG, "Useless, do not invoke anymore." );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke( int position, String moduleName ) {
|
||||
if ( sListeners != null && !sListeners.isEmpty() ) {
|
||||
Iterator< IMogoCardChangedListener > iterator = sListeners.values().iterator();
|
||||
while ( iterator.hasNext() ) {
|
||||
IMogoCardChangedListener listener = iterator.next();
|
||||
if ( listener != null ) {
|
||||
listener.onSwitched( position, moduleName );
|
||||
}
|
||||
}
|
||||
}
|
||||
Logger.w( TAG, "Useless, do not invoke anymore." );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switch2( String cardType, boolean lockCar ) {
|
||||
CardSwitchLiveData.getInstance().postValue( new CardInfo( cardType, lockCar ) );
|
||||
Logger.w( TAG, "Useless, do not invoke anymore." );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,9 +6,6 @@ import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.module.common.ModuleNames;
|
||||
import com.mogo.module.main.livedata.CardInfo;
|
||||
import com.mogo.module.main.livedata.CardSwitchLiveData;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
@@ -57,12 +54,13 @@ public class SchemeIntent implements IMogoStatusChangedListener {
|
||||
|
||||
private static volatile SchemeIntent sInstance;
|
||||
|
||||
private SchemeIntent(){}
|
||||
private SchemeIntent() {
|
||||
}
|
||||
|
||||
public static SchemeIntent getInstance(){
|
||||
if( sInstance == null ){
|
||||
synchronized( SchemeIntent.class ) {
|
||||
if( sInstance == null ){
|
||||
public static SchemeIntent getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( SchemeIntent.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new SchemeIntent();
|
||||
}
|
||||
}
|
||||
@@ -70,7 +68,7 @@ public class SchemeIntent implements IMogoStatusChangedListener {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release(){
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
@@ -80,7 +78,7 @@ public class SchemeIntent implements IMogoStatusChangedListener {
|
||||
mApis.getStatusManagerApi().registerStatusChangedListener( TAG, StatusDescriptor.MAIN_PAGE_RESUME, this );
|
||||
}
|
||||
|
||||
public void clear(){
|
||||
public void clear() {
|
||||
mApis.getStatusManagerApi().unregisterStatusChangedListener( TAG, StatusDescriptor.MAIN_PAGE_RESUME, this );
|
||||
mContext = null;
|
||||
mApis = null;
|
||||
@@ -141,14 +139,6 @@ public class SchemeIntent implements IMogoStatusChangedListener {
|
||||
return;
|
||||
}
|
||||
switch ( type ) {
|
||||
case ModuleNames.CARD_TYPE_BUSINESS_OPERATION:
|
||||
case ModuleNames.CARD_TYPE_CARS_CHATTING:
|
||||
case ModuleNames.CARD_TYPE_NOVELTY:
|
||||
case ModuleNames.CARD_TYPE_ROAD_CONDITION:
|
||||
case ModuleNames.CARD_TYPE_SHARE_MUSIC:
|
||||
case ModuleNames.CARD_TYPE_USER_DATA:
|
||||
handleSwitchCardIntent( type );
|
||||
break;
|
||||
case TYPE_NAVI:
|
||||
handleNaviIntent( target );
|
||||
break;
|
||||
@@ -175,10 +165,6 @@ public class SchemeIntent implements IMogoStatusChangedListener {
|
||||
target.getQueryParameter( "keywords" ) );
|
||||
}
|
||||
|
||||
private void handleSwitchCardIntent( String type ) {
|
||||
CardSwitchLiveData.getInstance().postValue( new CardInfo( type, true ) );
|
||||
}
|
||||
|
||||
private void handleNaviIntent( Uri naviUri ) {
|
||||
if ( mApis == null ) {
|
||||
return;
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-27
|
||||
* <p>
|
||||
* 卡片播报配置
|
||||
*/
|
||||
public class CardIntroduceConfig {
|
||||
|
||||
public String cardType;
|
||||
public String broadcastWords;
|
||||
public int broadcastAmount;
|
||||
|
||||
public CardIntroduceConfig( String cardType, String broadcastWords, int broadcastAmount ) {
|
||||
this.cardType = cardType;
|
||||
this.broadcastWords = broadcastWords;
|
||||
this.broadcastAmount = broadcastAmount;
|
||||
}
|
||||
|
||||
public CardIntroduceConfig() {
|
||||
}
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.commons.voice.VoicePreemptType;
|
||||
import com.mogo.map.navi.IMogoNavi;
|
||||
import com.mogo.module.common.ModuleNames;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.utils.CommonUtils;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
import com.mogo.utils.storage.SharedPrefsMgr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-27
|
||||
* <p>
|
||||
* 卡片播报配置
|
||||
*/
|
||||
public class CardIntroduceConfigs {
|
||||
|
||||
private static final String TAG = "CardIntroduceConfigs";
|
||||
|
||||
public static final String KEY_VOICE_BROADCAST_CONFIG = "voice_broadcast_";
|
||||
public static String sBroadcastConfigKey;
|
||||
|
||||
public static Map< String, CardIntroduceConfig > sConfigs = new HashMap<>();
|
||||
private static IMogoStatusManager sStatusManager;
|
||||
private static IMogoNavi sNaiv;
|
||||
|
||||
static {
|
||||
sConfigs.put( ModuleNames.CARD_TYPE_BUSINESS_OPERATION, new CardIntroduceConfig( ModuleNames.CARD_TYPE_BUSINESS_OPERATION, "", 3 ) );
|
||||
sConfigs.put( ModuleNames.CARD_TYPE_SHARE_MUSIC, new CardIntroduceConfig( ModuleNames.CARD_TYPE_SHARE_MUSIC, "音乐新闻听书,海量资源随你选", 0 ) );
|
||||
sConfigs.put( ModuleNames.CARD_TYPE_CARS_CHATTING, new CardIntroduceConfig( ModuleNames.CARD_TYPE_CARS_CHATTING, "开车无聊,就用车聊聊", 0 ) );
|
||||
sConfigs.put( ModuleNames.CARD_TYPE_ROAD_CONDITION, new CardIntroduceConfig( ModuleNames.CARD_TYPE_ROAD_CONDITION, "随时查看路况,可以对我说某某地点堵不堵", 0 ) );
|
||||
sConfigs.put( ModuleNames.CARD_TYPE_USER_DATA, new CardIntroduceConfig( ModuleNames.CARD_TYPE_USER_DATA, "在线车辆,邀你在地图上发现万千有趣的车友", 0 ) );
|
||||
sConfigs.put( ModuleNames.CARD_TYPE_NOVELTY, new CardIntroduceConfig( ModuleNames.CARD_TYPE_NOVELTY, "新鲜事,邀你给同城车友分享沿途封路、拥堵消息", 0 ) );
|
||||
}
|
||||
|
||||
public static void init( Context context, IMogoServiceApis apis ) {
|
||||
sStatusManager = apis.getStatusManagerApi();
|
||||
sNaiv = apis.getMapServiceApi().getNavi( context );
|
||||
WorkThreadHandler.getInstance().post( () -> {
|
||||
sBroadcastConfigKey = KEY_VOICE_BROADCAST_CONFIG + CommonUtils.getVersionCode( context );
|
||||
String configsStr = SharedPrefsMgr.getInstance( context ).getString( sBroadcastConfigKey );
|
||||
List< CardIntroduceConfig > configs = GsonUtil.arrayFromJson( configsStr, CardIntroduceConfig.class );
|
||||
if ( configs == null ) {
|
||||
return;
|
||||
}
|
||||
for ( CardIntroduceConfig config : configs ) {
|
||||
if ( config == null ) {
|
||||
return;
|
||||
}
|
||||
sConfigs.put( config.cardType, config );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
public static void broadcastCardIntroduce( Context context, String type ) {
|
||||
if ( sConfigs.get( type ) == null ) {
|
||||
Logger.d( TAG, "un support %s", type );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( sConfigs.get( type ).broadcastAmount >= 3 ) {
|
||||
Logger.d( TAG, "do not broadcastCardIntroduce %s cast amount = %s", type, type );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( sStatusManager != null ) {
|
||||
if ( !sStatusManager.isAIAssistReady() ) {
|
||||
Logger.w( TAG, "ai assist not ready: %s", type );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( sNaiv.isNaviing() ) {
|
||||
Logger.d( TAG, "do not broadcastCardIntroduce cause naving" );
|
||||
return;
|
||||
}
|
||||
|
||||
CardIntroduceConfig config = sConfigs.get( type );
|
||||
config.broadcastAmount++;
|
||||
|
||||
Logger.d( TAG, "speak card introduce: %s", config.broadcastWords );
|
||||
AIAssist.getInstance( context ).speakTTSVoice( config.broadcastWords, VoicePreemptType.PREEMPT_TYPE_IMMEADIATELY, null );
|
||||
}
|
||||
|
||||
public static void flush( Context context ) {
|
||||
if ( sBroadcastConfigKey == null || sConfigs.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
WorkThreadHandler.getInstance().post( () -> {
|
||||
synchronized ( sConfigs ) {
|
||||
ArrayList configs = new ArrayList( sConfigs.entrySet() );
|
||||
SharedPrefsMgr.getInstance( context ).putString( sBroadcastConfigKey, GsonUtil.jsonFromObject( configs ) );
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||
|
||||
import com.mogo.module.main.MainActivity;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-30
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class CardModulesAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
private static final String TAG = "CardModulesAdapter";
|
||||
|
||||
private final MainActivity mActivity;
|
||||
private List< IMogoModuleProvider > mProviders;
|
||||
|
||||
public CardModulesAdapter( @NonNull MainActivity fragmentActivity, List< IMogoModuleProvider > providers ) {
|
||||
super( fragmentActivity.getSupportFragmentManager() );
|
||||
mActivity = fragmentActivity;
|
||||
this.mProviders = new ArrayList<>( providers );
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment getItem( int position ) {
|
||||
Logger.i( TAG, "current position: %d", position );
|
||||
int factPosition = getFactPosition( position );
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt( "position", factPosition );
|
||||
final Fragment f = mProviders.get( factPosition ).createFragment( mActivity, bundle );
|
||||
return f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mProviders.size();
|
||||
// return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
public IMogoModuleProvider getProvider( int position ) {
|
||||
return mProviders.get( getFactPosition( position ) );
|
||||
}
|
||||
|
||||
public int getFactPosition( int position ) {
|
||||
return position % mProviders.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemPosition( Object object ) {
|
||||
return POSITION_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对应卡片类型在列表中的位置
|
||||
*
|
||||
* @param tag 卡片类型
|
||||
* @return 列表中的位置
|
||||
*/
|
||||
public int getProviderPosition( String tag ) {
|
||||
if ( mProviders != null ) {
|
||||
for ( int i = 0; i < mProviders.size(); i++ ) {
|
||||
IMogoModuleProvider provider = mProviders.get( i );
|
||||
if ( provider != null ) {
|
||||
if ( TextUtils.equals( provider.getModuleName(), tag ) ) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import android.view.View;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
/**
|
||||
* Created by Nate on 2016/7/22.
|
||||
*/
|
||||
public abstract class HorizentalBaseTransformer implements ViewPager.PageTransformer {
|
||||
/**
|
||||
* Called each {@link #transformPage(View, float)}.
|
||||
*
|
||||
* @param page Apply the transformation to this page
|
||||
* @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
|
||||
* center. 1 is one full page position to the right, and -1 is one page position to the left.
|
||||
*/
|
||||
protected abstract void onTransform(View page, float position);
|
||||
|
||||
/**
|
||||
* Apply a property transformation to the given page. For most use cases, this method should not be overridden.
|
||||
* Instead use {@link #transformPage(View, float)} to perform typical transformations.
|
||||
*
|
||||
* @param page Apply the transformation to this page
|
||||
* @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
|
||||
* center. 1 is one full page position to the right, and -1 is one page position to the left.
|
||||
*/
|
||||
@Override
|
||||
public void transformPage(View page, float position) {
|
||||
onPreTransform(page, position);
|
||||
onTransform(page, position);
|
||||
onPostTransform(page, position);
|
||||
}
|
||||
|
||||
/**
|
||||
* If the position offset of a fragment is less than negative one or greater than one, returning true will set the
|
||||
* fragment alpha to 0f. Otherwise fragment alpha is always defaulted to 1f.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected boolean hideOffscreenPages() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the default animations of the view pager should be used.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected boolean isPagingEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)}.
|
||||
* <p/>
|
||||
* The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
|
||||
* not modify the same page properties. For instance changing from a transformation that applies rotation to a
|
||||
* transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
|
||||
* alpha.
|
||||
*
|
||||
* @param page Apply the transformation to this page
|
||||
* @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
|
||||
* center. 1 is one full page position to the right, and -1 is one page position to the left.
|
||||
*/
|
||||
protected void onPreTransform(View page, float position) {
|
||||
final float width = page.getWidth();
|
||||
//final float height = page.getHeight();
|
||||
|
||||
page.setRotationX(0);
|
||||
page.setRotationY(0);
|
||||
page.setRotation(0);
|
||||
page.setScaleX(1);
|
||||
page.setScaleY(1);
|
||||
page.setPivotX(0);
|
||||
page.setPivotY(0);
|
||||
page.setTranslationY(0);
|
||||
page.setTranslationX(isPagingEnabled() ? 0f : -width * position);
|
||||
|
||||
if (hideOffscreenPages()) {
|
||||
page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
|
||||
} else {
|
||||
page.setAlpha(1f);
|
||||
}
|
||||
|
||||
/*final float normalizedposition = Math.abs(Math.abs(position) - 1);
|
||||
page.setAlpha(normalizedposition);*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Called each {@link #transformPage(View, float)} after {@link #onTransform(View, float)}.
|
||||
*
|
||||
* @param page Apply the transformation to this page
|
||||
* @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
|
||||
* center. 1 is one full page position to the right, and -1 is one page position to the left.
|
||||
*/
|
||||
protected void onPostTransform(View page, float position) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as {@link Math#min(double, double)} without double casting, zero closest to infinity handling, or NaN support.
|
||||
*
|
||||
* @param val
|
||||
* @param min
|
||||
* @return
|
||||
*/
|
||||
protected static final float min(float val, float min) {
|
||||
return val < min ? min : val;
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import com.mogo.module.main.R;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
public class HorizentalStackTransformer extends HorizentalBaseTransformer {
|
||||
|
||||
private Context context;
|
||||
private int spaceBetweenFirAndSecWith;//第一张卡片和第二张卡片宽度差
|
||||
private int spaceBetweenFirAndSecHeight;//第一张卡片和第二张卡片高度差
|
||||
private float offsetScroll = 0.0f;//ViewPager滑动时变化幅度
|
||||
|
||||
public HorizentalStackTransformer( Context context ) {
|
||||
this.context = context;
|
||||
spaceBetweenFirAndSecHeight = 0;
|
||||
spaceBetweenFirAndSecWith = context.getResources().getDimensionPixelSize( R.dimen.module_main_card_card_shadow_width_div );
|
||||
}
|
||||
|
||||
public HorizentalStackTransformer( Context context, int spaceBetweenFirAndSecWith, int spaceBetweenFirAndSecHeight ) {
|
||||
this.context = context;
|
||||
this.spaceBetweenFirAndSecWith = spaceBetweenFirAndSecWith;
|
||||
this.spaceBetweenFirAndSecHeight = spaceBetweenFirAndSecHeight;
|
||||
}
|
||||
|
||||
public void offsetScrollChanged(float offset){
|
||||
if(offset ==0){
|
||||
return;
|
||||
}
|
||||
offsetScroll = offset;
|
||||
}
|
||||
|
||||
public void resetOffsetScroll(){
|
||||
offsetScroll = 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTransform( View page, float position ) {
|
||||
if ( position == 0.0f ) {
|
||||
page.setAlpha( 1.0f );
|
||||
page.setTranslationX( 0f );
|
||||
//控制停止滑动切换的时候,只有最上面的一张卡片可以点击
|
||||
page.setClickable( true );
|
||||
} else if(position>0){
|
||||
float scale = ( float ) ( page.getWidth() - spaceBetweenFirAndSecWith * position ) / ( float ) ( page.getWidth() );
|
||||
Logger.d("VerticalStackTransformer","scale :" + scale);
|
||||
//控制下面卡片的可见度
|
||||
page.setAlpha( 1.0f );
|
||||
//控制停止滑动切换的时候,只有最上面的一张卡片可以点击
|
||||
page.setClickable( false );
|
||||
page.setPivotX( page.getWidth() / 2f );
|
||||
page.setPivotY( page.getHeight() / 2f );
|
||||
page.setScaleX( scale );
|
||||
page.setScaleY( scale );
|
||||
page.setTranslationX( -page.getHeight() * position + ( page.getHeight() * 0.5f ) * ( 1 - scale ) + spaceBetweenFirAndSecHeight * position );
|
||||
}else{
|
||||
float currentPage;
|
||||
if(offsetScroll > 0.1f){
|
||||
currentPage = 0.1f;
|
||||
}else{
|
||||
currentPage = offsetScroll;
|
||||
}
|
||||
page.setAlpha( 1 );
|
||||
page.setScaleX(1-currentPage);
|
||||
page.setScaleY(1-currentPage);
|
||||
page.setPivotX( page.getWidth() / 2f );
|
||||
page.setPivotY( page.getHeight() / 2f );
|
||||
page.setTranslationX( 0f );
|
||||
page.setClickable( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-06
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class OnPageChangeListenerAdapter implements ViewPager.OnPageChangeListener {
|
||||
|
||||
@Override
|
||||
public void onPageScrolled( int position, float positionOffset, int positionOffsetPixels ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected( int position ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged( int state ) {
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,112 +0,0 @@
|
||||
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Nate on 2016/7/22.
|
||||
*/
|
||||
public abstract class VerticalBaseTransformer implements ViewPager.PageTransformer {
|
||||
/**
|
||||
* Called each {@link #transformPage(View, float)}.
|
||||
*
|
||||
* @param page Apply the transformation to this page
|
||||
* @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
|
||||
* center. 1 is one full page position to the right, and -1 is one page position to the left.
|
||||
*/
|
||||
protected abstract void onTransform(View page, float position);
|
||||
|
||||
/**
|
||||
* Apply a property transformation to the given page. For most use cases, this method should not be overridden.
|
||||
* Instead use {@link #transformPage(View, float)} to perform typical transformations.
|
||||
*
|
||||
* @param page Apply the transformation to this page
|
||||
* @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
|
||||
* center. 1 is one full page position to the right, and -1 is one page position to the left.
|
||||
*/
|
||||
@Override
|
||||
public void transformPage(View page, float position) {
|
||||
onPreTransform(page, position);
|
||||
onTransform(page, position);
|
||||
onPostTransform(page, position);
|
||||
}
|
||||
|
||||
/**
|
||||
* If the position offset of a fragment is less than negative one or greater than one, returning true will set the
|
||||
* fragment alpha to 0f. Otherwise fragment alpha is always defaulted to 1f.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected boolean hideOffscreenPages() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the default animations of the view pager should be used.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected boolean isPagingEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)}.
|
||||
* <p/>
|
||||
* The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
|
||||
* not modify the same page properties. For instance changing from a transformation that applies rotation to a
|
||||
* transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
|
||||
* alpha.
|
||||
*
|
||||
* @param page Apply the transformation to this page
|
||||
* @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
|
||||
* center. 1 is one full page position to the right, and -1 is one page position to the left.
|
||||
*/
|
||||
protected void onPreTransform(View page, float position) {
|
||||
final float width = page.getWidth();
|
||||
final float height = page.getHeight();
|
||||
|
||||
page.setRotationX(0);
|
||||
page.setRotationY(0);
|
||||
page.setRotation(0);
|
||||
page.setScaleX(1);
|
||||
page.setScaleY(1);
|
||||
page.setPivotX(0);
|
||||
page.setPivotY(0);
|
||||
page.setTranslationX(0);
|
||||
page.setTranslationY(isPagingEnabled() ? 0f : -height * position);
|
||||
|
||||
if (hideOffscreenPages()) {
|
||||
page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
|
||||
} else {
|
||||
page.setAlpha(1f);
|
||||
}
|
||||
|
||||
/*final float normalizedposition = Math.abs(Math.abs(position) - 1);
|
||||
page.setAlpha(normalizedposition);*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Called each {@link #transformPage(View, float)} after {@link #onTransform(View, float)}.
|
||||
*
|
||||
* @param page Apply the transformation to this page
|
||||
* @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
|
||||
* center. 1 is one full page position to the right, and -1 is one page position to the left.
|
||||
*/
|
||||
protected void onPostTransform(View page, float position) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as {@link Math#min(double, double)} without double casting, zero closest to infinity handling, or NaN support.
|
||||
*
|
||||
* @param val
|
||||
* @param min
|
||||
* @return
|
||||
*/
|
||||
protected static final float min(float val, float min) {
|
||||
return val < min ? min : val;
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import com.mogo.module.main.R;
|
||||
import com.mogo.utils.WindowUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
public class VerticalStackTransformer extends VerticalBaseTransformer {
|
||||
|
||||
private Context context;
|
||||
private int spaceBetweenFirAndSecWith;//第一张卡片和第二张卡片宽度差
|
||||
private int spaceBetweenFirAndSecHeight;//第一张卡片和第二张卡片高度差
|
||||
private float offsetScroll = 0.0f;//ViewPager滑动时变化幅度
|
||||
|
||||
public VerticalStackTransformer( Context context ) {
|
||||
this.context = context;
|
||||
spaceBetweenFirAndSecHeight = 0;
|
||||
spaceBetweenFirAndSecWith = context.getResources().getDimensionPixelSize( R.dimen.module_main_card_card_shadow_width_div );
|
||||
}
|
||||
|
||||
public VerticalStackTransformer( Context context, int spaceBetweenFirAndSecWith, int spaceBetweenFirAndSecHeight ) {
|
||||
this.context = context;
|
||||
this.spaceBetweenFirAndSecWith = spaceBetweenFirAndSecWith;
|
||||
this.spaceBetweenFirAndSecHeight = spaceBetweenFirAndSecHeight;
|
||||
}
|
||||
|
||||
public void offsetScrollChanged(float offset){
|
||||
if(offset ==0){
|
||||
return;
|
||||
}
|
||||
offsetScroll = offset;
|
||||
}
|
||||
|
||||
public void resetOffsetScroll(){
|
||||
offsetScroll = 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTransform( View page, float position ) {
|
||||
if ( position == 0.0f ) {
|
||||
page.setAlpha( 1.0f );
|
||||
page.setTranslationY( 0f );
|
||||
//控制停止滑动切换的时候,只有最上面的一张卡片可以点击
|
||||
page.setClickable( true );
|
||||
} else if(position>0){
|
||||
float scale = ( float ) ( page.getWidth() - spaceBetweenFirAndSecWith * position ) / ( float ) ( page.getWidth() );
|
||||
Logger.d("VerticalStackTransformer","scale :" + scale);
|
||||
//控制下面卡片的可见度
|
||||
page.setAlpha( 1.0f );
|
||||
//控制停止滑动切换的时候,只有最上面的一张卡片可以点击
|
||||
page.setClickable( false );
|
||||
page.setPivotX( page.getWidth() / 2f );
|
||||
page.setPivotY( page.getHeight() / 2f );
|
||||
page.setScaleX( scale );
|
||||
page.setScaleY( scale );
|
||||
page.setTranslationY( -page.getHeight() * position + ( page.getHeight() * 0.5f ) * ( 1 - scale ) + spaceBetweenFirAndSecHeight * position );
|
||||
}else{
|
||||
float currentPage;
|
||||
if(offsetScroll > 0.2f){
|
||||
currentPage = 0.2f;
|
||||
}else{
|
||||
currentPage = offsetScroll;
|
||||
}
|
||||
page.setAlpha( 1 );
|
||||
page.setScaleX(1-currentPage);
|
||||
page.setScaleY(1-currentPage);
|
||||
page.setPivotX( page.getWidth() / 2f );
|
||||
page.setPivotY( page.getHeight() / 2f );
|
||||
page.setTranslationY( 0f );
|
||||
page.setClickable( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.mogo.module.main.constants;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
* 2020-03-02.
|
||||
*/
|
||||
public class VoiceConstants {
|
||||
/**
|
||||
* 切换上一张卡片
|
||||
*/
|
||||
public static final String COMMAND_ZHIDAO_SWITCHCARD_PREVIOUS = "com.zhidao.desk.switchCard.previous";
|
||||
/**
|
||||
* 切换下一张卡片
|
||||
*/
|
||||
public static final String COMMAND_ZHIDAO_SWITCHCARD_NEXT = "com.zhidao.desk.switchCard.next";
|
||||
/**
|
||||
* 查看多媒体卡片、探路卡片
|
||||
*/
|
||||
public static final String COMMAND_ZHIDAO_SWITCHCARD = "com.zhidao.desk.switchCard";
|
||||
|
||||
|
||||
|
||||
public static ArrayList<String> sCmds=new ArrayList<>();
|
||||
|
||||
static {
|
||||
sCmds.add(COMMAND_ZHIDAO_SWITCHCARD_PREVIOUS);
|
||||
sCmds.add(COMMAND_ZHIDAO_SWITCHCARD_NEXT);
|
||||
sCmds.add(COMMAND_ZHIDAO_SWITCHCARD);
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.mogo.module.main.livedata;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-09
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class CardInfo implements Parcelable {
|
||||
|
||||
public String mCardName;
|
||||
public boolean mLockCar;
|
||||
|
||||
public CardInfo( String cardName, boolean lockCar ) {
|
||||
this.mCardName = cardName;
|
||||
this.mLockCar = lockCar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel( Parcel dest, int flags ) {
|
||||
dest.writeString( this.mCardName );
|
||||
dest.writeByte( this.mLockCar ? ( byte ) 1 : ( byte ) 0 );
|
||||
}
|
||||
|
||||
protected CardInfo( Parcel in ) {
|
||||
this.mCardName = in.readString();
|
||||
this.mLockCar = in.readByte() != 0;
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator< CardInfo > CREATOR = new Parcelable.Creator< CardInfo >() {
|
||||
@Override
|
||||
public CardInfo createFromParcel( Parcel source ) {
|
||||
return new CardInfo( source );
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardInfo[] newArray( int size ) {
|
||||
return new CardInfo[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.mogo.module.main.livedata;
|
||||
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-06
|
||||
* <p>
|
||||
* 切换卡片
|
||||
*/
|
||||
public class CardSwitchLiveData extends MutableLiveData< CardInfo > {
|
||||
|
||||
private CardSwitchLiveData() {
|
||||
// private constructor
|
||||
}
|
||||
|
||||
private static final class InstanceHolder {
|
||||
private static final CardSwitchLiveData INSTANCE = new CardSwitchLiveData();
|
||||
}
|
||||
|
||||
public static CardSwitchLiveData getInstance() {
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.mogo.module.main.windowview;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* 用来处理主屏上方1/2屏的view
|
||||
*/
|
||||
public class TopViewHolder {
|
||||
public void init(){
|
||||
|
||||
}
|
||||
public void addView(View view) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@ import com.mogo.module.service.marker.MapMarkerManager;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.adas.IMogoADASController;
|
||||
import com.mogo.service.analytics.IMogoAnalytics;
|
||||
import com.mogo.service.cardmanager.IMogoCardManager;
|
||||
import com.mogo.service.connection.IMogoSocketManager;
|
||||
import com.mogo.service.datamanager.IMogoDataManager;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
@@ -51,7 +50,6 @@ public class MarkerServiceHandler {
|
||||
private static IMogoStatusManager sMogoStatusManager;
|
||||
private static IMogoImageloader sImageloader;
|
||||
private static IMogoSocketManager sMogoSocketManager;
|
||||
private static IMogoCardManager sMogoCardManager;
|
||||
private static IMogoAnalytics sMogoAnalytics;
|
||||
private static IMogoRegisterCenter sRegisterCenter;
|
||||
private static IMogoActionManager sActionManager;
|
||||
@@ -74,7 +72,6 @@ public class MarkerServiceHandler {
|
||||
sImageloader = sApis.getImageLoaderApi();
|
||||
sMogoStatusManager = sApis.getStatusManagerApi();
|
||||
sMogoSocketManager = sApis.getSocketManagerApi( context );
|
||||
sMogoCardManager = sApis.getCardManagerApi();
|
||||
sMogoAnalytics = sApis.getAnalyticsApi();
|
||||
sMarkerManager = sMapService.getMarkerManager( context );
|
||||
sNavi = sMapService.getNavi( context );
|
||||
@@ -127,10 +124,6 @@ public class MarkerServiceHandler {
|
||||
return sMogoStatusManager;
|
||||
}
|
||||
|
||||
public static IMogoCardManager getMogoCardManager() {
|
||||
return sMogoCardManager;
|
||||
}
|
||||
|
||||
public static IMogoAnalytics getMogoAnalytics() {
|
||||
return sMogoAnalytics;
|
||||
}
|
||||
|
||||
@@ -131,8 +131,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
|
||||
private IMogoMapUIController mUiController;
|
||||
|
||||
private IMogoCardManager mCardManager;
|
||||
|
||||
/**
|
||||
* 是否已计算出地图显示状态
|
||||
*/
|
||||
@@ -416,7 +414,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
mADASController = MarkerServiceHandler.getADASController();
|
||||
mLauncher = MarkerServiceHandler.getLauncher();
|
||||
mFragmentManager = MarkerServiceHandler.getFragmentManager();
|
||||
mCardManager = MarkerServiceHandler.getMogoCardManager();
|
||||
|
||||
mFragmentManager.addMainFragmentStackTransactionListener( this );
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ public class IntentHandlerFactory {
|
||||
private IntentHandlerFactory() {
|
||||
// private constructor
|
||||
mHandlers.put( MogoReceiver.ACTION_MOCK, new MockIntentHandler() );
|
||||
mHandlers.put( ServiceConst.COMMAND_SWITCH_CARD, new SwitchCardIntentHandler() );
|
||||
mHandlers.put( ServiceConst.COMMAND_OPERATION, new AppOperationIntentHandler() );
|
||||
mHandlers.put( ServiceConst.COMMAND_MY_LOCATION, new MyLocationHandler() );
|
||||
mHandlers.put( ServiceConst.COMMAND_ZHIDAO_NEARBY_CAR_ONLINE, OnlineCarSearchIntentHandler.getInstance() );
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
package com.mogo.module.service.intent;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
import com.mogo.utils.AppUtils;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-04-17
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class SwitchCardIntentHandler implements IntentHandler {
|
||||
|
||||
@Override
|
||||
public void handle( Context context, Intent intent ) {
|
||||
String data = intent.getStringExtra( "data" );
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject( data );
|
||||
String card = jsonObject.getString( "card" );
|
||||
if ( TextUtils.equals( "多媒体卡片", card )
|
||||
|| TextUtils.equals( "媒体中心卡片", card )
|
||||
|| TextUtils.equals( "音乐卡片", card ) ) {
|
||||
switchCard2( context, ServiceConst.CARD_TYPE_SHARE_MUSIC );
|
||||
} else if ( TextUtils.equals( "探路卡片", card ) ) {
|
||||
switchCard2( context, ServiceConst.CARD_TYPE_ROAD_CONDITION );
|
||||
} else if ( TextUtils.equals( "在线车辆卡片", card ) ) {
|
||||
switchCard2( context, ServiceConst.CARD_TYPE_USER_DATA );
|
||||
} else if ( TextUtils.equals( "新鲜事卡片", card ) ) {
|
||||
switchCard2( context, ServiceConst.CARD_TYPE_NOVELTY );
|
||||
}
|
||||
} catch ( JSONException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换卡片
|
||||
*/
|
||||
public static void switchCard2( Context context, String card ) {
|
||||
if ( AppUtils.isApplicationBroughtToBackground( context ) ) {
|
||||
MarkerServiceHandler.getLauncher().backToLauncher( context );
|
||||
UiThreadHandler.postDelayed( () -> {
|
||||
if ( MarkerServiceHandler.getMogoStatusManager().isADASShow() ) {
|
||||
MarkerServiceHandler.getADASController().closeADAS();
|
||||
}
|
||||
MarkerServiceHandler.getMogoCardManager().switch2( card, true );
|
||||
}, 2000L );
|
||||
} else {
|
||||
MarkerServiceHandler.getFragmentManager().clearAll();
|
||||
if ( MarkerServiceHandler.getMogoStatusManager().isADASShow() ) {
|
||||
MarkerServiceHandler.getADASController().closeADAS();
|
||||
}
|
||||
MarkerServiceHandler.getMogoCardManager().switch2( card, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,6 +59,7 @@ public interface IMogoServiceApis extends IProvider {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
IMogoCardManager getCardManagerApi();
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
* <p>
|
||||
* 卡片管理
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IMogoCardManager extends IProvider {
|
||||
|
||||
/**
|
||||
|
||||
@@ -113,6 +113,7 @@ public class MogoServiceApis implements IMogoServiceApis {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public synchronized IMogoCardManager getCardManagerApi() {
|
||||
return getApiInstance( IMogoCardManager.class, MogoServicePaths.PATH_CARD_MANAGER );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user