Skip to content

Commit

Permalink
Fixes Android crash react-native-component#49
Browse files Browse the repository at this point in the history
  • Loading branch information
webraptor authored Apr 10, 2018
1 parent 08293d1 commit 4579305
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ protected static Activity getActivity() {
return wr_activity.get();
}

protected static boolean hasActivity() {
return (wr_activity != null);
}

public static void openSplashScreen(Activity activity) {
openSplashScreen(activity, false);
}
Expand All @@ -49,7 +53,7 @@ public static void openSplashScreen(final Activity activity, final boolean isFul
activity.runOnUiThread(new Runnable() {
public void run() {

if(!getActivity().isFinishing()) {
if(hasActivity() && !getActivity().isFinishing()) {
Context context = getActivity();
imageView = new ImageView(context);

Expand Down Expand Up @@ -78,9 +82,10 @@ public void run() {
}

public static void removeSplashScreen(Activity activity, final int animationType,final int duration) {
if (activity == null) {
if (hasActivity()) {
activity = getActivity();
if(activity == null) return;
} else {
return;
}
activity.runOnUiThread(new Runnable() {
public void run() {
Expand Down

0 comments on commit 4579305

Please sign in to comment.