File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
lib-ui-titlebar/src/main/java/co/bxvip/tools/toast Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 88import android .content .res .Resources ;
99import android .graphics .drawable .GradientDrawable ;
1010import android .os .Build ;
11+ import android .support .annotation .Nullable ;
1112import android .util .TypedValue ;
1213import android .view .Gravity ;
1314import android .view .View ;
@@ -51,15 +52,19 @@ private ToastUtils() {
5152// */
5253// public static void init(Application application, IToastStyle style) {
5354// initStyle(style);
54- // init(CommonInit.ctx );
55+ // init(application );
5556// }
5657
5758 /**
5859 * 初始化 ToastUtils,在Application中初始化
5960 */
60- public static void init () {
61+ public static void init (@ Nullable Application application ) {
6162 isInit = true ;
62- Application application = CommonInit .ctx ;
63+
64+ if (application == null ){
65+ application = CommonInit .ctx ;
66+ }
67+
6368 checkNullPointer (application );
6469 // 初始化 Toast 拦截器
6570 if (sInterceptor == null ) {
@@ -260,11 +265,11 @@ public static Toast getToast() {
260265 }
261266
262267 /**
263- * 检查吐司状态,如果未初始化请先调用{@link ToastUtils#init()}
268+ * 检查吐司状态,如果未初始化请先调用{@link ToastUtils#init(Application application )}
264269 */
265270 private static void checkToastState () {
266271 if (!isInit ) {
267- init ();
272+ init (null );
268273 }
269274 // 吐司工具类还没有被初始化,必须要先调用init方法进行初始化
270275 if (sToast == null ) {
You can’t perform that action at this time.
0 commit comments