This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 550
Expand file tree
/
Copy pathNumberPickerErrorTextView.java
More file actions
84 lines (69 loc) · 2.47 KB
/
NumberPickerErrorTextView.java
File metadata and controls
84 lines (69 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package com.codetroopers.betterpickers.numberpicker;
import android.content.Context;
import android.os.Handler;
import android.support.v7.widget.AppCompatTextView;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
/**
* User: derek Date: 6/21/13 Time: 10:37 AM
*/
public class NumberPickerErrorTextView extends AppCompatTextView {
private static final long LENGTH_SHORT = 3000;
public NumberPickerErrorTextView(Context context) {
super(context);
}
public NumberPickerErrorTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public NumberPickerErrorTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public void show() {
fadeInEndHandler.removeCallbacks(hideRunnable);
Animation fadeIn = AnimationUtils.loadAnimation(getContext(), android.R.anim.fade_in);
fadeIn.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
fadeInEndHandler.postDelayed(hideRunnable, LENGTH_SHORT);
setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
startAnimation(fadeIn);
}
private Runnable hideRunnable = new Runnable() {
@Override
public void run() {
hide();
}
};
private Handler fadeInEndHandler = new Handler();
public void hide() {
fadeInEndHandler.removeCallbacks(hideRunnable);
Animation fadeOut = AnimationUtils.loadAnimation(getContext(), android.R.anim.fade_out);
fadeOut.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
setVisibility(View.INVISIBLE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
startAnimation(fadeOut);
}
public void hideImmediately() {
fadeInEndHandler.removeCallbacks(hideRunnable);
setVisibility(View.INVISIBLE);
}
}