File tree Expand file tree Collapse file tree 2 files changed +34
-2
lines changed
app/src/main/java/com/luojilab/componentdemo
basiclib/src/main/java/com.luojilab.component.basiclib Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change 66import android .support .v4 .app .FragmentTransaction ;
77import android .view .View ;
88import android .widget .Button ;
9- import android .widget .Toast ;
109
10+ import com .luojilab .component .basiclib .ToastManager ;
1111import com .luojilab .component .basicres .BaseActivity ;
12+ import com .luojilab .component .basicres .BaseApplication ;
1213import com .luojilab .component .componentlib .router .Router ;
1314import com .luojilab .componentservice .readerbook .ReadBookService ;
1415import com .luojilab .router .facade .annotation .RouteNode ;
@@ -69,7 +70,7 @@ public void onClick(View v) {
6970 public void onActivityResult (int requestCode , int resultCode , Intent data ) {
7071 super .onActivityResult (requestCode , resultCode , data );
7172 if (data != null ) {
72- Toast . makeText ( this , data .getStringExtra ("result" ), Toast . LENGTH_SHORT ). show ( );
73+ ToastManager . show ( BaseApplication . getAppContext () , data .getStringExtra ("result" ));
7374 }
7475 }
7576}
Original file line number Diff line number Diff line change 1+ package com .luojilab .component .basiclib ;
2+
3+ import android .content .Context ;
4+ import android .widget .Toast ;
5+
6+ /**
7+ * Created by mrzhang on 2018/1/16.
8+ */
9+
10+ public class ToastManager {
11+
12+ private ToastManager () {
13+ }
14+
15+ public static void show (Context context , String message ) {
16+ Toast .makeText (context , message , Toast .LENGTH_SHORT ).show ();
17+ }
18+
19+ public static void show (Context context , int resId ) {
20+ show (context , context .getString (resId ));
21+ }
22+
23+ public static void show (Context context , int resId , Object ... args ) {
24+ show (context , String .format (context .getString (resId ), args ));
25+ }
26+
27+ public static void show (Context context , String message , int duration ) {
28+ Toast .makeText (context , message , duration ).show ();
29+ }
30+
31+ }
You can’t perform that action at this time.
0 commit comments