1. 小智动画切换逻辑修改
2. 独立app卡片刷新次数限制 3. 其他优化
This commit is contained in:
@@ -13,6 +13,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.module.apps.adapter.AppIndicatorAdapter;
|
||||
import com.mogo.module.apps.anim.AnimRes;
|
||||
import com.mogo.module.apps.anim.AnimWrapper;
|
||||
import com.mogo.module.apps.applaunch.AppLauncher;
|
||||
import com.mogo.module.apps.applaunch.BaseAppLauncher;
|
||||
@@ -45,7 +46,7 @@ public class AppNavigatorFragment extends MvpFragment< AppNavigatorView, AppNavi
|
||||
|
||||
private ImageView mAIAssist;
|
||||
private View mAIAssistContainer;
|
||||
private AnimWrapper mAnim = new AnimWrapper();
|
||||
private AnimWrapper mAnim;
|
||||
|
||||
private BaseAppLauncher mLauncher;
|
||||
|
||||
@@ -71,7 +72,13 @@ public class AppNavigatorFragment extends MvpFragment< AppNavigatorView, AppNavi
|
||||
|
||||
mAIAssistContainer = findViewById( R.id.module_apps_id_ai_assist_container );
|
||||
mAIAssist = findViewById( R.id.module_apps_id_ai_assist );
|
||||
mAnim.initAnim( mAIAssist );
|
||||
|
||||
mAnim = new AnimWrapper( mAIAssist );
|
||||
boolean naviStatus = AppServiceHandler.getApis().getMapServiceApi().getNavi( getContext() ).isNaviing();
|
||||
if ( naviStatus ) {
|
||||
setCurrentXiaoZhiEmoji( AnimRes.EmojiType.Navigation );
|
||||
}
|
||||
|
||||
mAIAssist.setOnClickListener( new OnAiAssistClickListener() );
|
||||
mAIAssistContainer.setOnClickListener( view -> {
|
||||
mAIAssist.performClick();
|
||||
@@ -100,6 +107,16 @@ public class AppNavigatorFragment extends MvpFragment< AppNavigatorView, AppNavi
|
||||
mAppIndicatorAdapter.setDatas( NavigatorApps.getApps() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentXiaoZhiEmoji( AnimRes.EmojiType type ) {
|
||||
boolean started = mAnim.isStarted();
|
||||
mAnim.stop();
|
||||
mAnim.setCurrentAnim( type );
|
||||
if ( started ) {
|
||||
mAnim.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
@@ -157,6 +174,9 @@ public class AppNavigatorFragment extends MvpFragment< AppNavigatorView, AppNavi
|
||||
if ( mPresenter != null ) {
|
||||
mPresenter.onDestroy( getViewLifecycleOwner() );
|
||||
}
|
||||
if ( mAnim != null ) {
|
||||
mAnim.release();
|
||||
}
|
||||
AppServiceHandler.getApis().getFragmentManagerApi().removeMainFragmentStackTransactionListener( this );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,11 @@ import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
|
||||
import com.mogo.map.navi.IMogoNaviListener2;
|
||||
import com.mogo.module.apps.anim.AnimRes;
|
||||
import com.mogo.module.apps.model.AppsModel;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.utils.LaunchUtils;
|
||||
import com.mogo.utils.TipToast;
|
||||
|
||||
@@ -26,7 +29,8 @@ import org.json.JSONObject;
|
||||
*/
|
||||
public class AppNavigatorPresenter extends Presenter< AppNavigatorView > implements IMogoIntentListener,
|
||||
IMogoVoiceCmdCallBack,
|
||||
IMogoNaviListener2 {
|
||||
IMogoNaviListener2,
|
||||
IMogoStatusChangedListener {
|
||||
|
||||
private static final String TAG = "AppNavigatorPresenter";
|
||||
|
||||
@@ -42,6 +46,7 @@ public class AppNavigatorPresenter extends Presenter< AppNavigatorView > impleme
|
||||
// 预加载应用列表,空间换时间
|
||||
AppsModel.getInstance( getContext() ).load( null );
|
||||
}
|
||||
AppServiceHandler.getApis().getStatusManagerApi().registerStatusChangedListener( TAG, StatusDescriptor.MEDIA_PLAYER_STATUS, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -117,15 +122,38 @@ public class AppNavigatorPresenter extends Presenter< AppNavigatorView > impleme
|
||||
super.onDestroy( owner );
|
||||
AppServiceHandler.getApis().getRegisterCenterApi().unregisterMogoNaviListener( TAG );
|
||||
AppServiceHandler.getApis().getIntentManagerApi().unregisterIntentListener( AppsConst.COMMAND_OPERATION, this );
|
||||
AppServiceHandler.getApis().getStatusManagerApi().unregisterStatusChangedListener( TAG, StatusDescriptor.MEDIA_PLAYER_STATUS, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartNavi() {
|
||||
mView.hideNavigationEntrance();
|
||||
mView.setCurrentXiaoZhiEmoji( AnimRes.EmojiType.Navigation );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopNavi() {
|
||||
mView.showNavigationEntrance();
|
||||
if ( AppServiceHandler.getApis().getStatusManagerApi().isMediaPlaying() ) {
|
||||
mView.setCurrentXiaoZhiEmoji( AnimRes.EmojiType.Music );
|
||||
} else {
|
||||
mView.setCurrentXiaoZhiEmoji( AnimRes.EmojiType.Others );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged( StatusDescriptor descriptor, boolean isTrue ) {
|
||||
if ( descriptor != StatusDescriptor.MEDIA_PLAYER_STATUS ) {
|
||||
return;
|
||||
}
|
||||
if ( AppServiceHandler.getApis().getMapServiceApi().getNavi( getContext() ).isNaviing() ) {
|
||||
// 导航优先级更高
|
||||
return;
|
||||
}
|
||||
if ( isTrue ) {
|
||||
mView.setCurrentXiaoZhiEmoji( AnimRes.EmojiType.Music );
|
||||
} else {
|
||||
mView.setCurrentXiaoZhiEmoji( AnimRes.EmojiType.Others );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mogo.module.apps;
|
||||
|
||||
|
||||
import com.mogo.commons.mvp.IView;
|
||||
import com.mogo.module.apps.anim.AnimRes;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -19,4 +20,11 @@ public interface AppNavigatorView extends IView {
|
||||
void hideNavigationEntrance();
|
||||
|
||||
void showNavigationEntrance();
|
||||
|
||||
/**
|
||||
* 设置当前小智形象表情
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
void setCurrentXiaoZhiEmoji( AnimRes.EmojiType type );
|
||||
}
|
||||
|
||||
@@ -11,4 +11,8 @@ public interface Anim {
|
||||
void start();
|
||||
|
||||
void stop();
|
||||
|
||||
void setCurrentAnim( AnimRes.EmojiType type );
|
||||
|
||||
void release();
|
||||
}
|
||||
|
||||
@@ -11,7 +11,21 @@ import com.mogo.module.apps.R;
|
||||
*/
|
||||
public class AnimRes {
|
||||
|
||||
public static final int sRes[] = {
|
||||
public enum EmojiType {
|
||||
Navigation,
|
||||
Music,
|
||||
Others
|
||||
}
|
||||
|
||||
public static final int sNavigation[] = {
|
||||
|
||||
};
|
||||
|
||||
public static final int sMusic[] = {
|
||||
|
||||
};
|
||||
|
||||
public static final int sAll[][] = new int[][]{{
|
||||
R.drawable.mogo_tts_icon_00000,
|
||||
R.drawable.mogo_tts_icon_00001,
|
||||
R.drawable.mogo_tts_icon_00002,
|
||||
@@ -23,7 +37,8 @@ public class AnimRes {
|
||||
R.drawable.mogo_tts_icon_00008,
|
||||
R.drawable.mogo_tts_icon_00009,
|
||||
R.drawable.mogo_tts_icon_00010,
|
||||
R.drawable.mogo_tts_icon_00011,
|
||||
R.drawable.mogo_tts_icon_00011
|
||||
}, {
|
||||
R.drawable.mogo_tts_icon_00012,
|
||||
R.drawable.mogo_tts_icon_00013,
|
||||
R.drawable.mogo_tts_icon_00014,
|
||||
@@ -35,7 +50,8 @@ public class AnimRes {
|
||||
R.drawable.mogo_tts_icon_00020,
|
||||
R.drawable.mogo_tts_icon_00021,
|
||||
R.drawable.mogo_tts_icon_00022,
|
||||
R.drawable.mogo_tts_icon_00023,
|
||||
R.drawable.mogo_tts_icon_00023
|
||||
}, {
|
||||
R.drawable.mogo_tts_icon_00024,
|
||||
R.drawable.mogo_tts_icon_00025,
|
||||
R.drawable.mogo_tts_icon_00026,
|
||||
@@ -47,7 +63,8 @@ public class AnimRes {
|
||||
R.drawable.mogo_tts_icon_00032,
|
||||
R.drawable.mogo_tts_icon_00033,
|
||||
R.drawable.mogo_tts_icon_00034,
|
||||
R.drawable.mogo_tts_icon_00035,
|
||||
R.drawable.mogo_tts_icon_00035
|
||||
}, {
|
||||
R.drawable.mogo_tts_icon_00036,
|
||||
R.drawable.mogo_tts_icon_00037,
|
||||
R.drawable.mogo_tts_icon_00038,
|
||||
@@ -59,7 +76,8 @@ public class AnimRes {
|
||||
R.drawable.mogo_tts_icon_00044,
|
||||
R.drawable.mogo_tts_icon_00045,
|
||||
R.drawable.mogo_tts_icon_00046,
|
||||
R.drawable.mogo_tts_icon_00047,
|
||||
R.drawable.mogo_tts_icon_00047
|
||||
}, {
|
||||
R.drawable.mogo_tts_icon_00048,
|
||||
R.drawable.mogo_tts_icon_00049,
|
||||
R.drawable.mogo_tts_icon_00050,
|
||||
@@ -71,7 +89,8 @@ public class AnimRes {
|
||||
R.drawable.mogo_tts_icon_00056,
|
||||
R.drawable.mogo_tts_icon_00057,
|
||||
R.drawable.mogo_tts_icon_00058,
|
||||
R.drawable.mogo_tts_icon_00059,
|
||||
R.drawable.mogo_tts_icon_00059
|
||||
}, {
|
||||
R.drawable.mogo_tts_icon_00060,
|
||||
R.drawable.mogo_tts_icon_00061,
|
||||
R.drawable.mogo_tts_icon_00062,
|
||||
@@ -80,5 +99,7 @@ public class AnimRes {
|
||||
R.drawable.mogo_tts_icon_00065,
|
||||
R.drawable.mogo_tts_icon_00066,
|
||||
R.drawable.mogo_tts_icon_00067
|
||||
};
|
||||
}};
|
||||
|
||||
public static int sRes[] = sAll[0];
|
||||
}
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
package com.mogo.module.apps.anim;
|
||||
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.mogo.module.apps.R;
|
||||
import com.mogo.module.common.utils.CarSeries;
|
||||
import com.mogo.utils.ThreadPoolService;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
/**
|
||||
@@ -18,20 +14,14 @@ import com.mogo.utils.logger.Logger;
|
||||
public class AnimWrapper implements Anim {
|
||||
|
||||
private static final String TAG = "AnimWrapper";
|
||||
private ImageView mTarget;
|
||||
private Anim mDelegate;
|
||||
private boolean mIsStarted = false;
|
||||
|
||||
public AnimWrapper() {
|
||||
}
|
||||
|
||||
public void initAnim( ImageView target ) {
|
||||
mTarget = target;
|
||||
public AnimWrapper( ImageView target ) {
|
||||
if ( CarSeries.isF8xxSeries() ) {
|
||||
mDelegate = new OthersAnim( target );
|
||||
start();
|
||||
} else {
|
||||
mTarget.setImageResource( R.drawable.mogo_tts_icon_00000 );
|
||||
mDelegate = new KitkatAnim( target );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +43,22 @@ public class AnimWrapper implements Anim {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentAnim( AnimRes.EmojiType type ) {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.setCurrentAnim( type );
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isStarted() {
|
||||
return mIsStarted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.release();
|
||||
}
|
||||
mDelegate = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,40 @@
|
||||
package com.mogo.module.apps.anim;
|
||||
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.mogo.module.apps.R;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-26
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class KitkatAnim implements Anim{
|
||||
public class KitkatAnim implements Anim {
|
||||
|
||||
private ImageView mTarget;
|
||||
|
||||
public KitkatAnim( ImageView target ) {
|
||||
this.mTarget = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
|
||||
mTarget.setImageResource( R.drawable.mogo_tts_icon_00000 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentAnim( AnimRes.EmojiType type ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
mTarget = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,17 +9,20 @@ import android.widget.ImageView;
|
||||
* @author congtaowang
|
||||
* @since 2020-02-26
|
||||
* <p>
|
||||
* 描述
|
||||
* 导航>音乐>其他(自己轮询)
|
||||
*/
|
||||
public class OthersAnim implements Anim {
|
||||
|
||||
private int mStartIndex = 0;
|
||||
|
||||
private final static int MSG_LOOP = 3003;
|
||||
public static final int MSG_CHANGE = 3004;
|
||||
public static final long INTERVAL = 100L;
|
||||
private boolean mStarted = false;
|
||||
|
||||
private final ImageView mImageView;
|
||||
private ImageView mImageView;
|
||||
|
||||
private int mEmojiIndex = 0;
|
||||
|
||||
private Handler mHandler = new Handler( Looper.getMainLooper() ) {
|
||||
@Override
|
||||
@@ -28,27 +31,80 @@ public class OthersAnim implements Anim {
|
||||
switch ( msg.what ) {
|
||||
case MSG_LOOP:
|
||||
if ( mStarted ) {
|
||||
if ( AnimRes.sRes.length == 0 ) {
|
||||
return;
|
||||
}
|
||||
mImageView.setImageResource( AnimRes.sRes[mStartIndex++ % AnimRes.sRes.length] );
|
||||
mHandler.sendEmptyMessageDelayed( MSG_LOOP, INTERVAL );
|
||||
}
|
||||
break;
|
||||
case MSG_CHANGE:
|
||||
if ( mLastType == AnimRes.EmojiType.Others ) {
|
||||
boolean start = mStarted;
|
||||
stop();
|
||||
mEmojiIndex++;
|
||||
AnimRes.sRes = AnimRes.sAll[mEmojiIndex % AnimRes.sAll.length];
|
||||
mStartIndex = 0;
|
||||
if ( start ) {
|
||||
start();
|
||||
}
|
||||
mHandler.sendEmptyMessageDelayed( MSG_CHANGE, 60 * 1_000L );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private AnimRes.EmojiType mLastType;
|
||||
|
||||
public OthersAnim( ImageView imageView ) {
|
||||
this.mImageView = imageView;
|
||||
mLastType = AnimRes.EmojiType.Others;
|
||||
AnimRes.sRes = AnimRes.sAll[mEmojiIndex];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
if ( mStarted ) {
|
||||
return;
|
||||
}
|
||||
mStarted = true;
|
||||
mHandler.sendEmptyMessage( MSG_LOOP );
|
||||
mHandler.sendEmptyMessageDelayed( MSG_CHANGE, 60 * 1_000L );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
mStarted = false;
|
||||
mHandler.removeMessages( MSG_LOOP );
|
||||
mHandler.removeMessages( MSG_CHANGE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentAnim( AnimRes.EmojiType type ) {
|
||||
if ( mLastType == type ) {
|
||||
return;
|
||||
}
|
||||
mLastType = type;
|
||||
switch ( type ) {
|
||||
case Navigation:
|
||||
mStartIndex = 0;
|
||||
AnimRes.sRes = AnimRes.sNavigation;
|
||||
break;
|
||||
case Music:
|
||||
mStartIndex = 0;
|
||||
AnimRes.sRes = AnimRes.sMusic;
|
||||
break;
|
||||
case Others:
|
||||
mHandler.sendEmptyMessageDelayed( MSG_CHANGE, 0 * 1_000L );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
stop();
|
||||
mHandler = null;
|
||||
mImageView = null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user