4
4
import android .content .Intent ;
5
5
import android .graphics .Color ;
6
6
import android .os .Bundle ;
7
+ import android .support .v4 .content .ContextCompat ;
7
8
import android .view .Gravity ;
8
9
import android .view .View ;
9
10
22
23
*/
23
24
public class ToastActivity extends BaseBackActivity {
24
25
26
+ View toastView ;
27
+
25
28
public static void start (Context context ) {
26
29
Intent starter = new Intent (context , ToastActivity .class );
27
30
context .startActivity (starter );
@@ -46,11 +49,13 @@ public void initView(Bundle savedInstanceState, View view) {
46
49
findViewById (R .id .btn_show_long_toast_safe ).setOnClickListener (this );
47
50
findViewById (R .id .btn_show_long_toast ).setOnClickListener (this );
48
51
findViewById (R .id .btn_show_green_font ).setOnClickListener (this );
49
- findViewById (R .id .btn_show_custom_bg ).setOnClickListener (this );
52
+ findViewById (R .id .btn_show_bg_color ).setOnClickListener (this );
53
+ findViewById (R .id .btn_show_bg_resource ).setOnClickListener (this );
50
54
findViewById (R .id .btn_show_span ).setOnClickListener (this );
51
55
findViewById (R .id .btn_show_custom_view ).setOnClickListener (this );
52
56
findViewById (R .id .btn_show_middle ).setOnClickListener (this );
53
57
findViewById (R .id .btn_cancel_toast ).setOnClickListener (this );
58
+ toastView = findViewById (R .id .btn_cancel_toast );
54
59
}
55
60
56
61
@ Override
@@ -85,10 +90,14 @@ public void run() {
85
90
ToastUtils .showLong (R .string .toast_long );
86
91
break ;
87
92
case R .id .btn_show_green_font :
88
- ToastUtils .setMessageColor (Color .GREEN );
93
+ ToastUtils .setMsgColor (Color .GREEN );
89
94
ToastUtils .showLong (R .string .toast_green_font );
90
95
break ;
91
- case R .id .btn_show_custom_bg :
96
+ case R .id .btn_show_bg_color :
97
+ ToastUtils .setBgColor (ContextCompat .getColor (this , R .color .colorAccent ));
98
+ ToastUtils .showLong (R .string .toast_bg_color );
99
+ break ;
100
+ case R .id .btn_show_bg_resource :
92
101
ToastUtils .setBgResource (R .drawable .shape_round_rect );
93
102
ToastUtils .showLong (R .string .toast_custom_bg );
94
103
break ;
@@ -102,7 +111,7 @@ public void run() {
102
111
);
103
112
break ;
104
113
case R .id .btn_show_custom_view :
105
- MyToast . showMyToast (getString (R .string .toast_custom_view ));
114
+ CustomToast . show (getString (R .string .toast_custom_view ));
106
115
break ;
107
116
case R .id .btn_show_middle :
108
117
ToastUtils .setGravity (Gravity .CENTER , 0 , 0 );
@@ -121,9 +130,9 @@ protected void onDestroy() {
121
130
}
122
131
123
132
private void resetToast () {
124
- ToastUtils .setMessageColor (0xFFFFFFFF );
133
+ ToastUtils .setMsgColor (0xFEFFFFFF );
134
+ ToastUtils .setBgColor (0xFEFFFFFF );
125
135
ToastUtils .setBgResource (-1 );
126
- ToastUtils .setView (null );
127
136
ToastUtils .setGravity (Gravity .BOTTOM | Gravity .CENTER_HORIZONTAL , 0 , getResources ().getDimensionPixelSize (R .dimen .offset_64 ));
128
137
}
129
138
}
0 commit comments