1. 优化小智动画实现

2. 入口按钮添加白天模式的阴影
3. 大而全数据(短链+长链)-> 单独短链
4. 内存优化
This commit is contained in:
wangcongtao
2020-09-08 15:33:40 +08:00
parent c609e31385
commit e9880f35a3
27 changed files with 131 additions and 49 deletions

View File

@@ -28,17 +28,8 @@ public class AnimWrapper implements Anim {
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();
} );
} );
mDelegate = new OthersAnim( target );
start();
} else {
mTarget.setImageResource( R.drawable.mogo_tts_icon_00000 );
}

View File

@@ -1,6 +1,9 @@
package com.mogo.module.apps.anim;
import android.graphics.drawable.AnimationDrawable;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.widget.ImageView;
/**
* @author congtaowang
@@ -8,25 +11,44 @@ import android.graphics.drawable.AnimationDrawable;
* <p>
* 描述
*/
public class OthersAnim implements Anim{
public class OthersAnim implements Anim {
private AnimationDrawable mDrawable;
private int mStartIndex = 0;
public OthersAnim( AnimationDrawable drawable ) {
this.mDrawable = drawable;
private final static int MSG_LOOP = 3003;
public static final long INTERVAL = 100L;
private boolean mStarted = false;
private final ImageView mImageView;
private Handler mHandler = new Handler( Looper.getMainLooper() ) {
@Override
public void handleMessage( Message msg ) {
super.handleMessage( msg );
switch ( msg.what ) {
case MSG_LOOP:
if ( mStarted ) {
mImageView.setImageResource( AnimRes.sRes[mStartIndex++ % AnimRes.sRes.length] );
mHandler.sendEmptyMessageDelayed( MSG_LOOP, INTERVAL );
}
break;
}
}
};
public OthersAnim( ImageView imageView ) {
this.mImageView = imageView;
}
@Override
public void start() {
if ( mDrawable != null ) {
mDrawable.start();
}
mStarted = true;
mHandler.sendEmptyMessage( MSG_LOOP );
}
@Override
public void stop() {
if ( mDrawable != null ) {
mDrawable.stop();
}
mStarted = false;
mHandler.removeMessages( MSG_LOOP );
}
}