Initialize DroidFishApp.appContext earlier

This is an attempt to fix crashes reported in the play console.
This commit is contained in:
Peter Osterlund 2020-06-01 22:27:16 +02:00
parent 7d87d1fbd4
commit c4c650ce51

View File

@ -34,9 +34,8 @@ public class DroidFishApp extends Application {
private static Context appContext; private static Context appContext;
private static Toast toast; private static Toast toast;
@Override public DroidFishApp() {
public void onCreate() { super();
super.onCreate();
appContext = this; appContext = this;
} }
@ -96,11 +95,9 @@ public class DroidFishApp extends Application {
toast.cancel(); toast.cancel();
toast = null; toast = null;
} }
if (appContext != null) {
toast = Toast.makeText(appContext, resId, duration); toast = Toast.makeText(appContext, resId, duration);
toast.show(); toast.show();
} }
}
/** Show a toast after canceling current toast. */ /** Show a toast after canceling current toast. */
public static void toast(CharSequence text, int duration) { public static void toast(CharSequence text, int duration) {
@ -108,9 +105,7 @@ public class DroidFishApp extends Application {
toast.cancel(); toast.cancel();
toast = null; toast = null;
} }
if (appContext != null) {
toast = Toast.makeText(appContext, text, duration); toast = Toast.makeText(appContext, text, duration);
toast.show(); toast.show();
} }
}
} }