From 56a56f33d144c96d330bd19eae7a84137f924efc Mon Sep 17 00:00:00 2001 From: Peter Lai Date: Mon, 23 Nov 2015 10:47:06 -0800 Subject: [PATCH] add method to determine if current activity is null Reviewed By: andreicoman11 Differential Revision: D2680281 fb-gh-sync-id: ac158fb55dd60d05b7e3444d68e06a010e04eef4 --- .../main/java/com/facebook/react/bridge/ReactContext.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java index ee669462a..ca2d40c73 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java @@ -225,15 +225,17 @@ public class ReactContext extends ContextWrapper { } } + public boolean hasCurrentActivity() { + return mCurrentActivity != null; + } + /** * Same as {@link Activity#startActivityForResult(Intent, int)}, this just redirects the call to * the current activity. Returns whether the activity was started, as this might fail if this * was called before the context is in the right state. */ public boolean startActivityForResult(Intent intent, int code, Bundle bundle) { - if (mCurrentActivity == null) { - return false; - } + Assertions.assertNotNull(mCurrentActivity); mCurrentActivity.startActivityForResult(intent, code, bundle); return true; }