Skip to content

Commit

Permalink
ToastUtils闪退问题优化
Browse files Browse the repository at this point in the history
  • Loading branch information
Airry666 committed Oct 16, 2020
1 parent 9b57ed7 commit c8b00b9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion geetolsdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
minSdkVersion 17
targetSdkVersion 26
versionCode 16
versionName "4.5.3"
versionName "4.5.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.gtdev5.geetolsdk.mylibrary.util;

import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.widget.Toast;
Expand Down Expand Up @@ -34,14 +33,11 @@ public static void init(Context context) {
* @param msg
*/
public static void showShortToast(String msg) {
if (mToast == null) {
try {
mToast = Toast.makeText(mContext, msg, Toast.LENGTH_SHORT);
} else {
mToast = Toast.makeText(mContext, msg, Toast.LENGTH_SHORT);
}
Activity activity = (Activity) mContext;
if (activity != null && !activity.isFinishing()) {
mToast.show();
} catch (Exception e) {
e.printStackTrace();
}
}

Expand All @@ -51,11 +47,11 @@ public static void showShortToast(String msg) {
* @param msg
*/
public static void showLongToast(String msg) {
if (mToast == null) {
mToast = Toast.makeText(mContext, msg, Toast.LENGTH_LONG);
} else {
try {
mToast = Toast.makeText(mContext, msg, Toast.LENGTH_LONG);
mToast.show();
} catch (Exception e) {
e.printStackTrace();
}
mToast.show();
}
}

0 comments on commit c8b00b9

Please sign in to comment.