opt
This commit is contained in:
@@ -10,6 +10,8 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.module.extensions.anim.AnimRes;
|
||||
import com.mogo.module.extensions.anim.JSurfaceView;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -19,7 +21,7 @@ import com.mogo.commons.mvp.MvpFragment;
|
||||
*/
|
||||
public class ExtensionsFragment extends MvpFragment< ExtensionsView, ExtensionsPresenter > implements ExtensionsView {
|
||||
|
||||
private View mVoiceIcon;
|
||||
private JSurfaceView mVoiceIcon;
|
||||
private View mVoiceMsg;
|
||||
|
||||
private TextView mTime;
|
||||
@@ -66,6 +68,8 @@ public class ExtensionsFragment extends MvpFragment< ExtensionsView, ExtensionsP
|
||||
|
||||
mMsgContainer = findViewById( R.id.module_ext_id_msg );
|
||||
mMsgCounter = findViewById( R.id.module_ext_id_msg_counter );
|
||||
|
||||
mVoiceIcon.setFrames( AnimRes.sRes );
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -77,7 +81,18 @@ public class ExtensionsFragment extends MvpFragment< ExtensionsView, ExtensionsP
|
||||
@Override
|
||||
public void onActivityCreated( @Nullable Bundle savedInstanceState ) {
|
||||
super.onActivityCreated( savedInstanceState );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mVoiceIcon.startAnim();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
mVoiceIcon.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
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
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
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;
|
||||
|
||||
public class JSurfaceView extends SurfaceView implements Runnable, SurfaceHolder.Callback {
|
||||
|
||||
private SurfaceHolder mHolder;
|
||||
|
||||
/**
|
||||
* 动画是否执行中
|
||||
*/
|
||||
private boolean bRunning = false;
|
||||
/**
|
||||
* 当前执行的第几帧
|
||||
*/
|
||||
private int mCurrentPos;
|
||||
/**
|
||||
* 动画集合
|
||||
*/
|
||||
private int[] mFrames;
|
||||
|
||||
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( false );
|
||||
mHolder.setFormat( PixelFormat.TRANSLUCENT );
|
||||
}
|
||||
|
||||
public void setFrames( int[] frames ) {
|
||||
mFrames = frames;
|
||||
}
|
||||
|
||||
public void startAnim() {
|
||||
if ( bRunning ) {
|
||||
return;
|
||||
}
|
||||
ThreadPoolService.execute( this );
|
||||
bRunning = true;
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
bRunning = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while ( bRunning ) {
|
||||
drawBitmap();
|
||||
mCurrentPos++;
|
||||
try {
|
||||
Thread.sleep( 100 );
|
||||
} catch ( InterruptedException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void drawBitmap() {
|
||||
//获取画布并锁定
|
||||
Canvas mCanvas = mHolder.lockCanvas();
|
||||
if ( mCanvas == null ) {
|
||||
return;
|
||||
}
|
||||
//绘制透明色
|
||||
mCanvas.drawColor( Color.TRANSPARENT, PorterDuff.Mode.CLEAR );
|
||||
Bitmap mBitmap = BitmapFactory.decodeResource( getResources(), mFrames[mCurrentPos % mFrames.length] );
|
||||
|
||||
Paint paint = new Paint();
|
||||
Rect mSrcRect = new Rect( 0,
|
||||
0,
|
||||
mBitmap.getWidth(),
|
||||
mBitmap.getHeight() ); // 图片绘制
|
||||
Rect mDestRect = new Rect( 0,
|
||||
0,
|
||||
getWidth(),
|
||||
getHeight() );// 图片绘制位置
|
||||
|
||||
mCanvas.drawBitmap( mBitmap, mSrcRect, mDestRect, paint );
|
||||
//解锁画布,并展示bitmap到surface
|
||||
mHolder.unlockCanvasAndPost( mCanvas );
|
||||
mBitmap.recycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceCreated( SurfaceHolder holder ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceChanged( SurfaceHolder holder, int format, int width, int height ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceDestroyed( SurfaceHolder holder ) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,6 @@ import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.navi.IMogoNavi;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.map.navi.MogoNaviInfo;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.extensions.R;
|
||||
@@ -31,7 +29,7 @@ import com.mogo.service.module.IMogoModuleProvider;
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresenter > implements EntranceView, IMogoNaviListener {
|
||||
public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresenter > implements EntranceView {
|
||||
|
||||
|
||||
private View mSearch;
|
||||
@@ -126,64 +124,4 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
mMogoLocationClient = mService.getLocationClient( getContext() );
|
||||
mMogoNavi = mService.getNavi( getContext() );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onInitNaviFailure() {
|
||||
if ( mSearchProvider != null && mSearchProvider.getNaviListener() != null ) {
|
||||
mSearchProvider.getNaviListener().onInitNaviFailure();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitNaviSuccess() {
|
||||
if ( mSearchProvider != null && mSearchProvider.getNaviListener() != null ) {
|
||||
mSearchProvider.getNaviListener().onInitNaviSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviInfoUpdate( MogoNaviInfo naviinfo ) {
|
||||
if ( naviinfo == null ) {
|
||||
return;
|
||||
}
|
||||
mNaviInfo.notifyChanged( naviinfo );
|
||||
if ( mSearchProvider != null && mSearchProvider.getNaviListener() != null ) {
|
||||
mSearchProvider.getNaviListener().onNaviInfoUpdate( naviinfo );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartNavi() {
|
||||
mCommonAddress.setVisibility( View.GONE );
|
||||
mNaviInfo.setVisibility( View.VISIBLE );
|
||||
mExitNavi.setVisibility( View.VISIBLE );
|
||||
if ( mSearchProvider != null && mSearchProvider.getNaviListener() != null ) {
|
||||
mSearchProvider.getNaviListener().onStartNavi();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopNavi() {
|
||||
mCommonAddress.setVisibility( View.VISIBLE );
|
||||
mNaviInfo.setVisibility( View.GONE );
|
||||
mExitNavi.setVisibility( View.GONE );
|
||||
if ( mSearchProvider != null && mSearchProvider.getNaviListener() != null ) {
|
||||
mSearchProvider.getNaviListener().onStopNavi();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCalculateSuccess() {
|
||||
if ( mSearchProvider != null && mSearchProvider.getNaviListener() != null ) {
|
||||
mSearchProvider.getNaviListener().onCalculateSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onoCalculateFailed() {
|
||||
if ( mSearchProvider != null && mSearchProvider.getNaviListener() != null ) {
|
||||
mSearchProvider.getNaviListener().onoCalculateFailed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user