opt
This commit is contained in:
@@ -25,6 +25,8 @@ import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.module.common.MogoModule;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.main.assist.MapBroadCastHelper;
|
||||
import com.mogo.module.main.cards.CardIntroduceConfig;
|
||||
import com.mogo.module.main.cards.CardIntroduceConfigs;
|
||||
import com.mogo.module.main.cards.CardModulesAdapter;
|
||||
import com.mogo.module.main.cards.HorizentalStackTransformer;
|
||||
import com.mogo.module.main.cards.MogoModulesHandler;
|
||||
@@ -198,7 +200,8 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
mCardCoverUpBottomLayout = findViewById( R.id.module_main_id_card_cover_up_bottom );
|
||||
|
||||
// 避免事件穿透导致地图被滑动
|
||||
mLeftShadowFrame.setOnClickListener( view -> {} );
|
||||
mLeftShadowFrame.setOnClickListener( view -> {
|
||||
} );
|
||||
WindowViewHandler.init( mFloatingLayout );
|
||||
}
|
||||
|
||||
@@ -378,6 +381,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
MapBroadCastHelper.getInstance( this ).mapBackground();
|
||||
super.onPause();
|
||||
mMogoStatusManager.setMainPageResumeStatus( TAG, false );
|
||||
CardIntroduceConfigs.flush( getApplicationContext() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import com.mogo.module.common.ModuleNames;
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.commons.voice.VoicePreemptType;
|
||||
import com.mogo.module.common.ModuleNames;
|
||||
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;
|
||||
@@ -14,34 +24,66 @@ import java.util.Map;
|
||||
*/
|
||||
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<>();
|
||||
|
||||
static {
|
||||
sConfigs.put( ModuleNames.CARD_TYPE_BUSINESS_OPERATION, new CardIntroduceConfig( ModuleNames.CARD_TYPE_BUSINESS_OPERATION, "随时查看路况,可以对我说某某地点堵不堵", 0 ) );
|
||||
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 ) );
|
||||
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 CardIntroduceConfig getConfig( String type ) {
|
||||
return sConfigs.get( type );
|
||||
}
|
||||
public static void init( Context context ) {
|
||||
|
||||
public static void init( List< CardIntroduceConfig > configs ) {
|
||||
if ( configs == null ) {
|
||||
return;
|
||||
}
|
||||
for ( CardIntroduceConfig config : configs ) {
|
||||
if ( config == null ) {
|
||||
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;
|
||||
}
|
||||
sConfigs.put( config.cardType, config );
|
||||
}
|
||||
for ( CardIntroduceConfig config : configs ) {
|
||||
if ( config == null ) {
|
||||
return;
|
||||
}
|
||||
sConfigs.put( config.cardType, config );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
public static void increase( String type ) {
|
||||
|
||||
public static void broadcast( 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 broadcast %s cast amount = %s", type, type );
|
||||
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 ) );
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class MogoModulesManager implements MogoModulesHandler,
|
||||
|
||||
private static final String TAG = "MogoModulesManager";
|
||||
|
||||
public static final String KEY_VOICE_BROADCAST_CONFIG = "voice_broadcast_";
|
||||
|
||||
private String mBroadcastConfigKey;
|
||||
|
||||
private MainActivity mActivity;
|
||||
@@ -97,13 +97,7 @@ public class MogoModulesManager implements MogoModulesHandler,
|
||||
mMogoIntentManager = apis.getIntentManagerApi();
|
||||
|
||||
registerReceiver();
|
||||
|
||||
WorkThreadHandler.getInstance().post( () -> {
|
||||
mBroadcastConfigKey = KEY_VOICE_BROADCAST_CONFIG + CommonUtils.getVersionCode( mActivity );
|
||||
String configsStr = SharedPrefsMgr.getInstance( mActivity ).getString( mBroadcastConfigKey );
|
||||
List< CardIntroduceConfig > configs = GsonUtil.arrayFromJson( configsStr, CardIntroduceConfig.class );
|
||||
CardIntroduceConfigs.init( configs );
|
||||
} );
|
||||
CardIntroduceConfigs.init( getContext() );
|
||||
}
|
||||
|
||||
private Context getContext() {
|
||||
@@ -288,6 +282,8 @@ public class MogoModulesManager implements MogoModulesHandler,
|
||||
mSortedCards.add( 0, mEnableModuleName );
|
||||
SharedPrefsMgr.getInstance( getContext() ).putString( KEY_SORTED_CARD_MODULES, GsonUtil.jsonFromObject( mSortedCards ) );
|
||||
Log.i( TAG, "enable & disable card cost " + ( System.currentTimeMillis() - start1 ) + "ms" );
|
||||
|
||||
CardIntroduceConfigs.broadcast( mActivity, mEnableModuleName );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user