opt
This commit is contained in:
@@ -11,11 +11,6 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.module.extensions.anim.AnimWrapper;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.analytics.IMogoAnalytics;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -29,24 +24,13 @@ public class ExtensionsFragment extends MvpFragment< ExtensionsView, ExtensionsP
|
||||
|
||||
public static final int MAX_DISPLAY_MSG_AMOUNT = 99;
|
||||
|
||||
private ImageView mVoiceIcon;
|
||||
private AnimWrapper mAnim = new AnimWrapper();
|
||||
private TextView mVoiceMsg;
|
||||
|
||||
private TextView mTime;
|
||||
private TextView mDate;
|
||||
|
||||
private View mWeatherContainer;
|
||||
private ImageView mWeatherIcon;
|
||||
private TextView mWeatherTemp;
|
||||
private TextView mWeatherDesc;
|
||||
|
||||
private View mMsgContainer;
|
||||
private TextView mMsgCounter;
|
||||
|
||||
private IMogoAnalytics mAnalytics;
|
||||
private IMogoFragmentManager mMogoFragmentManager;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.module_ext_layout_extensions;
|
||||
@@ -54,25 +38,10 @@ public class ExtensionsFragment extends MvpFragment< ExtensionsView, ExtensionsP
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
mVoiceIcon = findViewById( R.id.module_ext_id_voice );
|
||||
mAnim.initAnim( mVoiceIcon );
|
||||
mVoiceMsg = findViewById( R.id.module_ext_id_voice_msg );
|
||||
|
||||
mVoiceIcon.setOnClickListener( view -> {
|
||||
mVoiceMsg.performClick();
|
||||
} );
|
||||
mVoiceMsg.setOnClickListener( view -> {
|
||||
AIAssist.startAssistant( getContext() );
|
||||
mAnalytics.track( "Launcher_xiaozhi_Click", null );
|
||||
} );
|
||||
|
||||
mTime = findViewById( R.id.module_ext_id_time );
|
||||
mDate = findViewById( R.id.module_ext_id_date );
|
||||
|
||||
mWeatherContainer = findViewById( R.id.module_ext_id_weather_container );
|
||||
mWeatherIcon = findViewById( R.id.module_ext_id_weather_icon );
|
||||
mWeatherTemp = findViewById( R.id.module_ext_id_weather_temp );
|
||||
mWeatherDesc = findViewById( R.id.module_ext_id_weather_desc );
|
||||
|
||||
mMsgContainer = findViewById( R.id.module_ext_id_msg );
|
||||
mMsgContainer.setOnClickListener( view -> {
|
||||
@@ -90,35 +59,16 @@ public class ExtensionsFragment extends MvpFragment< ExtensionsView, ExtensionsP
|
||||
@Override
|
||||
public void onActivityCreated( @Nullable Bundle savedInstanceState ) {
|
||||
super.onActivityCreated( savedInstanceState );
|
||||
mAnalytics = ( IMogoAnalytics ) ARouter.getInstance().build( MogoServicePaths.PATH_UTILS_ANALYTICS ).navigation( getContext() );
|
||||
mMogoFragmentManager = ( IMogoFragmentManager ) ARouter.getInstance().build( MogoServicePaths.PATH_FRAGMENT_MANAGER ).navigation( getContext() );
|
||||
|
||||
mMogoFragmentManager.addMainFragmentStackTransactionListener( size -> {
|
||||
// 主页 fragment 栈变化的时候,改变动画状态
|
||||
if ( size == 0 ) {
|
||||
mAnim.start();
|
||||
} else {
|
||||
mAnim.stop();
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mAnim.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
mAnim.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTime( String date, String time ) {
|
||||
mDate.setText( date );
|
||||
mTime.setText( time );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -134,7 +84,6 @@ public class ExtensionsFragment extends MvpFragment< ExtensionsView, ExtensionsP
|
||||
hidden |= TextUtils.isEmpty( temp );
|
||||
hidden |= TextUtils.isEmpty( desc );
|
||||
mWeatherTemp.setText( temp );
|
||||
mWeatherDesc.setText( desc );
|
||||
mWeatherContainer.setVisibility( hidden ? View.GONE : View.VISIBLE );
|
||||
}
|
||||
|
||||
@@ -143,11 +92,4 @@ public class ExtensionsFragment extends MvpFragment< ExtensionsView, ExtensionsP
|
||||
mMsgContainer.setVisibility( hasMsg ? View.VISIBLE : View.GONE );
|
||||
mMsgCounter.setText( amount > MAX_DISPLAY_MSG_AMOUNT ? getString( R.string.module_ext_str_dots ) : String.valueOf( amount ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderAITipWords( String word ) {
|
||||
if ( !TextUtils.isEmpty( word ) ) {
|
||||
mVoiceMsg.setText( word );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
package com.mogo.module.extensions;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
@@ -20,23 +12,6 @@ import com.mogo.module.extensions.weather.WeatherModel;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.statusmanager.IMogoMsgCenter;
|
||||
import com.mogo.service.statusmanager.IMogoMsgCenterListener;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
@@ -46,136 +21,26 @@ import java.util.Set;
|
||||
* 描述
|
||||
*/
|
||||
public class ExtensionsPresenter extends Presenter< ExtensionsView > implements WeatherCallback,
|
||||
IMogoMsgCenterListener,
|
||||
IMogoStatusChangedListener {
|
||||
IMogoMsgCenterListener {
|
||||
|
||||
private static final String TAG = "ExtensionsPresenter";
|
||||
|
||||
private String[] mWeeks;
|
||||
|
||||
private WeatherModel mWeatherModel;
|
||||
|
||||
public static final int MSG_SWITCH_AI_TIP_WORDS = 4000;
|
||||
public static final long INTERVAL_TIME = 8_000L;
|
||||
private String[] mAITipWords;
|
||||
private int mCurrentIndex = 0;
|
||||
private Handler mHandler = new Handler( Looper.getMainLooper() ) {
|
||||
@Override
|
||||
public void handleMessage( Message msg ) {
|
||||
super.handleMessage( msg );
|
||||
if ( msg.what == MSG_SWITCH_AI_TIP_WORDS ) {
|
||||
if ( mView != null ) {
|
||||
if ( mCurrentIndex < mAITipWords.length ) {
|
||||
mView.renderAITipWords( mAITipWords[mCurrentIndex++] );
|
||||
} else {
|
||||
mCurrentIndex = 0;
|
||||
mHasTipWords = generateTipWordsSequence();
|
||||
}
|
||||
}
|
||||
if ( mHasTipWords ) {
|
||||
mHandler.sendEmptyMessageDelayed( MSG_SWITCH_AI_TIP_WORDS, INTERVAL_TIME );
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
private boolean mHasTipWords = false;
|
||||
|
||||
private boolean mHasStarted = false;
|
||||
|
||||
/**
|
||||
* 接收时间变化的广播
|
||||
*/
|
||||
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive( Context context, Intent intent ) {
|
||||
try {
|
||||
WorkThreadHandler.getInstance().post( () -> {
|
||||
refreshTimeAndDate();
|
||||
} );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error. " );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private IMogoMsgCenter mMsgCenter;
|
||||
|
||||
private IMogoStatusManager mStatusManager;
|
||||
|
||||
private boolean generateTipWordsSequence() {
|
||||
if ( mAITipWords != null && mAITipWords.length > 0 ) {
|
||||
Random random = new Random( System.currentTimeMillis() );
|
||||
int loop = mAITipWords.length / 2;
|
||||
int bound = mAITipWords.length;
|
||||
for ( int i = 0; i < loop; i++ ) {
|
||||
int target = random.nextInt( bound );
|
||||
int sweepTarget = random.nextInt( bound );
|
||||
if ( target != sweepTarget ) {
|
||||
String targetStr = mAITipWords[target];
|
||||
mAITipWords[target] = mAITipWords[sweepTarget];
|
||||
mAITipWords[sweepTarget] = targetStr;
|
||||
}
|
||||
}
|
||||
Logger.d( TAG, "next generate sequence: " + mAITipWords );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ExtensionsPresenter( ExtensionsView view ) {
|
||||
super( view );
|
||||
mWeeks = getContext().getResources().getStringArray( R.array.module_ext_str_arr_week );
|
||||
mAITipWords = getContext().getResources().getStringArray( R.array.module_ext_str_arr_ai_tips );
|
||||
mWeatherModel = new WeatherModel( getContext() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate( @NonNull LifecycleOwner owner ) {
|
||||
super.onCreate( owner );
|
||||
registerTimerReceiver();
|
||||
mWeatherModel.init( this );
|
||||
mWeatherModel.queryWeatherInformation();
|
||||
refreshTimeAndDate();
|
||||
mMsgCenter = ( IMogoMsgCenter ) ARouter.getInstance().build( MogoServicePaths.PATH_MSG_CENTER ).navigation();
|
||||
mMsgCenter.registerMsgCenterListener( this );
|
||||
mHasTipWords = generateTipWordsSequence();
|
||||
|
||||
mStatusManager = ( IMogoStatusManager ) ARouter.getInstance().build( MogoServicePaths.PATH_STATUS_MANAGER ).navigation();
|
||||
mStatusManager.registerStatusChangedListener( TAG, StatusDescriptor.APP_LIST_UI, this );
|
||||
mStatusManager.registerStatusChangedListener( TAG, StatusDescriptor.SEARCH_UI, this );
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册时间变化监听
|
||||
*/
|
||||
private void registerTimerReceiver() {
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction( Intent.ACTION_TIME_TICK );
|
||||
filter.addAction( Intent.ACTION_TIME_CHANGED );
|
||||
filter.addAction( Intent.ACTION_TIMEZONE_CHANGED );
|
||||
filter.addAction( Intent.ACTION_CONFIGURATION_CHANGED );
|
||||
getContext().registerReceiver( mReceiver, filter );
|
||||
}
|
||||
|
||||
private void refreshTimeAndDate() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int hour = calendar.get( Calendar.HOUR_OF_DAY );
|
||||
int minute = calendar.get( Calendar.MINUTE );
|
||||
|
||||
int month = calendar.get( Calendar.MONTH );
|
||||
int day = calendar.get( Calendar.DAY_OF_MONTH );
|
||||
int week = calendar.get( Calendar.DAY_OF_WEEK );
|
||||
|
||||
String timeStr = getContext().getResources().getString( R.string.module_ext_str_time_format, hour, minute > 9 ? String.valueOf( minute ) : "0" + minute );
|
||||
String dateStr = getContext().getResources().getString( R.string.module_ext_str_date_format, month + 1, day, mWeeks[week - 1] );
|
||||
|
||||
UiThreadHandler.post( () -> {
|
||||
try {
|
||||
mView.renderTime( dateStr, timeStr );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -197,43 +62,14 @@ public class ExtensionsPresenter extends Presenter< ExtensionsView > implements
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged( StatusDescriptor descriptor, boolean isTrue ) {
|
||||
switch ( descriptor ) {
|
||||
case APP_LIST_UI:
|
||||
case SEARCH_UI:
|
||||
// changeAutoSwitchVoiceTipsWordsStatus( !isTrue );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume( @NonNull LifecycleOwner owner ) {
|
||||
super.onResume( owner );
|
||||
// changeAutoSwitchVoiceTipsWordsStatus( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause( @NonNull LifecycleOwner owner ) {
|
||||
super.onPause( owner );
|
||||
// changeAutoSwitchVoiceTipsWordsStatus( true );
|
||||
}
|
||||
|
||||
private void changeAutoSwitchVoiceTipsWordsStatus( boolean autoChange ) {
|
||||
if ( !mHasTipWords ) {
|
||||
return;
|
||||
}
|
||||
if ( mHasStarted ) {
|
||||
return;
|
||||
}
|
||||
mHasStarted = true;
|
||||
if ( autoChange ) {
|
||||
mHandler.sendEmptyMessageDelayed( MSG_SWITCH_AI_TIP_WORDS, INTERVAL_TIME );
|
||||
Logger.d( TAG, "auto switch" );
|
||||
} else {
|
||||
mHandler.removeMessages( MSG_SWITCH_AI_TIP_WORDS );
|
||||
Logger.d( TAG, "stop auto switch" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -242,7 +78,6 @@ public class ExtensionsPresenter extends Presenter< ExtensionsView > implements
|
||||
if ( mWeatherModel != null ) {
|
||||
mWeatherModel.destroy();
|
||||
}
|
||||
getContext().unregisterReceiver( mReceiver );
|
||||
if ( mMsgCenter != null ) {
|
||||
mMsgCenter.unregisterMsgCenterListener( this );
|
||||
}
|
||||
|
||||
@@ -11,14 +11,6 @@ import com.mogo.module.extensions.weather.WeatherInfo;
|
||||
*/
|
||||
public interface ExtensionsView extends IView {
|
||||
|
||||
/**
|
||||
* 刷新日期、时间
|
||||
*
|
||||
* @param date 日期
|
||||
* @param time 时间
|
||||
*/
|
||||
void renderTime( String date, String time );
|
||||
|
||||
/**
|
||||
* 天气信息
|
||||
*
|
||||
@@ -35,11 +27,4 @@ public interface ExtensionsView extends IView {
|
||||
* @param amount 消息数量
|
||||
*/
|
||||
void renderMsgInfo( boolean hasMsg, int amount );
|
||||
|
||||
/**
|
||||
* 更换小智语音提示词
|
||||
*
|
||||
* @param word
|
||||
*/
|
||||
void renderAITipWords( String word );
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.mogo.module.extensions.anim;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-26
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public interface Anim {
|
||||
|
||||
void start();
|
||||
|
||||
void stop();
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
package com.mogo.module.extensions.anim;
|
||||
|
||||
import com.mogo.module.extensions.R;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-09
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AnimRes {
|
||||
|
||||
public static final int sRes[] = {
|
||||
R.drawable.mogo_tts_icon_00000,
|
||||
R.drawable.mogo_tts_icon_00001,
|
||||
R.drawable.mogo_tts_icon_00002,
|
||||
R.drawable.mogo_tts_icon_00003,
|
||||
R.drawable.mogo_tts_icon_00004,
|
||||
R.drawable.mogo_tts_icon_00005,
|
||||
R.drawable.mogo_tts_icon_00006,
|
||||
R.drawable.mogo_tts_icon_00007,
|
||||
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_00012,
|
||||
R.drawable.mogo_tts_icon_00013,
|
||||
R.drawable.mogo_tts_icon_00014,
|
||||
R.drawable.mogo_tts_icon_00015,
|
||||
R.drawable.mogo_tts_icon_00016,
|
||||
R.drawable.mogo_tts_icon_00017,
|
||||
R.drawable.mogo_tts_icon_00018,
|
||||
R.drawable.mogo_tts_icon_00019,
|
||||
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_00024,
|
||||
R.drawable.mogo_tts_icon_00025,
|
||||
R.drawable.mogo_tts_icon_00026,
|
||||
R.drawable.mogo_tts_icon_00027,
|
||||
R.drawable.mogo_tts_icon_00028,
|
||||
R.drawable.mogo_tts_icon_00029,
|
||||
R.drawable.mogo_tts_icon_00030,
|
||||
R.drawable.mogo_tts_icon_00031,
|
||||
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_00036,
|
||||
R.drawable.mogo_tts_icon_00037,
|
||||
R.drawable.mogo_tts_icon_00038,
|
||||
R.drawable.mogo_tts_icon_00039,
|
||||
R.drawable.mogo_tts_icon_00040,
|
||||
R.drawable.mogo_tts_icon_00041,
|
||||
R.drawable.mogo_tts_icon_00042,
|
||||
R.drawable.mogo_tts_icon_00043,
|
||||
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_00048,
|
||||
R.drawable.mogo_tts_icon_00049,
|
||||
R.drawable.mogo_tts_icon_00050,
|
||||
R.drawable.mogo_tts_icon_00051,
|
||||
R.drawable.mogo_tts_icon_00052,
|
||||
R.drawable.mogo_tts_icon_00053,
|
||||
R.drawable.mogo_tts_icon_00054,
|
||||
R.drawable.mogo_tts_icon_00055,
|
||||
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_00060,
|
||||
R.drawable.mogo_tts_icon_00061,
|
||||
R.drawable.mogo_tts_icon_00062,
|
||||
R.drawable.mogo_tts_icon_00063,
|
||||
R.drawable.mogo_tts_icon_00064,
|
||||
R.drawable.mogo_tts_icon_00065,
|
||||
R.drawable.mogo_tts_icon_00066,
|
||||
R.drawable.mogo_tts_icon_00067
|
||||
};
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package com.mogo.module.extensions.anim;
|
||||
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.mogo.module.common.utils.CarSeries;
|
||||
import com.mogo.module.extensions.R;
|
||||
import com.mogo.utils.ThreadPoolService;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-26
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
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;
|
||||
if ( CarSeries.getSeries() == CarSeries.CAR_SERIES_F80X ) {
|
||||
ThreadPoolService.execute( () -> {
|
||||
final AnimationDrawable drawable = new AnimationDrawable();
|
||||
for ( int i = 0; i < AnimRes.sRes.length; i++ ) {
|
||||
drawable.addFrame( target.getResources().getDrawable( AnimRes.sRes[i] ), 100 );
|
||||
}
|
||||
UiThreadHandler.post( () -> {
|
||||
target.setBackground( drawable );
|
||||
mDelegate = new OthersAnim( drawable );
|
||||
start();
|
||||
} );
|
||||
} );
|
||||
} else {
|
||||
mTarget.setImageResource( R.drawable.mogo_tts_icon_00000 );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void start() {
|
||||
if ( mDelegate != null && !mIsStarted ) {
|
||||
mIsStarted = true;
|
||||
mDelegate.start();
|
||||
Logger.d( TAG, "开启小智动画" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
if ( mDelegate != null ) {
|
||||
mIsStarted = false;
|
||||
mDelegate.stop();
|
||||
Logger.d( TAG, "停止小智动画" );
|
||||
}
|
||||
}
|
||||
|
||||
public void release() {
|
||||
mDelegate = null;
|
||||
}
|
||||
}
|
||||
@@ -1,184 +0,0 @@
|
||||
package com.mogo.module.extensions.anim;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Rect;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
|
||||
import com.mogo.utils.ThreadPoolService;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class JSurfaceView extends SurfaceView implements Runnable, SurfaceHolder.Callback {
|
||||
|
||||
private static final String TAG = "JSurfaceView";
|
||||
|
||||
private SurfaceHolder mHolder;
|
||||
|
||||
/**
|
||||
* 动画是否执行中
|
||||
*/
|
||||
private boolean bRunning = false;
|
||||
/**
|
||||
* 当前执行的第几帧
|
||||
*/
|
||||
private int mCurrentPos;
|
||||
/**
|
||||
* 动画集合
|
||||
*/
|
||||
private int[] mFrames;
|
||||
|
||||
private Thread mThread;
|
||||
|
||||
// 使用 BitmapFactory.Option.inBitmap 属性复用 bitmap 对象
|
||||
private Bitmap mContainerBitmap = null;
|
||||
|
||||
// mContainerBitmap 是否生效
|
||||
private boolean mContainerBitmapStatus = true;
|
||||
|
||||
// mContainerBitmapStatus 为 false 时,使用该缓存方案
|
||||
private Map< Integer, WeakReference< Bitmap > > mBitmapRefMap = new HashMap<>();
|
||||
|
||||
public JSurfaceView( Context context ) {
|
||||
super( context );
|
||||
init();
|
||||
}
|
||||
|
||||
public JSurfaceView( Context context, AttributeSet attrs ) {
|
||||
super( context, attrs );
|
||||
init();
|
||||
}
|
||||
|
||||
public JSurfaceView( Context context, AttributeSet attrs, int defStyleAttr ) {
|
||||
super( context, attrs, defStyleAttr );
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
mHolder = getHolder();
|
||||
mHolder.addCallback( this );
|
||||
setZOrderOnTop( true );
|
||||
mHolder.setFormat( PixelFormat.TRANSLUCENT );
|
||||
}
|
||||
|
||||
public void setFrames( int[] frames ) {
|
||||
mFrames = frames;
|
||||
}
|
||||
|
||||
public void startAnim() {
|
||||
if ( bRunning ) {
|
||||
return;
|
||||
}
|
||||
bRunning = true;
|
||||
mThread = new Thread( this );
|
||||
mThread.setName( TAG + "thread" );
|
||||
mThread.start();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
bRunning = false;
|
||||
try {
|
||||
mThread.interrupt();
|
||||
mThread = null;
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while ( bRunning ) {
|
||||
drawBitmap();
|
||||
mCurrentPos++;
|
||||
try {
|
||||
Thread.sleep( 100 );
|
||||
} catch ( InterruptedException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void drawBitmap() {
|
||||
//获取画布并锁定
|
||||
Canvas canvas = mHolder.lockCanvas();
|
||||
if ( canvas == null ) {
|
||||
return;
|
||||
}
|
||||
//绘制透明色
|
||||
canvas.drawColor( Color.TRANSPARENT, PorterDuff.Mode.CLEAR );
|
||||
|
||||
int factPosition = mCurrentPos % mFrames.length;
|
||||
|
||||
if ( mContainerBitmapStatus ) {
|
||||
if ( mContainerBitmap == null ) {
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
options.inMutable = true;
|
||||
mContainerBitmap = BitmapFactory.decodeResource( getResources(), mFrames[factPosition], options );
|
||||
} else {
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
options.inMutable = true;
|
||||
options.inBitmap = mContainerBitmap;
|
||||
try {
|
||||
BitmapFactory.decodeResource( getResources(), mFrames[factPosition], options );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
mContainerBitmapStatus = false;
|
||||
mContainerBitmap = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( !mContainerBitmapStatus ) {
|
||||
WeakReference< Bitmap > ref = mBitmapRefMap.get( factPosition );
|
||||
if ( ref != null && ref.get() != null && !ref.get().isRecycled() ) {
|
||||
mContainerBitmap = ref.get();
|
||||
} else {
|
||||
mContainerBitmap = BitmapFactory.decodeResource( getResources(), mFrames[factPosition] );
|
||||
mBitmapRefMap.put( factPosition, new WeakReference<>( mContainerBitmap ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( mContainerBitmap == null || mContainerBitmap.isRecycled() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
Paint paint = new Paint();
|
||||
Rect mSrcRect = new Rect( 0,
|
||||
0,
|
||||
mContainerBitmap.getWidth(),
|
||||
mContainerBitmap.getHeight() ); // 图片绘制
|
||||
Rect mDestRect = new Rect( 0,
|
||||
0,
|
||||
getWidth(),
|
||||
getHeight() );// 图片绘制位置
|
||||
|
||||
canvas.drawBitmap( mContainerBitmap, mSrcRect, mDestRect, paint );
|
||||
//解锁画布,并展示bitmap到surface
|
||||
mHolder.unlockCanvasAndPost( canvas );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceCreated( SurfaceHolder holder ) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceChanged( SurfaceHolder holder, int format, int width, int height ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceDestroyed( SurfaceHolder holder ) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.mogo.module.extensions.anim;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-26
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class KitkatAnim implements Anim{
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.mogo.module.extensions.anim;
|
||||
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-26
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class OthersAnim implements Anim{
|
||||
|
||||
private AnimationDrawable mDrawable;
|
||||
|
||||
public OthersAnim( AnimationDrawable drawable ) {
|
||||
this.mDrawable = drawable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
if ( mDrawable != null ) {
|
||||
mDrawable.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
if ( mDrawable != null ) {
|
||||
mDrawable.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.mogo.module.extensions.entrance;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
@@ -17,16 +17,13 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.marker.IMogoMarkerManager;
|
||||
import com.mogo.map.model.MogoPoi;
|
||||
import com.mogo.map.navi.IMogoAimlessModeListener;
|
||||
import com.mogo.map.navi.IMogoNavi;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.map.navi.MogoCongestionInfo;
|
||||
import com.mogo.map.navi.MogoNaviInfo;
|
||||
import com.mogo.map.navi.MogoTraffic;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
@@ -39,7 +36,6 @@ import com.mogo.module.common.map.MapCenterPointStrategy;
|
||||
import com.mogo.module.common.map.Scene;
|
||||
import com.mogo.module.extensions.ExtensionsModuleConst;
|
||||
import com.mogo.module.extensions.R;
|
||||
import com.mogo.module.extensions.dialog.NaviNoticeDialog;
|
||||
import com.mogo.module.extensions.navi.NaviInfoView;
|
||||
import com.mogo.module.share.ShareControl;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
@@ -49,12 +45,11 @@ import com.mogo.service.entrance.ButtonIndex;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.module.IMogoAddressManager;
|
||||
import com.mogo.service.module.IMogoRegisterCenter;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.ResourcesHelper;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -82,15 +77,15 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
private TextView mUpload;
|
||||
private ImageView mUploading;
|
||||
|
||||
private View mVRMode;
|
||||
private View mMove2CurrentLocation;
|
||||
|
||||
private NaviInfoView mNaviInfo;
|
||||
private TextView mExitNavi;
|
||||
|
||||
private View mSpeedLimit;
|
||||
private TextView mSpeedLimitValue;
|
||||
private View mSpeedLimitUnit;
|
||||
|
||||
private View mDisplayOverview;
|
||||
private ImageView mDisplayOverviewIcon;
|
||||
private TextView mDisplayOverviewText;
|
||||
|
||||
private IMogoServiceApis mApis;
|
||||
private IMogoMapService mService;
|
||||
@@ -165,6 +160,8 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
public static final int MSG_STOP_ANIM = 308;
|
||||
public static final long TIME_FRAME_INTERVAL_TIME = 80;
|
||||
|
||||
private Rect mDisplayOverviewBounds;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.module_ext_layout_entrance;
|
||||
@@ -193,15 +190,24 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
traceData( "1" );
|
||||
}
|
||||
} );
|
||||
mVRMode = findViewById( R.id.module_entrance_id_vr_mode );
|
||||
mVRMode.setOnClickListener( view -> {
|
||||
|
||||
mDisplayOverview = findViewById( R.id.module_ext_id_display_overview );
|
||||
mDisplayOverviewText = findViewById( R.id.module_ext_id_display_overview_text );
|
||||
mDisplayOverviewIcon = findViewById( R.id.module_ext_id_display_overview_icon );
|
||||
mDisplayOverview.setOnClickListener( view -> {
|
||||
if ( !mStatusManager.isDisplayOverview() ) {
|
||||
mMApUIController.displayOverview( mDisplayOverviewBounds );
|
||||
} else {
|
||||
mMApUIController.recoverLockMode();
|
||||
}
|
||||
mStatusManager.setDisplayOverview( TAG, !mStatusManager.isDisplayOverview() );
|
||||
} );
|
||||
|
||||
mMove2CurrentLocation = findViewById( R.id.module_entrance_id_move2_current_location );
|
||||
mMove2CurrentLocation.setOnClickListener( view -> {
|
||||
final MogoLocation location = mMogoLocationClient.getLastKnowLocation();
|
||||
if ( location != null ) {
|
||||
if ( !mMogoStatusManager.isADASShow() ) {
|
||||
if ( !mMogoStatusManager.isV2XShow() ) {
|
||||
mMogoStatusManager.setUserInteractionStatus( TAG, true, false );
|
||||
mMApUIController.setLockZoom( 16 );
|
||||
mMApUIController.changeZoom( 16.0f );
|
||||
@@ -218,6 +224,7 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
if ( mIsLock ) {
|
||||
new WMDialog.Builder( getContext() )
|
||||
.setOkButton( R.string.module_commons_button_ok, ( dlg, which ) -> {
|
||||
dlg.dismiss();
|
||||
mMogoNavi.stopNavi();
|
||||
} )
|
||||
.setCancelButton( R.string.module_commons_button_cancel, ( dlg, which ) -> {
|
||||
@@ -244,10 +251,6 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
mCameraMode.setText( getString( mCameraMode.isSelected() ? R.string.mode_car_up : R.string.mode_north_up ) );
|
||||
} );
|
||||
|
||||
mSpeedLimit = findViewById( R.id.module_entrance_id_speed_limit_container );
|
||||
mSpeedLimitValue = findViewById( R.id.module_entrance_id_speed_limit_value );
|
||||
mSpeedLimitUnit = findViewById( R.id.module_entrance_id_speed_limit_unit );
|
||||
|
||||
|
||||
mApis.getIntentManagerApi().registerIntentListener( AUTONAVI_STANDARD_BROADCAST_RECV, new IMogoIntentListener() {
|
||||
@Override
|
||||
@@ -268,6 +271,12 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
MogoEntranceButtons.save( ButtonIndex.BUTTON1, findViewById( R.id.module_entrance_id_button1 ) );
|
||||
MogoEntranceButtons.save( ButtonIndex.BUTTON2, findViewById( R.id.module_entrance_id_button2 ) );
|
||||
|
||||
mDisplayOverviewBounds = new Rect(
|
||||
ResourcesHelper.getDimensionPixelSize( getContext(), R.dimen.module_map_display_overview_left_margin ),
|
||||
ResourcesHelper.getDimensionPixelSize( getContext(), R.dimen.module_map_display_overview_top_margin ),
|
||||
ResourcesHelper.getDimensionPixelSize( getContext(), R.dimen.module_map_display_overview_right_margin ),
|
||||
ResourcesHelper.getDimensionPixelSize( getContext(), R.dimen.module_map_display_overview_bottom_margin )
|
||||
);
|
||||
}
|
||||
|
||||
private static final String AUTONAVI_STANDARD_BROADCAST_RECV = "AUTONAVI_STANDARD_BROADCAST_RECV";
|
||||
@@ -296,6 +305,7 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
mMogoMarkerManager = mService.getMarkerManager( getContext() );
|
||||
|
||||
mMogoStatusManager.registerStatusChangedListener( TAG, StatusDescriptor.UPLOADING, this );
|
||||
mMogoStatusManager.registerStatusChangedListener( TAG, StatusDescriptor.DISPLAY_OVERVIEW, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -343,22 +353,21 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
@Override
|
||||
public void onStartNavi() {
|
||||
mNaviInfo.setVisibility( View.VISIBLE );
|
||||
mCameraMode.setVisibility( View.VISIBLE );
|
||||
mExitNavi.setVisibility( View.VISIBLE );
|
||||
mMApUIController.changeMapMode( mCameraMode.isSelected() ? EnumMapUI.NorthUP_2D : EnumMapUI.CarUp_2D );
|
||||
MapCenterPointStrategy.setMapCenterPointBySceneAndDelay( mMApUIController, Scene.NAVI, 500, () -> {
|
||||
return !mMogoNavi.isNaviing();
|
||||
} );
|
||||
mDisplayOverview.setVisibility( View.VISIBLE );
|
||||
mApis.getAnalyticsApi().track( "Navigation_begin", new HashMap<>() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopNavi() {
|
||||
mNaviInfo.setVisibility( View.GONE );
|
||||
mCameraMode.setVisibility( View.GONE );
|
||||
mExitNavi.setVisibility( View.GONE );
|
||||
mSpeedLimit.setVisibility( View.GONE );
|
||||
mMApUIController.changeMapMode( EnumMapUI.NorthUP_2D );
|
||||
mDisplayOverview.setVisibility( View.GONE );
|
||||
MapCenterPointStrategy.setMapCenterPointByScene( mMApUIController, Scene.AIMLESS );
|
||||
}
|
||||
|
||||
@@ -367,14 +376,6 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
if ( traffic == null ) {
|
||||
return;
|
||||
}
|
||||
if ( traffic.getSpeedLimit() <= 0 ) {
|
||||
mSpeedLimit.setVisibility( View.INVISIBLE );
|
||||
mSpeedLimitValue.setText( "--" );
|
||||
} else {
|
||||
// 暂时不显示限速,等有好的显示方案在放开
|
||||
mSpeedLimit.setVisibility( View.INVISIBLE );
|
||||
mSpeedLimitValue.setText( String.valueOf( traffic.getSpeedLimit() ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -396,34 +397,6 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
mAnalytics.track( "Launcher_Share_Click", properties );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showNaviPanelWidgets() {
|
||||
if ( !mMogoNavi.isNaviing() ) {
|
||||
return;
|
||||
}
|
||||
mNaviInfo.setVisibility( View.VISIBLE );
|
||||
mCameraMode.setVisibility( View.VISIBLE );
|
||||
try {
|
||||
mApis.getWindowManagerApi().showAll();
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideNaviPanelWidgets() {
|
||||
if ( !mMogoNavi.isNaviing() ) {
|
||||
return;
|
||||
}
|
||||
mNaviInfo.setVisibility( View.GONE );
|
||||
mCameraMode.setVisibility( View.GONE );
|
||||
try {
|
||||
mApis.getWindowManagerApi().hideAll();
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged( StatusDescriptor descriptor, boolean isTrue ) {
|
||||
if ( mUploadRoadCondition == null ) {
|
||||
@@ -446,6 +419,17 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
mUploading.setVisibility( View.GONE );
|
||||
mUpload.setVisibility( View.VISIBLE );
|
||||
}
|
||||
} else if ( descriptor == StatusDescriptor.DISPLAY_OVERVIEW ) {
|
||||
if ( !mMogoNavi.isNaviing() ) {
|
||||
return;
|
||||
}
|
||||
if ( isTrue ) {
|
||||
mDisplayOverviewText.setText( "退出全览" );
|
||||
mCameraMode.setVisibility( View.GONE );
|
||||
} else {
|
||||
mDisplayOverviewText.setText( "全览" );
|
||||
mCameraMode.setVisibility( View.VISIBLE );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.mogo.module.extensions.entrance;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -13,7 +12,6 @@ import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
|
||||
import com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant;
|
||||
import com.mogo.module.authorize.authprovider.module.IMogoAuthorizeModuleManager;
|
||||
import com.mogo.module.extensions.ExtensionsModuleConst;
|
||||
import com.mogo.module.share.ShareControl;
|
||||
@@ -22,9 +20,7 @@ import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.analytics.IMogoAnalytics;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import org.json.JSONObject;
|
||||
@@ -40,7 +36,7 @@ import static com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerCons
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class EntrancePresenter extends Presenter< EntranceView > implements IMogoStatusChangedListener {
|
||||
public class EntrancePresenter extends Presenter< EntranceView > {
|
||||
|
||||
private Context mContext;
|
||||
private IMogoAnalytics mAnalytics;
|
||||
@@ -82,7 +78,7 @@ public class EntrancePresenter extends Presenter< EntranceView > implements IMog
|
||||
Log.d( TAG, "免唤醒 mogoVoiceListener needAuthorize = " + mIMogoAuthorizeModuleManager.needAuthorize( AUTHORIZE_TYPE_LAUNCHER_SHARE ) + " >>>cmd = " + cmd );
|
||||
mVoiceCmdType = cmd;
|
||||
if ( cmd.equals( ExtensionsModuleConst.CANCLE_SHARE )
|
||||
/*|| cmd.equals( ExtensionsModuleConst.CLOSE ) */) { //取消分享,关闭页面
|
||||
/*|| cmd.equals( ExtensionsModuleConst.CLOSE ) */ ) { //取消分享,关闭页面
|
||||
if ( mIMogoAuthorizeModuleManager.needAuthorize( AUTHORIZE_TYPE_LAUNCHER_SHARE ) ) {
|
||||
mIMogoAuthorizeModuleManager.invokeAuthorization( AUTHORIZE_TYPE_LAUNCHER_SHARE );
|
||||
} else {
|
||||
@@ -129,7 +125,6 @@ public class EntrancePresenter extends Presenter< EntranceView > implements IMog
|
||||
@Override
|
||||
public void onCreate( @NonNull LifecycleOwner owner ) {
|
||||
super.onCreate( owner );
|
||||
mStatusManager.registerStatusChangedListener( TAG, StatusDescriptor.DISPLAY_OVERVIEW, this );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -276,7 +271,7 @@ public class EntrancePresenter extends Presenter< EntranceView > implements IMog
|
||||
}
|
||||
|
||||
private void uploadRoadCondition() {
|
||||
mStatusManager.setUploadingStatus("CARD_TYPE_ROAD_CONDITION", true);
|
||||
mStatusManager.setUploadingStatus( "CARD_TYPE_ROAD_CONDITION", true );
|
||||
|
||||
traceTanluData( "2" );
|
||||
sendShareReceiver( "1" );
|
||||
@@ -286,7 +281,7 @@ public class EntrancePresenter extends Presenter< EntranceView > implements IMog
|
||||
}
|
||||
|
||||
private void uploadTrfficCheck() {
|
||||
mStatusManager.setUploadingStatus("CARD_TYPE_ROAD_CONDITION", true);
|
||||
mStatusManager.setUploadingStatus( "CARD_TYPE_ROAD_CONDITION", true );
|
||||
sendShareReceiver( "2" );
|
||||
Logger.d( "EntrancePresenter", "mogoIntentListener 分享交通检查 ----> " );
|
||||
traceTypeData( "3" );
|
||||
@@ -294,7 +289,7 @@ public class EntrancePresenter extends Presenter< EntranceView > implements IMog
|
||||
}
|
||||
|
||||
private void uploadRoadClosed() {
|
||||
mStatusManager.setUploadingStatus("CARD_TYPE_ROAD_CONDITION", true);
|
||||
mStatusManager.setUploadingStatus( "CARD_TYPE_ROAD_CONDITION", true );
|
||||
sendShareReceiver( "3" );
|
||||
Logger.d( "EntrancePresenter", "mogoIntentListener 分享封路 ----> " );
|
||||
traceTypeData( "4" );
|
||||
@@ -364,15 +359,4 @@ public class EntrancePresenter extends Presenter< EntranceView > implements IMog
|
||||
AIAssist.getInstance( mContext ).unregisterUnWakeupCommand( ExtensionsModuleConst.UPLOAD_TRAFFIC_CHECK );
|
||||
AIAssist.getInstance( mContext ).unregisterUnWakeupCommand( ExtensionsModuleConst.UPLOAD_ROAD_CLOSURE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged( StatusDescriptor descriptor, boolean isTrue ) {
|
||||
if ( descriptor == StatusDescriptor.DISPLAY_OVERVIEW ) {
|
||||
if ( isTrue ) {
|
||||
mView.hideNaviPanelWidgets();
|
||||
} else {
|
||||
mView.showNaviPanelWidgets();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,4 @@ import com.mogo.commons.mvp.IView;
|
||||
*/
|
||||
public interface EntranceView extends IView {
|
||||
|
||||
void showNaviPanelWidgets();
|
||||
|
||||
void hideNaviPanelWidgets();
|
||||
}
|
||||
|
||||
@@ -51,21 +51,58 @@ public abstract class BaseNaviInfoView extends RelativeLayout {
|
||||
protected void fillNextCrossDistance( TextView target, TextView unit, int distance ) {
|
||||
if ( distance >= 1000 ) {
|
||||
target.setText( String.format( "%.1f", distance / 1000f ) );
|
||||
unit.setText( "公里" );
|
||||
unit.setText( "km" );
|
||||
} else {
|
||||
target.setText( distance + "" );
|
||||
unit.setText( "米" );
|
||||
unit.setText( "m" );
|
||||
}
|
||||
}
|
||||
|
||||
protected void fillFormatSurplusDistance( int m, StringBuilder builder ) {
|
||||
if ( m >= 1000 ) {
|
||||
builder.append( String.format( "%.1f公里", m / 1000f ) );
|
||||
builder.append( String.format( "%.1fkm", m / 1000f ) );
|
||||
} else {
|
||||
builder.append( m ).append( "米" );
|
||||
builder.append( m ).append( "m" );
|
||||
}
|
||||
}
|
||||
|
||||
protected String getFormatSurplusDistance( int m ) {
|
||||
if ( m >= 1000 ) {
|
||||
mFormatSurplusDistanceUnit = "km";
|
||||
return String.format( "%.1f", m / 1000f );
|
||||
} else {
|
||||
mFormatSurplusDistanceUnit = "m";
|
||||
return String.format( "%d", m );
|
||||
}
|
||||
}
|
||||
|
||||
private String mFormatSurplusDistanceUnit = "";
|
||||
|
||||
protected String getFormatSurplusDistanceUnit() {
|
||||
return mFormatSurplusDistanceUnit;
|
||||
}
|
||||
|
||||
protected String getFormatSurplusTime( int seconds ) {
|
||||
if ( seconds > 60 * 60 ) {
|
||||
mFormatSurplusDistanceUnit = "h";
|
||||
return String.format( "%.1f", ( ( float ) seconds ) / 60 * 60 );
|
||||
}
|
||||
|
||||
if ( seconds > 60 ) {
|
||||
mFormatSurplusTimeUnit = "min";
|
||||
return String.format( "%.1f", ( ( float ) seconds ) / 60 );
|
||||
}
|
||||
|
||||
mFormatSurplusTimeUnit = "s";
|
||||
return String.format( "%d", seconds );
|
||||
}
|
||||
|
||||
private String mFormatSurplusTimeUnit = "";
|
||||
|
||||
protected String getFormatSurplusTimeUnit() {
|
||||
return mFormatSurplusTimeUnit;
|
||||
}
|
||||
|
||||
protected void fillFormatTime( int seconds, StringBuilder builder ) {
|
||||
int days = seconds / ( 24 * 60 * 60 );
|
||||
if ( days > 0 ) {
|
||||
@@ -81,6 +118,29 @@ public abstract class BaseNaviInfoView extends RelativeLayout {
|
||||
builder.append( min > 1 ? min : 1 ).append( "分钟" );
|
||||
}
|
||||
|
||||
protected String getArriveTime( int seconds ) {
|
||||
int days = seconds / ( 24 * 60 * 60 );
|
||||
if ( days > 0 ) {
|
||||
return String.format( "%d天后", days );
|
||||
} else {
|
||||
seconds -= days * 24 * 60 * 60;
|
||||
int hours = seconds / ( 60 * 60 );
|
||||
seconds -= hours * 60 * 60;
|
||||
int min = seconds / 60;
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int curHour = calendar.get( Calendar.HOUR_OF_DAY );
|
||||
int curMin = calendar.get( Calendar.MINUTE );
|
||||
if ( curHour + hours + ( curMin + min ) / 60 > 24 ) {
|
||||
return "一天后";
|
||||
} else {
|
||||
calendar.add( Calendar.HOUR_OF_DAY, hours );
|
||||
calendar.add( Calendar.MINUTE, min );
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat( "HH:mm" );
|
||||
return dateFormat.format( calendar.getTime() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void fillArriveTime( int seconds, StringBuilder builder ) {
|
||||
|
||||
int days = seconds / ( 24 * 60 * 60 );
|
||||
|
||||
@@ -23,9 +23,12 @@ public class NaviInfoView extends BaseNaviInfoView {
|
||||
private TextView distance;
|
||||
private TextView distanceUnit;
|
||||
private TextView nextRoad;
|
||||
private TextView estimateInfo;
|
||||
|
||||
private StringBuilder mBuilder = new StringBuilder();
|
||||
private TextView remainingDistance;
|
||||
private TextView remainingDistanceUnit;
|
||||
private TextView remainingTime;
|
||||
private TextView remainingTimeUnit;
|
||||
private TextView arriveTime;
|
||||
|
||||
public NaviInfoView( Context context ) {
|
||||
this( context, null );
|
||||
@@ -42,7 +45,12 @@ public class NaviInfoView extends BaseNaviInfoView {
|
||||
distance = findViewById( R.id.module_map_id_navi_next_info_distance );
|
||||
distanceUnit = findViewById( R.id.module_map_id_navi_next_info_distance_unit );
|
||||
nextRoad = findViewById( R.id.module_map_id_navi_next_info_road );
|
||||
estimateInfo = findViewById( R.id.module_map_id_navi_arrive_destination_estimate_info );
|
||||
|
||||
remainingDistance = findViewById( R.id.module_map_id_remaining_distance );
|
||||
remainingDistanceUnit = findViewById( R.id.module_map_id_remaining_distance_unit );
|
||||
remainingTime = findViewById( R.id.module_map_id_remaining_time );
|
||||
remainingTimeUnit = findViewById( R.id.module_map_id_remaining_time_unit );
|
||||
arriveTime = findViewById( R.id.module_map_id_arrive_time );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,46 +63,12 @@ public class NaviInfoView extends BaseNaviInfoView {
|
||||
fillNextCrossIconType( turnIcon, naviInfo.getIconResId() );
|
||||
nextRoad.setText( naviInfo.getNextRoadName() );
|
||||
|
||||
try {
|
||||
mBuilder.delete( 0, mBuilder.length() );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
mBuilder.append( "剩余" );
|
||||
fillFormatSurplusDistance( naviInfo.getPathRetainDistance(), mBuilder );
|
||||
mBuilder.append( " " );
|
||||
fillFormatTime( naviInfo.getPathRetainTime(), mBuilder );
|
||||
mBuilder.append( "\n" );
|
||||
fillArriveTime( naviInfo.getPathRetainTime(), mBuilder );
|
||||
remainingDistance.setText( getFormatSurplusDistance( naviInfo.getPathRetainDistance() ) );
|
||||
remainingDistanceUnit.setText( getFormatSurplusDistanceUnit() );
|
||||
|
||||
final String text = mBuilder.toString();
|
||||
estimateInfo.setText( text );
|
||||
}
|
||||
remainingTime.setText( getFormatSurplusTime( naviInfo.getPathRetainTime() ) );
|
||||
remainingTimeUnit.setText( getFormatSurplusTimeUnit() );
|
||||
|
||||
/**
|
||||
* 获取当行信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getGuideInfo() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
if ( getVisibility() == VISIBLE ) {
|
||||
builder.append( distance.getText() );
|
||||
builder.append( nextRoad.getText() );
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取剩余里程
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getPathRetainDistance() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
if ( getVisibility() == VISIBLE ) {
|
||||
builder.append( estimateInfo.getText() );
|
||||
}
|
||||
return builder.toString();
|
||||
arriveTime.setText( getArriveTime( naviInfo.getPathRetainTime() ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user