MCPcopy Create free account
hub / github.com/GcsSloop/AndroidNote / CheckView

Class CheckView

CustomView/Advance/Code/CheckView.java:26–182  ·  view source on GitHub ↗

Author: Sloop Version: v1.0.0 Copyright: Copyright (c) 2015 Date: 2016/2/5 作者网站 作者微博 <a href="htt

Source from the content-addressed store, hash-verified

24 * </ul>
25 */
26public class CheckView extends View {
27
28 private static final int ANIM_NULL = 0; //动画状态-没有
29 private static final int ANIM_CHECK = 1; //动画状态-开启
30 private static final int ANIM_UNCHECK = 2; //动画状态-结束
31
32 private Context mContext; // 上下文
33 private int mWidth, mHeight; // 宽高
34 private Handler mHandler; // handler
35
36 private Paint mPaint;
37 private Bitmap okBitmap;
38
39 private int animCurrentPage = -1; // 当前页码
40 private int animMaxPage = 13; // 总页数
41 private int animDuration = 500; // 动画时长
42 private int animState = ANIM_NULL; // 动画状态
43
44 private boolean isCheck = false; // 是否只选中状态
45
46 public CheckView(Context context) {
47 super(context, null);
48
49 }
50
51 public CheckView(Context context, AttributeSet attrs) {
52 super(context, attrs);
53 init(context);
54 }
55
56 /**
57 * 初始化
58 * @param context
59 */
60 private void init(Context context) {
61 mContext = context;
62
63 mPaint = new Paint();
64 mPaint.setColor(0xffFF5317);
65 mPaint.setStyle(Paint.Style.FILL);
66 mPaint.setAntiAlias(true);
67
68 okBitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.checkres);
69
70 mHandler = new Handler() {
71 @Override
72 public void handleMessage(Message msg) {
73 super.handleMessage(msg);
74 if (animCurrentPage < animMaxPage && animCurrentPage >= 0) {
75 invalidate();
76 if (animState == ANIM_NULL)
77 return;
78 if (animState == ANIM_CHECK) {
79
80 animCurrentPage++;
81 } else if (animState == ANIM_UNCHECK) {
82 animCurrentPage--;
83 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected