MCPcopy Create free account
hub / github.com/asLody/VirtualApp / BaseView

Class BaseView

VirtualApp/app/src/main/java/io/virtualapp/widgets/BaseView.java:13–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11import android.view.animation.LinearInterpolator;
12
13public abstract class BaseView extends View {
14
15
16 public ValueAnimator valueAnimator;
17
18 public BaseView(Context context) {
19 this(context, null);
20 }
21
22 public BaseView(Context context, AttributeSet attrs) {
23 this(context, attrs, 0);
24 }
25
26 public BaseView(Context context, AttributeSet attrs, int defStyleAttr) {
27 super(context, attrs, defStyleAttr);
28 InitPaint();
29 }
30
31 public void startAnim() {
32 stopAnim();
33 startViewAnim(0f, 1f, 500);
34 }
35
36 public void startAnim(int time) {
37 stopAnim();
38 startViewAnim(0f, 1f, time);
39 }
40
41 public void stopAnim() {
42 if (valueAnimator != null) {
43 clearAnimation();
44
45 valueAnimator.setRepeatCount(0);
46 valueAnimator.cancel();
47 valueAnimator.end();
48 if (OnStopAnim() == 0) {
49 valueAnimator.setRepeatCount(0);
50 valueAnimator.cancel();
51 valueAnimator.end();
52 }
53
54 }
55 }
56
57 private ValueAnimator startViewAnim(float startF, final float endF, long time) {
58 valueAnimator = ValueAnimator.ofFloat(startF, endF);
59 valueAnimator.setDuration(time);
60 valueAnimator.setInterpolator(new LinearInterpolator());
61
62
63 valueAnimator.setRepeatCount(SetAnimRepeatCount());
64
65
66 if (ValueAnimator.RESTART == SetAnimRepeatMode()) {
67 valueAnimator.setRepeatMode(ValueAnimator.RESTART);
68
69 } else if (ValueAnimator.REVERSE == SetAnimRepeatMode()) {
70 valueAnimator.setRepeatMode(ValueAnimator.REVERSE);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected