Merge branch 'dev' into demo/shunyi_v2v_merge
# Conflicts: # app/src/main/java/com/mogo/launcher/MogoApplication.java # config.gradle # foudations/mogo-commons/src/main/java/com/mogo/commons/debug/DebugConfig.java # modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java # modules/mogo-module-extensions/src/main/res/values-mdpi/dimens.xml # modules/mogo-module-extensions/src/main/res/values-xhdpi/dimens.xml # modules/mogo-module-extensions/src/main/res/values/dimens.xml # modules/mogo-module-media/src/main/java/com/mogo/module/media/window/MediaWindow2.java # modules/mogo-module-v2x/src/main/res/layout/item_v2x_fault_help.xml # modules/mogo-module-v2x/src/main/res/values-xhdpi/dimens.xml # modules/mogo-module-v2x/src/main/res/values/dimens.xml # services/mogo-service-api/src/main/java/com/mogo/service/IMogoServiceApis.java # services/mogo-service/src/main/java/com/mogo/service/impl/MogoServiceApis.java # upload.sh
This commit is contained in:
@@ -7,6 +7,7 @@ import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.context.ContextHolderUtil;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.mvp.MvpActivity;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
@@ -16,6 +17,7 @@ import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.map.MapCenterPointStrategy;
|
||||
import com.mogo.module.common.map.Scene;
|
||||
import com.mogo.module.main.cards.MogoModulesManager;
|
||||
@@ -109,6 +111,8 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
mLeftShadowFrame.setOnClickListener( view -> {
|
||||
} );
|
||||
FloatingViewHandler.init( mFloatingLayout );
|
||||
|
||||
mServiceApis.getOnlineCarPanelApi().initContainer( R.id.module_main_id_message_history_fragment_container, this );
|
||||
}
|
||||
|
||||
// 隐藏布局
|
||||
@@ -130,15 +134,17 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
@Override
|
||||
protected void onCreate( @Nullable Bundle savedInstanceState ) {
|
||||
super.onCreate( savedInstanceState );
|
||||
ContextHolderUtil.holdContext(this);
|
||||
mPresenter.postLoadModuleMsg();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
if ( mServiceApis == null ) {
|
||||
mServiceApis = ( IMogoServiceApis ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation();
|
||||
mServiceApis = MogoApisHandler.getInstance().getApis();
|
||||
}
|
||||
mServiceApis.getShareManager().resetContext( this );
|
||||
mServiceApis.getAuthManagerApi().showAuth( this );
|
||||
|
||||
mMogoStatusManager = mServiceApis.getStatusManagerApi();
|
||||
mMogoStatusManager.setMainPageLaunchedStatus( TAG, true );
|
||||
AutopilotServiceManage.getInstance().init( getContext() );
|
||||
@@ -148,7 +154,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
public void loadModules() {
|
||||
final long start = System.currentTimeMillis();
|
||||
|
||||
MogoModulesManager.getInstance().init( this, getApis() );
|
||||
MogoModulesManager.getInstance().init( this );
|
||||
loadSplash();
|
||||
mMogoMapService = mServiceApis.getMapServiceApi();
|
||||
if ( mMogoMapService != null ) {
|
||||
@@ -327,7 +333,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
@Override
|
||||
public IMogoServiceApis getApis() {
|
||||
if ( mServiceApis == null ) {
|
||||
mServiceApis = ( IMogoServiceApis ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation();
|
||||
mServiceApis = MogoApisHandler.getInstance().getApis();
|
||||
}
|
||||
return mServiceApis;
|
||||
}
|
||||
@@ -335,9 +341,14 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mMogoMapService.getHostListenerRegister().unregisterMarkerClickListener();
|
||||
mMogoMapService.getHostListenerRegister().unregisterHostAimlessModeListener();
|
||||
mMogoMapService.getHostListenerRegister().unregisterHostNaviListener();
|
||||
mMogoMapService.getHostListenerRegister().unregisterHostMapListener();
|
||||
mMogoStatusManager.setMainPageLaunchedStatus( TAG, false );
|
||||
mMogoMapService = null;
|
||||
mMogoMapUIController = null;
|
||||
mMogoFragmentManager.unregisterMainFragmentStackTransactionListener();
|
||||
mMogoFragmentManager = null;
|
||||
mServiceApis.getMapServiceApi().getMapViewInstanceHandler().destroy();
|
||||
AdasConfigApiController.getInstance().release();
|
||||
@@ -345,5 +356,11 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
Logger.d( TAG, "destroy." );
|
||||
mServiceApis.getRefreshStrategyControllerApi().clearAllData();
|
||||
AIAssist.getInstance( this ).release();
|
||||
mServiceApis.getOnlineCarPanelApi().clear();
|
||||
ContextHolderUtil.releaseContext();
|
||||
MogoModulesManager.getInstance().onDestroy();
|
||||
SchemeIntent.getInstance().clear();
|
||||
FloatingViewHandler.clear();
|
||||
mServiceApis.getShareManager().releaseContext();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,15 +6,9 @@ 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.intent.IMogoIntentListener;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.utils.AppUtils;
|
||||
import com.mogo.utils.CommonUtils;
|
||||
import com.mogo.utils.TipToast;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
@@ -41,21 +35,41 @@ public class SchemeIntent implements IMogoStatusChangedListener {
|
||||
|
||||
public static final String TYPE_LAUNCH = "launch";
|
||||
|
||||
public static final String TYPE_SHOW_ONLINE_CAR_PANEL = "showOnlineCarPanel";
|
||||
|
||||
private IMogoServiceApis mApis;
|
||||
private Context mContext;
|
||||
|
||||
private Intent mNextIntent;
|
||||
private IntentWrapper mNextIntent;
|
||||
|
||||
private SchemeIntent() {
|
||||
// private constructor
|
||||
private static class IntentWrapper {
|
||||
public Intent mIntent;
|
||||
public long mDelay = 0L;
|
||||
|
||||
public IntentWrapper( Intent intent, long delay ) {
|
||||
this.mIntent = intent;
|
||||
this.mDelay = delay;
|
||||
}
|
||||
}
|
||||
|
||||
private static final class InstanceHolder {
|
||||
private static final SchemeIntent INSTANCE = new SchemeIntent();
|
||||
private static volatile SchemeIntent sInstance;
|
||||
|
||||
private SchemeIntent() {
|
||||
}
|
||||
|
||||
public static SchemeIntent getInstance() {
|
||||
return InstanceHolder.INSTANCE;
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( SchemeIntent.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new SchemeIntent();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
public void init( Context context, IMogoServiceApis apis ) {
|
||||
@@ -64,9 +78,11 @@ public class SchemeIntent implements IMogoStatusChangedListener {
|
||||
mApis.getStatusManagerApi().registerStatusChangedListener( TAG, StatusDescriptor.MAIN_PAGE_RESUME, this );
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return InstanceHolder.INSTANCE;
|
||||
public void clear() {
|
||||
mApis.getStatusManagerApi().unregisterStatusChangedListener( TAG, StatusDescriptor.MAIN_PAGE_RESUME, this );
|
||||
mContext = null;
|
||||
mApis = null;
|
||||
|
||||
}
|
||||
|
||||
public void handle( Intent intent ) {
|
||||
@@ -80,7 +96,11 @@ public class SchemeIntent implements IMogoStatusChangedListener {
|
||||
}
|
||||
|
||||
if ( !mApis.getStatusManagerApi().isMainPageOnResume() ) {
|
||||
mNextIntent = intent;
|
||||
long delay = 0L;
|
||||
if ( isNaviIntent( intent ) ) {
|
||||
delay = 2_000L;
|
||||
}
|
||||
mNextIntent = new IntentWrapper( intent, delay );
|
||||
mApis.getLauncherApi().backToLauncher( mContext );
|
||||
return;
|
||||
}
|
||||
@@ -104,20 +124,21 @@ public class SchemeIntent implements IMogoStatusChangedListener {
|
||||
mNextIntent = null;
|
||||
}
|
||||
|
||||
private boolean isNaviIntent( Intent intent ) {
|
||||
if ( intent == null || intent.getData() == null ) {
|
||||
return false;
|
||||
}
|
||||
Uri target = intent.getData();
|
||||
String type = target.getQueryParameter( "type" );
|
||||
return TextUtils.equals( TYPE_NAVI, type );
|
||||
}
|
||||
|
||||
private void handleSwitch2Action( Uri target ) {
|
||||
String type = target.getQueryParameter( "type" );
|
||||
if ( TextUtils.isEmpty( type ) ) {
|
||||
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;
|
||||
@@ -125,25 +146,23 @@ public class SchemeIntent implements IMogoStatusChangedListener {
|
||||
handleLaunchIntent( target );
|
||||
break;
|
||||
case TYPE_SEARCH_ROAD_CONDITION:
|
||||
handleSearchRoadCondition(target);
|
||||
handleSearchRoadCondition( target );
|
||||
break;
|
||||
case TYPE_SHOW_ONLINE_CAR_PANEL:
|
||||
handleShowOnlineCarPanel( target );
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void handleSearchRoadCondition(Uri target) {
|
||||
if (mApis == null) {
|
||||
private void handleSearchRoadCondition( Uri target ) {
|
||||
if ( mApis == null ) {
|
||||
return;
|
||||
}
|
||||
mApis.getTanluUiApi().searchRoadCondition(target.getQueryParameter("intentStr"),
|
||||
target.getQueryParameter("data"), target.getQueryParameter("city"),
|
||||
target.getQueryParameter("keywords"));
|
||||
}
|
||||
|
||||
private void handleSwitchCardIntent( String type ) {
|
||||
CardSwitchLiveData.getInstance().postValue( new CardInfo( type, true ) );
|
||||
mApis.getTanluUiApi().searchRoadCondition( target.getQueryParameter( "intentStr" ),
|
||||
target.getQueryParameter( "data" ), target.getQueryParameter( "city" ),
|
||||
target.getQueryParameter( "keywords" ) );
|
||||
}
|
||||
|
||||
private void handleNaviIntent( Uri naviUri ) {
|
||||
@@ -153,8 +172,6 @@ public class SchemeIntent implements IMogoStatusChangedListener {
|
||||
String lon = naviUri.getQueryParameter( "lon" );
|
||||
String lat = naviUri.getQueryParameter( "lat" );
|
||||
|
||||
// TODO: 2020-04-20 补充场景
|
||||
|
||||
try {
|
||||
double dlon = Double.valueOf( lon );
|
||||
double dlat = Double.valueOf( lat );
|
||||
@@ -178,14 +195,24 @@ public class SchemeIntent implements IMogoStatusChangedListener {
|
||||
mApis.getAnalyticsApi().track( "appenterfront", properties );
|
||||
}
|
||||
|
||||
private void handleShowOnlineCarPanel( Uri uri ) {
|
||||
mApis.getOnlineCarPanelApi().showPanel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged( StatusDescriptor descriptor, boolean isTrue ) {
|
||||
if ( descriptor == StatusDescriptor.MAIN_PAGE_RESUME ) {
|
||||
if ( mNextIntent == null ) {
|
||||
return;
|
||||
}
|
||||
if ( isTrue ) {
|
||||
// 保证回到桌面后在开始该规划路线。
|
||||
UiThreadHandler.postDelayed( () -> {
|
||||
handle( mNextIntent );
|
||||
}, 2_000L );
|
||||
if ( mNextIntent == null ) {
|
||||
return;
|
||||
}
|
||||
handle( mNextIntent.mIntent );
|
||||
}, mNextIntent.mDelay );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,13 +38,6 @@ public interface MogoModulesHandler {
|
||||
*/
|
||||
void loadAppsListModule( int containerId );
|
||||
|
||||
/**
|
||||
* 加载头部信息
|
||||
*
|
||||
* @param containerId
|
||||
*/
|
||||
void loadExtensionsModule( int containerId );
|
||||
|
||||
/**
|
||||
* 加载快捷操作
|
||||
*
|
||||
@@ -77,4 +70,9 @@ public interface MogoModulesHandler {
|
||||
* @param containerId
|
||||
*/
|
||||
void loadSplashModule(int containerId);
|
||||
|
||||
/**
|
||||
* 释放各个模块资源
|
||||
*/
|
||||
void onDestroy();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.alibaba.idst.nls.internal.utils.L;
|
||||
import com.mogo.module.common.MogoModule;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.extensions.ExtensionsModuleConst;
|
||||
@@ -16,6 +18,7 @@ import com.mogo.utils.ResourcesHelper;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -31,6 +34,7 @@ public class MogoModulesManager implements MogoModulesHandler {
|
||||
private static final String TAG = "MogoModulesManager";
|
||||
|
||||
private MainActivity mActivity;
|
||||
private Application mApp;
|
||||
|
||||
private Map< MogoModule, IMogoModuleProvider > mModuleProviders = new HashMap<>();
|
||||
// 空间换效率
|
||||
@@ -56,19 +60,20 @@ public class MogoModulesManager implements MogoModulesHandler {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
public void init( MainActivity activity, IMogoServiceApis apis ) {
|
||||
public void init( MainActivity activity ) {
|
||||
if ( activity == null ) {
|
||||
throw new NullPointerException( "activity can't be null." );
|
||||
}
|
||||
this.mActivity = activity;
|
||||
mApp = mActivity.getApplication();
|
||||
}
|
||||
|
||||
private Context getContext() {
|
||||
return mActivity;
|
||||
return getApplicationContext();
|
||||
}
|
||||
|
||||
private Context getApplicationContext() {
|
||||
return mActivity.getApplicationContext();
|
||||
return mApp;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -100,6 +105,7 @@ public class MogoModulesManager implements MogoModulesHandler {
|
||||
|
||||
@Override
|
||||
public void loadMapModule( int containerId ) {
|
||||
Logger.d( TAG, "loadMapModule" );
|
||||
IMogoModuleProvider provider = ( IMogoModuleProvider ) ARouter.getInstance()
|
||||
.build( MogoModulePaths.PATH_MODULE_MAP )
|
||||
.navigation( getContext() );
|
||||
@@ -114,14 +120,6 @@ public class MogoModulesManager implements MogoModulesHandler {
|
||||
addFragment( provider, containerId );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadExtensionsModule( int containerId ) {
|
||||
IMogoModuleProvider provider = ( IMogoModuleProvider ) ARouter.getInstance()
|
||||
.build( ExtensionsModuleConst.PATH_EXTENSION )
|
||||
.navigation( getContext() );
|
||||
addFragment( provider, containerId );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadEntrancesModule( int containerId ) {
|
||||
IMogoModuleProvider provider = ( IMogoModuleProvider ) ARouter.getInstance()
|
||||
@@ -131,25 +129,25 @@ public class MogoModulesManager implements MogoModulesHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadEventPanelModule(int containerId) {
|
||||
public void loadEventPanelModule( int containerId ) {
|
||||
IMogoModuleProvider provider = ( IMogoModuleProvider ) ARouter.getInstance()
|
||||
.build(MogoServicePaths.PATH_EVENT_PANEL)
|
||||
.build( MogoServicePaths.PATH_EVENT_PANEL )
|
||||
.navigation( getContext() );
|
||||
addFragment( provider, containerId );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadLeftPanelModule(int containerId) {
|
||||
public void loadLeftPanelModule( int containerId ) {
|
||||
IMogoModuleProvider provider = ( IMogoModuleProvider ) ARouter.getInstance()
|
||||
.build(MogoServicePaths.PATH_LEFT_PANEL)
|
||||
.build( MogoServicePaths.PATH_LEFT_PANEL )
|
||||
.navigation( getContext() );
|
||||
addFragment( provider, containerId );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadSplashModule(int containerId) {
|
||||
public void loadSplashModule( int containerId ) {
|
||||
IMogoModuleProvider provider = ( IMogoModuleProvider ) ARouter.getInstance()
|
||||
.build(MogoServicePaths.PATH_SPLASH)
|
||||
.build( MogoServicePaths.PATH_SPLASH )
|
||||
.navigation( getContext() );
|
||||
addFragment( provider, containerId );
|
||||
}
|
||||
@@ -179,7 +177,11 @@ public class MogoModulesManager implements MogoModulesHandler {
|
||||
Logger.e( TAG, "add fragment fail cause provider == null, container is %s", ResourcesHelper.getResNameById( getApplicationContext(), containerId ) );
|
||||
return;
|
||||
}
|
||||
final Fragment fragment = provider.createFragment( getContext(), null );
|
||||
Fragment fragment = null;
|
||||
fragment = mActivity.getSupportFragmentManager().findFragmentByTag( provider.getModuleName() );
|
||||
if ( fragment == null ) {
|
||||
fragment = provider.createFragment( getContext(), null );
|
||||
}
|
||||
if ( fragment == null ) {
|
||||
Logger.e( TAG, "add fragment fail cause fragment == null, container is %s", ResourcesHelper.getResNameById( getApplicationContext(), containerId ) );
|
||||
return;
|
||||
@@ -188,4 +190,26 @@ public class MogoModulesManager implements MogoModulesHandler {
|
||||
.replace( containerId, fragment, provider.getModuleName() )
|
||||
.commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if ( mModuleNameProviders != null ) {
|
||||
Collection< IMogoModuleProvider > modules = mModuleNameProviders.values();
|
||||
if ( modules != null ) {
|
||||
for ( IMogoModuleProvider module : modules ) {
|
||||
try {
|
||||
Logger.d( TAG, "destroy module: " + module.getModuleName() );
|
||||
module.onDestroy();
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "onDestroy" );
|
||||
}
|
||||
}
|
||||
}
|
||||
mModuleNameProviders.clear();
|
||||
}
|
||||
if ( mModuleProviders != null ) {
|
||||
mModuleProviders.clear();
|
||||
}
|
||||
mActivity = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import com.mogo.service.module.IMogoRegisterCenter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -28,7 +29,7 @@ public class MogoRegisterCenterHandler implements IMogoRegisterCenter {
|
||||
|
||||
private Map< String, IMogoModuleLifecycle > mLifecycle = new HashMap<>();
|
||||
private Map< String, IMogoMapListener > mMap = new HashMap<>();
|
||||
private Map< String, IMogoNaviListener > mNavi = new HashMap<>();
|
||||
private Map< String, IMogoNaviListener > mNavi = new ConcurrentHashMap<>();
|
||||
private Map< String, IMogoLocationListener > mLocation = new HashMap<>();
|
||||
private Map< String, IMogoMarkerClickListener > mMarker = new HashMap<>();
|
||||
private Map< String, IMogoAimlessModeListener > mAimless = new HashMap<>();
|
||||
|
||||
@@ -7,15 +7,14 @@ import android.os.IBinder;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.main.EventDispatchCenter;
|
||||
import com.mogo.module.main.cards.MogoModulesManager;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
@@ -26,7 +25,7 @@ public
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
@Route(path = "/service/base/info")
|
||||
@Route( path = "/service/base/info" )
|
||||
class MogoMainService extends Service implements IMogoLocationListener {
|
||||
|
||||
private static final String TAG = "MogoMainService";
|
||||
@@ -39,10 +38,10 @@ class MogoMainService extends Service implements IMogoLocationListener {
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
Logger.d(TAG, "基本服务启动");
|
||||
mServiceApis = (IMogoServiceApis) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation();
|
||||
Logger.d( TAG, "基本服务启动" );
|
||||
mServiceApis = MogoApisHandler.getInstance().getApis();
|
||||
initAndStartLocation();
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
UiThreadHandler.postDelayed( () -> {
|
||||
loadBaseModules();
|
||||
startTanluService();
|
||||
initADAS();
|
||||
@@ -53,53 +52,53 @@ class MogoMainService extends Service implements IMogoLocationListener {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
public IBinder onBind( Intent intent ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
public int onStartCommand( Intent intent, int flags, int startId ) {
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
private void initAndStartLocation() {
|
||||
Logger.d(TAG, "开始定位");
|
||||
mLocationClient = mServiceApis.getMapServiceApi().getSingletonLocationClient(AbsMogoApplication.getApp());
|
||||
mLocationClient.addLocationListener(this);
|
||||
mLocationClient.start(2_000L);
|
||||
Logger.d( TAG, "开始定位" );
|
||||
mLocationClient = mServiceApis.getMapServiceApi().getSingletonLocationClient( AbsMogoApplication.getApp() );
|
||||
mLocationClient.addLocationListener( this );
|
||||
mLocationClient.start( 2_000L );
|
||||
}
|
||||
|
||||
private void initGpsSimulatorListener() {
|
||||
mServiceApis.getMapServiceApi().getNavi(this).registerCarLocationChangedListener(EventDispatchCenter.getInstance());
|
||||
mServiceApis.getMapServiceApi().getNavi( this ).registerCarLocationChangedListener( EventDispatchCenter.getInstance() );
|
||||
}
|
||||
|
||||
private void loadBaseModules() {
|
||||
Logger.d(TAG, "加载基本模块");
|
||||
Logger.d( TAG, "加载基本模块" );
|
||||
MogoModulesManager.getInstance().loadBaseModule();
|
||||
}
|
||||
|
||||
private void startTanluService() {
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
Logger.d(TAG, "startTanluService ---------- ");
|
||||
UiThreadHandler.postDelayed( () -> {
|
||||
Logger.d( TAG, "startTanluService ---------- " );
|
||||
mServiceApis.getTanluApi().startTanluService();
|
||||
}, 2_000L
|
||||
);
|
||||
}
|
||||
|
||||
private void initADAS() {
|
||||
mServiceApis.getAdasControllerApi().init(AbsMogoApplication.getApp());
|
||||
mServiceApis.getAdasControllerApi().init( AbsMogoApplication.getApp() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(MogoLocation location) {
|
||||
EventDispatchCenter.getInstance().onLocationChanged(location);
|
||||
public void onLocationChanged( MogoLocation location ) {
|
||||
EventDispatchCenter.getInstance().onLocationChanged( location );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (mLocationClient != null) {
|
||||
mLocationClient.removeLocationListener(this);
|
||||
if ( mLocationClient != null ) {
|
||||
mLocationClient.removeLocationListener( this );
|
||||
mLocationClient.stop();
|
||||
mLocationClient.destroy();
|
||||
mLocationClient = null;
|
||||
|
||||
@@ -41,6 +41,10 @@ public class FloatingViewHandler {
|
||||
sFloatingLayout = frameLayout;
|
||||
}
|
||||
|
||||
public static void clear(){
|
||||
sFloatingLayout = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加任意view到布局,不考虑优先级
|
||||
*
|
||||
|
||||
@@ -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,7 @@
|
||||
<dimen name="cards_container_shadow_dp_margin_top">319px</dimen>
|
||||
|
||||
<dimen name="module_main_apps_fragment_container_width">110px</dimen>
|
||||
<dimen name="module_main_apps_fragment_container_padding">10px</dimen>
|
||||
<dimen name="module_main_apps_fragment_container_padding">6px</dimen>
|
||||
<dimen name="module_main_header_fragment_container_marginTop">15px</dimen>
|
||||
<dimen name="module_main_header_fragment_container_marginLeft">460px</dimen>
|
||||
<dimen name="module_main_id_entrance_fragment_container_marginLeft">444px</dimen>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<dimen name="cards_container_shadow_dp_margin_top">319px</dimen>
|
||||
|
||||
<dimen name="module_main_apps_fragment_container_width">110px</dimen>
|
||||
<dimen name="module_main_apps_fragment_container_padding">10px</dimen>
|
||||
<dimen name="module_main_apps_fragment_container_padding">6px</dimen>
|
||||
<dimen name="module_main_header_fragment_container_marginTop">15px</dimen>
|
||||
<dimen name="module_main_header_fragment_container_marginLeft">460px</dimen>
|
||||
<dimen name="module_main_id_entrance_fragment_container_marginLeft">444px</dimen>
|
||||
@@ -26,6 +26,6 @@
|
||||
<dimen name="module_main_entrance_fragment_container_padding_top">16px</dimen>
|
||||
<dimen name="module_main_entrance_fragment_container_width">658px</dimen>
|
||||
<dimen name="module_event_fragment_container_padding">8px</dimen>
|
||||
<dimen name="module_main_apps_fragment_container_paddingTop">10px</dimen>
|
||||
<dimen name="module_main_apps_fragment_container_paddingTop">2px</dimen>
|
||||
|
||||
</resources>
|
||||
Reference in New Issue
Block a user