效果就不放上来了,处理方法很简单,可以参考下
package com.android.systemui.statusbar.phone;
/**
*add by scq 20151027
*/
import java.io.InputStream;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.provider.Settings;
import android.os.SystemProperties;
/**
* 帧动画-处理触摸控制动态壁纸运行
*/
class LiveImageView extends ImageView implements Runnable{
final int FRAMES_COUNT = 72;//数组空间大小
int[] bitmapRids = new int[FRAMES_COUNT];//帧动画数组
Bitmap[] bitmaps = new Bitmap[bitmapRids.length]; //中转数组
Paint paint=new Paint();
int animateIndex=0;
Thread liveImageThread=new Thread(this); //线程
Context cont;
public LiveImageView(Context context) {
this(context,null);
}
public LiveImageView(Context context, AttributeSet attrs) {
super(context,attrs);
cont = context;
}
/**
*每张帧图片处理
*/
public static Bitmap readBitMap(Context context, int resId){
BitmapFactory.Options opt = new BitmapFactory.Options();
opt.inPreferredConfig = Bitmap.Config.RGB_565;
opt.inPurgeable = true;
opt.inInputShareable = true;
InputStream is = context.getResources().openRawResource(resId);
return BitmapFactory.decodeStream(is,null,opt);
}
/**
*选择一套帧动画进行实例和赋予
*/
private int mWallPaperIndex = 0;
public void selectBitmap(int number){
mWallPaperIndex = number;
switch (number) {
case 0:
bitmapRids = new int[]{
com.android.internal.R.drawable.red_carp00,
com.android.internal.R.drawable.red_carp01,
com.android.internal.R.drawable.red_carp02,
com.android.internal.R.drawable.red_carp03,
com.android.internal.R.drawable.red_carp04,
com.android.internal.R.drawable.red_carp05,
com.android.internal.R.drawable.red_carp06,
com.android.internal.R.drawable.red_carp07,
com.android.internal.R.drawable.red_carp08,
com.android.internal.R.drawable.red_carp09,
com.android.internal.R.drawable.red_carp10,
//com.android.internal.R.drawable.red_carp11,
com.android.internal.R.drawable.red_carp12,
//com.android.internal.R.drawable.red_carp13,
com.android.internal.R.drawable.red_carp14,
//com.android.internal.R.drawable.red_carp15,
com.android.internal.R.drawable.red_carp16,
//com.android.internal.R.drawable.red_carp17,
com.android.internal.R.drawable.red_carp18,
//com.android.internal.R.drawable.red_carp19,
com.android.internal.R.drawable.red_carp20,
//com.android.internal.R.drawable.red_carp21,
com.android.internal.R.drawable.red_carp22,
//com.android.internal.R.drawable.red_carp23,
com.android.internal.R.drawable.red_carp24,
//com.android.internal.R.drawable.red_carp25,
com.android.internal.R.drawable.red_carp26,
//com.android.internal.R.drawable.red_carp27,
com.android.internal.R.drawable.red_carp28,
//com.android.internal.R.drawable.red_carp29,
com.android.internal.R.drawable.red_carp30,
//com.android.internal.R.drawable.red_carp31,
com.android.internal.R.drawable.red_carp32,
//com.android.internal.R.drawable.red_carp33,
com.android.internal.R.drawable.red_carp34,
//com.android.internal.R.drawable.red_carp35,
com.android.internal.R.drawable.red_carp36,
//com.android.internal.R.drawable.red_carp37,
com.android.internal.R.drawable.red_carp38,
//com.android.internal.R.drawable.red_carp39,
com.android.internal.R.drawable.red_carp40,
//com.android.internal.R.drawable.red_carp41,
com.android.internal.R.drawable.red_carp42,
//com.android.internal.R.drawable.red_carp43,
com.android.internal.R.drawable.red_carp44,
//com.android.internal.R.drawable.red_carp45,
com.android.internal.R.drawable.red_carp46,
//com.android.internal.R.drawable.red_carp47,
com.android.internal.R.drawable.red_carp48,
//com.android.internal.R.drawable.red_carp49,
com.android.internal.R.drawable.red_carp50,
//com.android.internal.R.drawable.red_carp51,
com.android.internal.R.drawable.red_carp52,
//com.android.internal.R.drawable.red_carp53,
com.android.internal.R.drawable.red_carp54,
//com.android.internal.R.drawable.red_carp55,
com.android.internal.R.drawable.red_carp56,
//com.android.internal.R.drawable.red_carp57,
com.android.internal.R.drawable.red_carp58,
//com.android.internal.R.drawable.red_carp59,
com.android.internal.R.drawable.red_carp60,
//com.android.internal.R.drawable.red_carp61,
com.android.internal.R.drawable.red_carp62,
//com.android.internal.R.drawable.red_carp63,
com.android.internal.R.drawable.red_carp64,
com.android.internal.R.drawable.red_carp65,
com.android.internal.R.drawable.red_carp66,
com.android.internal.R.drawable.red_carp67,
com.android.internal.R.drawable.red_carp68,
com.android.internal.R.drawable.red_carp69,
com.android.internal.R.drawable.red_carp70,
com.android.internal.R.drawable.red_carp71
};
bitmaps = new Bitmap[bitmapRids.length];
break;
case 1:
bitmapRids = new int[]{
com.android.internal.R.drawable.blue_fish00,
com.android.internal.R.drawable.blue_fish01,
com.android.internal.R.drawable.blue_fish02,
com.android.internal.R.drawable.blue_fish03,
com.android.internal.R.drawable.blue_fish04,
com.android.internal.R.drawable.blue_fish05,
com.android.internal.R.drawable.blue_fish06,
com.android.internal.R.drawable.blue_fish07,
com.android.internal.R.drawable.blue_fish08,
com.android.internal.R.drawable.blue_fish09,
com.android.internal.R.drawable.blue_fish10,
//com.android.internal.R.drawable.blue_fish11,
com.android.internal.R.drawable.blue_fish12,
//com.android.internal.R.drawable.blue_fish13,
com.android.internal.R.drawable.blue_fish14,
//com.android.internal.R.drawable.blue_fish15,
com.android.internal.R.drawable.blue_fish16,
//com.android.internal.R.drawable.blue_fish17,
com.android.internal.R.drawable.blue_fish18,
//com.android.internal.R.drawable.blue_fish19,
com.android.internal.R.drawable.blue_fish20,
//com.android.internal.R.drawable.blue_fish21,
com.android.internal.R.drawable.blue_fish22,
//com.android.internal.R.drawable.blue_fish23,
com.android.internal.R.drawable.blue_fish24,
//com.android.internal.R.drawable.blue_fish25,
com.android.internal.R.drawable.blue_fish26,
//com.android.internal.R.drawable.blue_fish27,
com.android.internal.R.drawable.blue_fish28,
//com.android.internal.R.drawable.blue_fish29,
com.android.internal.R.drawable.blue_fish30,
//com.android.internal.R.drawable.blue_fish31,
com.android.internal.R.drawable.blue_fish32,
//com.android.internal.R.drawable.blue_fish33,
com.android.internal.R.drawable.blue_fish34,
//com.android.internal.R.drawable.blue_fish35,
com.android.internal.R.drawable.blue_fish36,
//com.android.internal.R.drawable.blue_fish37,
com.android.internal.R.drawable.blue_fish38,
//com.android.internal.R.drawable.blue_fish39,
com.android.internal.R.drawable.blue_fish40,
//com.android.internal.R.drawable.blue_fish41,
com.android.internal.R.drawable.blue_fish42,
//com.android.internal.R.drawable.blue_fish43,
com.android.internal.R.drawable.blue_fish44,
//com.android.internal.R.drawable.blue_fish45,
com.android.internal.R.drawable.blue_fish46,
//com.android.internal.R.drawable.blue_fish47,
com.android.internal.R.drawable.blue_fish48,
//com.android.internal.R.drawable.blue_fish49,
com.android.internal.R.drawable.blue_fish50,
//com.android.internal.R.drawable.blue_fish51,
com.android.internal.R.drawable.blue_fish52,
//com.android.internal.R.drawable.blue_fish53,
com.android.internal.R.drawable.blue_fish54,
//com.android.internal.R.drawable.blue_fish55,
com.android.internal.R.drawable.blue_fish56,
//com.android.internal.R.drawable.blue_fish57,
com.android.internal.R.drawable.blue_fish58,
//com.android.internal.R.drawable.blue_fish59,
com.android.internal.R.drawable.blue_fish60,
//com.android.internal.R.drawable.blue_fish61,
com.android.internal.R.drawable.blue_fish62,
//com.android.internal.R.drawable.blue_fish63,
com.android.internal.R.drawable.blue_fish64,
com.android.internal.R.drawable.blue_fish65,
com.android.internal.R.drawable.blue_fish66,
com.android.internal.R.drawable.blue_fish67,
com.android.internal.R.drawable.blue_fish68,
com.android.internal.R.drawable.blue_fish69,
com.android.internal.R.drawable.blue_fish70,
com.android.internal.R.drawable.blue_fish71
};
bitmaps = new Bitmap[bitmapRids.length];
break;
case 2:
bitmapRids = new int[]{
com.android.internal.R.drawable.yellow_fish00,
com.android.internal.R.drawable.yellow_fish01,
com.android.internal.R.drawable.yellow_fish02,
com.android.internal.R.drawable.yellow_fish03,
com.android.internal.R.drawable.yellow_fish04,
com.android.internal.R.drawable.yellow_fish05,
com.android.internal.R.drawable.yellow_fish06,
com.android.internal.R.drawable.yellow_fish07,
com.android.internal.R.drawable.yellow_fish08,
com.android.internal.R.drawable.yellow_fish09,
com.android.internal.R.drawable.yellow_fish10,
//com.android.internal.R.drawable.yellow_fish11,
com.android.internal.R.drawable.yellow_fish12,
//com.android.internal.R.drawable.yellow_fish13,
com.android.internal.R.drawable.yellow_fish14,
//com.android.internal.R.drawable.yellow_fish15,
com.android.internal.R.drawable.yellow_fish16,
//com.android.internal.R.drawable.yellow_fish17,
com.android.internal.R.drawable.yellow_fish18,
//com.android.internal.R.drawable.yellow_fish19,
com.android.internal.R.drawable.yellow_fish20,
//com.android.internal.R.drawable.yellow_fish21,
com.android.internal.R.drawable.yellow_fish22,
//com.android.internal.R.drawable.yellow_fish23,
com.android.internal.R.drawable.yellow_fish24,
//com.android.internal.R.drawable.yellow_fish25,
com.android.internal.R.drawable.yellow_fish26,
//com.android.internal.R.drawable.yellow_fish27,
com.android.internal.R.drawable.yellow_fish28,
//com.android.internal.R.drawable.yellow_fish29,
com.android.internal.R.drawable.yellow_fish30,
//com.android.internal.R.drawable.yellow_fish31,
com.android.internal.R.drawable.yellow_fish32,
//com.android.internal.R.drawable.yellow_fish33,
com.android.internal.R.drawable.yellow_fish34,
//com.android.internal.R.drawable.yellow_fish35,
com.android.internal.R.drawable.yellow_fish36,
//com.android.internal.R.drawable.yellow_fish37,
com.android.internal.R.drawable.yellow_fish38,
//com.android.internal.R.drawable.yellow_fish39,
com.android.internal.R.drawable.yellow_fish40,
//com.android.internal.R.drawable.yellow_fish41,
com.android.internal.R.drawable.yellow_fish42,
//com.android.internal.R.drawable.yellow_fish43,
com.android.internal.R.drawable.yellow_fish44,
//com.android.internal.R.drawable.yellow_fish45,
com.android.internal.R.drawable.yellow_fish46,
//com.android.internal.R.drawable.yellow_fish47,
com.android.internal.R.drawable.yellow_fish48,
//com.android.internal.R.drawable.yellow_fish49,
com.android.internal.R.drawable.yellow_fish50,
//com.android.internal.R.drawable.yellow_fish51,
com.android.internal.R.drawable.yellow_fish52,
//com.android.internal.R.drawable.yellow_fish53,
com.android.internal.R.drawable.yellow_fish54,
//com.android.internal.R.drawable.yellow_fish55,
com.android.internal.R.drawable.yellow_fish56,
//com.android.internal.R.drawable.yellow_fish57,
com.android.internal.R.drawable.yellow_fish58,
//com.android.internal.R.drawable.yellow_fish59,
com.android.internal.R.drawable.yellow_fish60,
//com.android.internal.R.drawable.yellow_fish61,
com.android.internal.R.drawable.yellow_fish62,
//com.android.internal.R.drawable.yellow_fish63,
com.android.internal.R.drawable.yellow_fish64,
com.android.internal.R.drawable.yellow_fish65,
com.android.internal.R.drawable.yellow_fish66,
com.android.internal.R.drawable.yellow_fish67,
com.android.internal.R.drawable.yellow_fish68,
com.android.internal.R.drawable.yellow_fish69,
com.android.internal.R.drawable.yellow_fish70,
com.android.internal.R.drawable.yellow_fish71
};
bitmaps = new Bitmap[bitmapRids.length];
break;
case 3:
bitmapRids = new int[]{
com.android.internal.R.drawable.orange_fish00,
com.android.internal.R.drawable.orange_fish01,
com.android.internal.R.drawable.orange_fish02,
com.android.internal.R.drawable.orange_fish03,
com.android.internal.R.drawable.orange_fish04,
com.android.internal.R.drawable.orange_fish05,
com.android.internal.R.drawable.orange_fish06,
//com.android.internal.R.drawable.orange_fish07,
com.android.internal.R.drawable.orange_fish08,
//com.android.internal.R.drawable.orange_fish09,
com.android.internal.R.drawable.orange_fish10,
//com.android.internal.R.drawable.orange_fish11,
com.android.internal.R.drawable.orange_fish12,
//com.android.internal.R.drawable.orange_fish13,
com.android.internal.R.drawable.orange_fish14,
//com.android.internal.R.drawable.orange_fish15,
com.android.internal.R.drawable.orange_fish16,
//com.android.internal.R.drawable.orange_fish17,
com.android.internal.R.drawable.orange_fish18,
//com.android.internal.R.drawable.orange_fish19,
com.android.internal.R.drawable.orange_fish20,
//com.android.internal.R.drawable.orange_fish21,
com.android.internal.R.drawable.orange_fish22,
//com.android.internal.R.drawable.orange_fish23,
com.android.internal.R.drawable.orange_fish24,
//com.android.internal.R.drawable.orange_fish25,
com.android.internal.R.drawable.orange_fish26,
//com.android.internal.R.drawable.orange_fish27,
com.android.internal.R.drawable.orange_fish28,
//com.android.internal.R.drawable.orange_fish29,
com.android.internal.R.drawable.orange_fish30,
//com.android.internal.R.drawable.orange_fish31,
com.android.internal.R.drawable.orange_fish32,
//com.android.internal.R.drawable.orange_fish33,
com.android.internal.R.drawable.orange_fish34,
//com.android.internal.R.drawable.orange_fish35,
com.android.internal.R.drawable.orange_fish36,
//com.android.internal.R.drawable.orange_fish37,
com.android.internal.R.drawable.orange_fish38,
//com.android.internal.R.drawable.orange_fish39,
com.android.internal.R.drawable.orange_fish40,
//com.android.internal.R.drawable.orange_fish41,
com.android.internal.R.drawable.orange_fish42,
//com.android.internal.R.drawable.orange_fish43,
com.android.internal.R.drawable.orange_fish44,
//com.android.internal.R.drawable.orange_fish45,
com.android.internal.R.drawable.orange_fish46,
//com.android.internal.R.drawable.orange_fish47,
com.android.internal.R.drawable.orange_fish48,
//com.android.internal.R.drawable.orange_fish49,
com.android.internal.R.drawable.orange_fish50,
//com.android.internal.R.drawable.orange_fish51,
com.android.internal.R.drawable.orange_fish52,
//com.android.internal.R.drawable.orange_fish53,
com.android.internal.R.drawable.orange_fish54,
//com.android.internal.R.drawable.orange_fish55,
com.android.internal.R.drawable.orange_fish56,
//com.android.internal.R.drawable.orange_fish57,
com.android.internal.R.drawable.orange_fish58,
//com.android.internal.R.drawable.orange_fish59,
com.android.internal.R.drawable.orange_fish60,
//com.android.internal.R.drawable.orange_fish61,
com.android.internal.R.drawable.orange_fish62,
//com.android.internal.R.drawable.orange_fish63,
com.android.internal.R.drawable.orange_fish64,
com.android.internal.R.drawable.orange_fish65,
com.android.internal.R.drawable.orange_fish66,
com.android.internal.R.drawable.orange_fish67,
com.android.internal.R.drawable.orange_fish68,
com.android.internal.R.drawable.orange_fish69,
com.android.internal.R.drawable.orange_fish70,
com.android.internal.R.drawable.orange_fish71
};
bitmaps = new Bitmap[bitmapRids.length];
break;
case 4:
bitmapRids = new int[]{
com.android.internal.R.drawable.white_fish00,
com.android.internal.R.drawable.white_fish01,
com.android.internal.R.drawable.white_fish02,
com.android.internal.R.drawable.white_fish03,
com.android.internal.R.drawable.white_fish04,
com.android.internal.R.drawable.white_fish05,
com.android.internal.R.drawable.white_fish06,
//com.android.internal.R.drawable.white_fish07,
com.android.internal.R.drawable.white_fish08,
//com.android.internal.R.drawable.white_fish09,
com.android.internal.R.drawable.white_fish10,
//com.android.internal.R.drawable.white_fish11,
com.android.internal.R.drawable.white_fish12,
//com.android.internal.R.drawable.white_fish13,
com.android.internal.R.drawable.white_fish14,
//com.android.internal.R.drawable.white_fish15,
com.android.internal.R.drawable.white_fish16,
//com.android.internal.R.drawable.white_fish17,
com.android.internal.R.drawable.white_fish18,
//com.android.internal.R.drawable.white_fish19,
com.android.internal.R.drawable.white_fish20,
//com.android.internal.R.drawable.white_fish21,
com.android.internal.R.drawable.white_fish22,
//com.android.internal.R.drawable.white_fish23,
com.android.internal.R.drawable.white_fish24,
//com.android.internal.R.drawable.white_fish25,
com.android.internal.R.drawable.white_fish26,
//com.android.internal.R.drawable.white_fish27,
com.android.internal.R.drawable.white_fish28,
//com.android.internal.R.drawable.white_fish29,
com.android.internal.R.drawable.white_fish30,
//com.android.internal.R.drawable.white_fish31,
com.android.internal.R.drawable.white_fish32,
//com.android.internal.R.drawable.white_fish33,
com.android.internal.R.drawable.white_fish34,
//com.android.internal.R.drawable.white_fish35,
com.android.internal.R.drawable.white_fish36,
//com.android.internal.R.drawable.white_fish37,
com.android.internal.R.drawable.white_fish38,
//com.android.internal.R.drawable.white_fish39,
com.android.internal.R.drawable.white_fish40,
//com.android.internal.R.drawable.white_fish41,
com.android.internal.R.drawable.white_fish42,
//com.android.internal.R.drawable.white_fish43,
com.android.internal.R.drawable.white_fish44,
//com.android.internal.R.drawable.white_fish45,
com.android.internal.R.drawable.white_fish46,
//com.android.internal.R.drawable.white_fish47,
com.android.internal.R.drawable.white_fish48,
//com.android.internal.R.drawable.white_fish49,
com.android.internal.R.drawable.white_fish50,
//com.android.internal.R.drawable.white_fish51,
com.android.internal.R.drawable.white_fish52,
//com.android.internal.R.drawable.white_fish53,
com.android.internal.R.drawable.white_fish54,
//com.android.internal.R.drawable.white_fish55,
com.android.internal.R.drawable.white_fish56,
//com.android.internal.R.drawable.white_fish57,
com.android.internal.R.drawable.white_fish58,
//com.android.internal.R.drawable.white_fish59,
com.android.internal.R.drawable.white_fish60,
//com.android.internal.R.drawable.white_fish61,
com.android.internal.R.drawable.white_fish62,
//com.android.internal.R.drawable.white_fish63,
com.android.internal.R.drawable.white_fish64,
com.android.internal.R.drawable.white_fish65,
com.android.internal.R.drawable.white_fish66,
com.android.internal.R.drawable.white_fish67,
com.android.internal.R.drawable.white_fish68,
com.android.internal.R.drawable.white_fish69,
com.android.internal.R.drawable.white_fish70,
com.android.internal.R.drawable.white_fish71
};
bitmaps = new Bitmap[bitmapRids.length];
break;
case 5:
bitmapRids = new int[]{
com.android.internal.R.drawable.light_fish00,
com.android.internal.R.drawable.light_fish01,
com.android.internal.R.drawable.light_fish02,
com.android.internal.R.drawable.light_fish03,
com.android.internal.R.drawable.light_fish04,
com.android.internal.R.drawable.light_fish05,
com.android.internal.R.drawable.light_fish06,
//com.android.internal.R.drawable.light_fish07,
com.android.internal.R.drawable.light_fish08,
//com.android.internal.R.drawable.light_fish09,
com.android.internal.R.drawable.light_fish10,
//com.android.internal.R.drawable.light_fish11,
com.android.internal.R.drawable.light_fish12,
//com.android.internal.R.drawable.light_fish13,
com.android.internal.R.drawable.light_fish14,
//com.android.internal.R.drawable.light_fish15,
com.android.internal.R.drawable.light_fish16,
//com.android.internal.R.drawable.light_fish17,
com.android.internal.R.drawable.light_fish18,
//com.android.internal.R.drawable.light_fish19,
com.android.internal.R.drawable.light_fish20,
//com.android.internal.R.drawable.light_fish21,
com.android.internal.R.drawable.light_fish22,
//com.android.internal.R.drawable.light_fish23,
com.android.internal.R.drawable.light_fish24,
//com.android.internal.R.drawable.light_fish25,
com.android.internal.R.drawable.light_fish26,
//com.android.internal.R.drawable.light_fish27,
com.android.internal.R.drawable.light_fish28,
//com.android.internal.R.drawable.light_fish29,
com.android.internal.R.drawable.light_fish30,
//com.android.internal.R.drawable.light_fish31,
com.android.internal.R.drawable.light_fish32,
//com.android.internal.R.drawable.light_fish33,
com.android.internal.R.drawable.light_fish34,
//com.android.internal.R.drawable.light_fish35,
com.android.internal.R.drawable.light_fish36,
//com.android.internal.R.drawable.light_fish37,
com.android.internal.R.drawable.light_fish38,
//com.android.internal.R.drawable.light_fish39,
com.android.internal.R.drawable.light_fish40,
//com.android.internal.R.drawable.light_fish41,
com.android.internal.R.drawable.light_fish42,
//com.android.internal.R.drawable.light_fish43,
com.android.internal.R.drawable.light_fish44,
//com.android.internal.R.drawable.light_fish45,
com.android.internal.R.drawable.light_fish46,
//com.android.internal.R.drawable.light_fish47,
com.android.internal.R.drawable.light_fish48,
//com.android.internal.R.drawable.light_fish49,
com.android.internal.R.drawable.light_fish50,
//com.android.internal.R.drawable.light_fish51,
com.android.internal.R.drawable.light_fish52,
//com.android.internal.R.drawable.light_fish53,
com.android.internal.R.drawable.light_fish54,
//com.android.internal.R.drawable.light_fish55,
com.android.internal.R.drawable.light_fish56,
//com.android.internal.R.drawable.light_fish57,
com.android.internal.R.drawable.light_fish58,
//com.android.internal.R.drawable.light_fish59,
com.android.internal.R.drawable.light_fish60,
//com.android.internal.R.drawable.light_fish61,
com.android.internal.R.drawable.light_fish62,
//com.android.internal.R.drawable.light_fish63,
com.android.internal.R.drawable.light_fish64,
com.android.internal.R.drawable.light_fish65,
com.android.internal.R.drawable.light_fish66,
com.android.internal.R.drawable.light_fish67,
com.android.internal.R.drawable.light_fish68,
com.android.internal.R.drawable.light_fish69,
com.android.internal.R.drawable.light_fish70,
com.android.internal.R.drawable.light_fish71
};
bitmaps = new Bitmap[bitmapRids.length];
break;
case 8:
bitmapRids = new int[]{
com.android.internal.R.drawable.light_ink00,
com.android.internal.R.drawable.light_ink01,
com.android.internal.R.drawable.light_ink02,
com.android.internal.R.drawable.light_ink03,
com.android.internal.R.drawable.light_ink04,
com.android.internal.R.drawable.light_ink05,
com.android.internal.R.drawable.light_ink06,
//com.android.internal.R.drawable.light_ink07,
com.android.internal.R.drawable.light_ink08,
//com.android.internal.R.drawable.light_ink09,
com.android.internal.R.drawable.light_ink10,
//com.android.internal.R.drawable.light_ink11,
com.android.internal.R.drawable.light_ink12,
//com.android.internal.R.drawable.light_ink13,
com.android.internal.R.drawable.light_ink14,
//com.android.internal.R.drawable.light_ink15,
com.android.internal.R.drawable.light_ink16,
//com.android.internal.R.drawable.light_ink17,
com.android.internal.R.drawable.light_ink18,
//com.android.internal.R.drawable.light_ink19,
com.android.internal.R.drawable.light_ink20,
//com.android.internal.R.drawable.light_ink21,
com.android.internal.R.drawable.light_ink22,
//com.android.internal.R.drawable.light_ink23,
com.android.internal.R.drawable.light_ink24,
//com.android.internal.R.drawable.light_ink25,
com.android.internal.R.drawable.light_ink26,
//com.android.internal.R.drawable.light_ink27,
com.android.internal.R.drawable.light_ink28,
//com.android.internal.R.drawable.light_ink29,
com.android.internal.R.drawable.light_ink30,
//com.android.internal.R.drawable.light_ink31,
com.android.internal.R.drawable.light_ink32,
//com.android.internal.R.drawable.light_ink33,
com.android.internal.R.drawable.light_ink34,
//com.android.internal.R.drawable.light_ink35,
com.android.internal.R.drawable.light_ink36,
//com.android.internal.R.drawable.light_ink37,
com.android.internal.R.drawable.light_ink38,
//com.android.internal.R.drawable.light_ink39,
com.android.internal.R.drawable.light_ink40,
//com.android.internal.R.drawable.light_ink41,
com.android.internal.R.drawable.light_ink42,
//com.android.internal.R.drawable.light_ink43,
com.android.internal.R.drawable.light_ink44,
//com.android.internal.R.drawable.light_ink45,
com.android.internal.R.drawable.light_ink46,
//com.android.internal.R.drawable.light_ink47,
com.android.internal.R.drawable.light_ink48,
//com.android.internal.R.drawable.light_ink49,
com.android.internal.R.drawable.light_ink50,
//com.android.internal.R.drawable.light_ink51,
com.android.internal.R.drawable.light_ink52,
//com.android.internal.R.drawable.light_ink53,
com.android.internal.R.drawable.light_ink54,
//com.android.internal.R.drawable.light_ink55,
com.android.internal.R.drawable.light_ink56,
//com.android.internal.R.drawable.light_ink57,
com.android.internal.R.drawable.light_ink58,
//com.android.internal.R.drawable.light_ink59,
com.android.internal.R.drawable.light_ink60,
//com.android.internal.R.drawable.light_ink61,
com.android.internal.R.drawable.light_ink62,
//com.android.internal.R.drawable.light_ink63,
com.android.internal.R.drawable.light_ink64,
com.android.internal.R.drawable.light_ink65,
com.android.internal.R.drawable.light_ink66,
com.android.internal.R.drawable.light_ink67,
com.android.internal.R.drawable.light_ink68,
com.android.internal.R.drawable.light_ink69,
com.android.internal.R.drawable.light_ink70,
com.android.internal.R.drawable.light_ink71
};
bitmaps = new Bitmap[bitmapRids.length];
break;
case 7:
bitmapRids = new int[]{
com.android.internal.R.drawable.white_ink00,
com.android.internal.R.drawable.white_ink01,
com.android.internal.R.drawable.white_ink02,
com.android.internal.R.drawable.white_ink03,
com.android.internal.R.drawable.white_ink04,
com.android.internal.R.drawable.white_ink05,
com.android.internal.R.drawable.white_ink06,
//com.android.internal.R.drawable.white_ink07,
com.android.internal.R.drawable.white_ink08,
//com.android.internal.R.drawable.white_ink09,
com.android.internal.R.drawable.white_ink10,
//com.android.internal.R.drawable.white_ink11,
com.android.internal.R.drawable.white_ink12,
//com.android.internal.R.drawable.white_ink13,
com.android.internal.R.drawable.white_ink14,
//com.android.internal.R.drawable.white_ink15,
com.android.internal.R.drawable.white_ink16,
//com.android.internal.R.drawable.white_ink17,
com.android.internal.R.drawable.white_ink18,
//com.android.internal.R.drawable.white_ink19,
com.android.internal.R.drawable.white_ink20,
//com.android.internal.R.drawable.white_ink21,
com.android.internal.R.drawable.white_ink22,
//com.android.internal.R.drawable.white_ink23,
com.android.internal.R.drawable.white_ink24,
//com.android.internal.R.drawable.white_ink25,
com.android.internal.R.drawable.white_ink26,
//com.android.internal.R.drawable.white_ink27,
com.android.internal.R.drawable.white_ink28,
//com.android.internal.R.drawable.white_ink29,
com.android.internal.R.drawable.white_ink30,
//com.android.internal.R.drawable.white_ink31,
com.android.internal.R.drawable.white_ink32,
//com.android.internal.R.drawable.white_ink33,
com.android.internal.R.drawable.white_ink34,
//com.android.internal.R.drawable.white_ink35,
com.android.internal.R.drawable.white_ink36,
//com.android.internal.R.drawable.white_ink37,
com.android.internal.R.drawable.white_ink38,
//com.android.internal.R.drawable.white_ink39,
com.android.internal.R.drawable.white_ink40,
//com.android.internal.R.drawable.white_ink41,
com.android.internal.R.drawable.white_ink42,
//com.android.internal.R.drawable.white_ink43,
com.android.internal.R.drawable.white_ink44,
//com.android.internal.R.drawable.white_ink45,
com.android.internal.R.drawable.white_ink46,
//com.android.internal.R.drawable.white_ink47,
com.android.internal.R.drawable.white_ink48,
//com.android.internal.R.drawable.white_ink49,
com.android.internal.R.drawable.white_ink50,
//com.android.internal.R.drawable.white_ink51,
com.android.internal.R.drawable.white_ink52,
//com.android.internal.R.drawable.white_ink53,
com.android.internal.R.drawable.white_ink54,
//com.android.internal.R.drawable.white_ink55,
com.android.internal.R.drawable.white_ink56,
//com.android.internal.R.drawable.white_ink57,
com.android.internal.R.drawable.white_ink58,
//com.android.internal.R.drawable.white_ink59,
com.android.internal.R.drawable.white_ink60,
//com.android.internal.R.drawable.white_ink61,
com.android.internal.R.drawable.white_ink62,
//com.android.internal.R.drawable.white_ink63,
com.android.internal.R.drawable.white_ink64,
com.android.internal.R.drawable.white_ink65,
com.android.internal.R.drawable.white_ink66,
com.android.internal.R.drawable.white_ink67,
com.android.internal.R.drawable.white_ink68,
com.android.internal.R.drawable.white_ink69,
com.android.internal.R.drawable.white_ink70,
com.android.internal.R.drawable.white_ink71
};
bitmaps = new Bitmap[bitmapRids.length];
break;
case 6:
bitmapRids = new int[]{
com.android.internal.R.drawable.purple_ink00,
com.android.internal.R.drawable.purple_ink01,
com.android.internal.R.drawable.purple_ink02,
com.android.internal.R.drawable.purple_ink03,
com.android.internal.R.drawable.purple_ink04,
com.android.internal.R.drawable.purple_ink05,
com.android.internal.R.drawable.purple_ink06,
//com.android.internal.R.drawable.purple_ink07,
com.android.internal.R.drawable.purple_ink08,
//com.android.internal.R.drawable.purple_ink09,
com.android.internal.R.drawable.purple_ink10,
//com.android.internal.R.drawable.purple_ink11,
com.android.internal.R.drawable.purple_ink12,
//com.android.internal.R.drawable.purple_ink13,
com.android.internal.R.drawable.purple_ink14,
//com.android.internal.R.drawable.purple_ink15,
com.android.internal.R.drawable.purple_ink16,
//com.android.internal.R.drawable.purple_ink17,
com.android.internal.R.drawable.purple_ink18,
//com.android.internal.R.drawable.purple_ink19,
com.android.internal.R.drawable.purple_ink20,
//com.android.internal.R.drawable.purple_ink21,
com.android.internal.R.drawable.purple_ink22,
//com.android.internal.R.drawable.purple_ink23,
com.android.internal.R.drawable.purple_ink24,
//com.android.internal.R.drawable.purple_ink25,
com.android.internal.R.drawable.purple_ink26,
//com.android.internal.R.drawable.purple_ink27,
com.android.internal.R.drawable.purple_ink28,
//com.android.internal.R.drawable.purple_ink29,
com.android.internal.R.drawable.purple_ink30,
//com.android.internal.R.drawable.purple_ink31,
com.android.internal.R.drawable.purple_ink32,
//com.android.internal.R.drawable.purple_ink33,
com.android.internal.R.drawable.purple_ink34,
//com.android.internal.R.drawable.purple_ink35,
com.android.internal.R.drawable.purple_ink36,
//com.android.internal.R.drawable.purple_ink37,
com.android.internal.R.drawable.purple_ink38,
//com.android.internal.R.drawable.purple_ink39,
com.android.internal.R.drawable.purple_ink40,
//com.android.internal.R.drawable.purple_ink41,
com.android.internal.R.drawable.purple_ink42,
//com.android.internal.R.drawable.purple_ink43,
com.android.internal.R.drawable.purple_ink44,
//com.android.internal.R.drawable.purple_ink45,
com.android.internal.R.drawable.purple_ink46,
//com.android.internal.R.drawable.purple_ink47,
com.android.internal.R.drawable.purple_ink48,
//com.android.internal.R.drawable.purple_ink49,
com.android.internal.R.drawable.purple_ink50,
//com.android.internal.R.drawable.purple_ink51,
com.android.internal.R.drawable.purple_ink52,
//com.android.internal.R.drawable.purple_ink53,
com.android.internal.R.drawable.purple_ink54,
//com.android.internal.R.drawable.purple_ink55,
com.android.internal.R.drawable.purple_ink56,
//com.android.internal.R.drawable.purple_ink57,
com.android.internal.R.drawable.purple_ink58,
//com.android.internal.R.drawable.purple_ink59,
com.android.internal.R.drawable.purple_ink60,
//com.android.internal.R.drawable.purple_ink61,
com.android.internal.R.drawable.purple_ink62,
//com.android.internal.R.drawable.purple_ink63,
com.android.internal.R.drawable.purple_ink64,
com.android.internal.R.drawable.purple_ink65,
com.android.internal.R.drawable.purple_ink66,
com.android.internal.R.drawable.purple_ink67,
com.android.internal.R.drawable.purple_ink68,
com.android.internal.R.drawable.purple_ink69,
com.android.internal.R.drawable.purple_ink70,
com.android.internal.R.drawable.purple_ink71
};
bitmaps = new Bitmap[bitmapRids.length];
break;
default:
break;
}
redCarp(cont);
}
/**
*回收数组
*/
public void recycleBitmapOnly(){
for(int i = 0;i < bitmaps.length;i ++) {
if(bitmaps[i] != null ) {
if(!bitmaps[i].isRecycled()) {
bitmaps[i].recycle();
}
bitmaps[i] = null;
}
}
System.gc();
}
/**
*初始化各变量
*/
public void reset(){
recycleBitmapOnly();
animateIndex=0;
isPause = false;
isStop = true;
isForward = false;
cacheLength = 20;
cacheBegin = 0;
cacheEnd = cacheLength + cacheBegin;
}
int cacheLength = 20,cacheBegin = 0,cacheEnd = cacheLength + cacheBegin;
public void redCarp(Context context){
for(int i = 0;i < bitmapRids.length;i ++) {
if(bitmaps[i] != null) {
if(i < cacheBegin || i > cacheEnd) {
if(!bitmaps[i].isRecycled()) {
bitmaps[i].recycle();
}
bitmaps[i] = null;
} else {
if(bitmaps[i].isRecycled()) {
bitmaps[i] = readBitMap(context,bitmapRids[i]);
}
}
} else {
if(i >= cacheBegin && i <= cacheEnd) {
bitmaps[i] = readBitMap(context,bitmapRids[i]);
}
}
}
}
/**
*控制动态壁纸
*/
boolean isPause = false;
boolean isStop = true;
boolean isForward = false;
public void forward(){
isPause = false;
isForward = true;
if(isStop) {
isStop = false;
liveImageThread.start();
}
}
public void back(){
isPause = false;
isForward = false;
if(isStop) {
isStop = false;
liveImageThread.start();
}
}
public void pause(){
isPause = true;
}
public void stop(){
isStop = true;
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
int currentIndex = animateIndex;
if(currentIndex > bitmaps.length -1){
currentIndex = bitmaps.length - 1;
}
if(currentIndex < 0){
currentIndex = 0;
}
if(bitmaps[currentIndex] != null && !bitmaps[currentIndex].isRecycled())
canvas.drawBitmap(bitmaps[currentIndex], 0, 0, paint);
}
/**
*帧动画的运行时间处理
*/
public void run() {
while(true){
if(isStop) break;
if(!isPause) {
if(isForward) {
animateIndex++;
//animateIndex = animateIndex+2;
if(animateIndex >= bitmaps.length -1){
animateIndex = bitmaps.length - 1;
pause();
}
} else {
animateIndex--;
//animateIndex = animateIndex - 2;
if(animateIndex <= 0){
animateIndex = 0;
pause();
}
}
this.postInvalidate();
cacheBegin = animateIndex - cacheLength / 2;
if(cacheBegin < 0) {
cacheBegin = 0;
}
cacheEnd = cacheBegin + cacheLength;
if(cacheEnd > bitmapRids.length - 1) {
cacheEnd = bitmapRids.length - 1;
cacheBegin = cacheEnd - cacheLength;
}
redCarp(getContext());
}
try {
if(isForward){
switch (mWallPaperIndex) {
case 0:
Thread.sleep(mPlaybackSpeed);//25
break;
case 1:
Thread.sleep(mPlaybackSpeed);//25
break;
case 2:
Thread.sleep(mPlaybackSpeed);//25
break;
case 3:
Thread.sleep(mPlaybackSpeed);//25
break;
case 4:
Thread.sleep(mPlaybackSpeed);//25
break;
case 5:
Thread.sleep(mPlaybackSpeed+20);//45
break;
case 6:
Thread.sleep(mPlaybackSpeed);//25
break;
case 7:
Thread.sleep(mPlaybackSpeed);//25
break;
case 8:
Thread.sleep(mPlaybackSpeed);//25
break;
default:
break;
}
}else{
switch (mWallPaperIndex) {
case 0:
Thread.sleep(mPlaybackSpeed);//13
break;
case 1:
Thread.sleep(mPlaybackSpeed);//13
break;
case 2:
Thread.sleep(mPlaybackSpeed+7);//20
break;
case 3:
Thread.sleep(mPlaybackSpeed);//13
break;
case 4:
Thread.sleep(mPlaybackSpeed+3);//16
break;
case 5:
Thread.sleep(mPlaybackSpeed+10);//23
break;
case 6:
Thread.sleep(mPlaybackSpeed);//13
break;
case 7:
Thread.sleep(mPlaybackSpeed);//13
break;
case 8:
Thread.sleep(mPlaybackSpeed);//13
break;
default:
break;
}
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
long mPlaybackSpeed=13;
public void setPlaybackSpeed(long timeDistance,boolean forward){
mPlaybackSpeed=125;
if(timeDistance < 1000){
mPlaybackSpeed = 93;
if(timeDistance < 500){
mPlaybackSpeed = 58;
if(timeDistance < 250){
mPlaybackSpeed =13;
/*if(timeDistance < 175 && forward){
mPlaybackSpeed = 8;
}*/
}
}
}
}
}