From dcc2abc1f63f91e53bf01f4bc56c5b7c76300617 Mon Sep 17 00:00:00 2001 From: leeight Date: Mon, 20 Jun 2016 08:42:43 -0700 Subject: [PATCH] Fix Examples/{UIExplorer,Movies} Summary: Thanks for submitting a pull request! Please provide enough information so that others can review your pull request: (You can skip this if you're fixing a typo or adding an app to the Showcase.) UIExplorerActivity.java and MoviesActivity.java should override `getReactNativeHost` method. And this PR will fix https://github.com/facebook/react-native/issues/8215. **Test plan (required)** Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI. Make sure tests pass on both Travis and Circle CI. **Code formatting** Look around. Match the style of the rest of the codebase. See also the simple [style guide](https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md#style-guide). For more info, see the ["Pull Requests" section of our "Contributing" guidelines](https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md#pull-requests). Closes https://github.com/facebook/react-native/pull/8223 Differential Revision: D3456957 fbshipit-source-id: cc0b51e5bfaec71d210bfba81b1f7cd06a723d8c --- .../android/app/src/main/AndroidManifest.xml | 1 + .../facebook/react/movies/MoviesActivity.java | 29 ------- .../react/movies/MoviesApplication.java | 58 ++++++++++++++ .../android/app/src/main/AndroidManifest.xml | 1 + .../app/src/main/java/UIExplorerActivity.java | 78 ------------------- .../react/uiapp/UIExplorerActivity.java | 49 ++++++++++++ .../react/uiapp/UIExplorerApplication.java | 58 ++++++++++++++ 7 files changed, 167 insertions(+), 107 deletions(-) create mode 100644 Examples/Movies/android/app/src/main/java/com/facebook/react/movies/MoviesApplication.java delete mode 100644 Examples/UIExplorer/android/app/src/main/java/UIExplorerActivity.java create mode 100644 Examples/UIExplorer/android/app/src/main/java/com/facebook/react/uiapp/UIExplorerActivity.java create mode 100644 Examples/UIExplorer/android/app/src/main/java/com/facebook/react/uiapp/UIExplorerApplication.java diff --git a/Examples/Movies/android/app/src/main/AndroidManifest.xml b/Examples/Movies/android/app/src/main/AndroidManifest.xml index 9c5b43e36c1691..34f5b0bc47ee60 100644 --- a/Examples/Movies/android/app/src/main/AndroidManifest.xml +++ b/Examples/Movies/android/app/src/main/AndroidManifest.xml @@ -12,6 +12,7 @@ android:targetSdkVersion="22" /> getPackages() { - return Arrays.asList( - new MainReactPackage() - ); - } } diff --git a/Examples/Movies/android/app/src/main/java/com/facebook/react/movies/MoviesApplication.java b/Examples/Movies/android/app/src/main/java/com/facebook/react/movies/MoviesApplication.java new file mode 100644 index 00000000000000..a620b3eb699416 --- /dev/null +++ b/Examples/Movies/android/app/src/main/java/com/facebook/react/movies/MoviesApplication.java @@ -0,0 +1,58 @@ +/** + * The examples provided by Facebook are for non-commercial testing and + * evaluation purposes only. + * + * Facebook reserves all rights not expressly granted. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL + * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.facebook.react.movies; + +import android.app.Application; + +import com.facebook.react.ReactApplication; +import com.facebook.react.ReactNativeHost; +import com.facebook.react.ReactPackage; +import com.facebook.react.shell.MainReactPackage; + +import java.util.Arrays; +import java.util.List; + +import javax.annotation.Nullable; + +public class MoviesApplication extends Application implements ReactApplication { + private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { + @Override + public String getJSMainModuleName() { + return "Examples/Movies/MoviesApp.android"; + } + + @Override + public @Nullable String getBundleAssetName() { + return "MoviesApp.android.bundle"; + } + + @Override + protected boolean getUseDeveloperSupport() { + return true; + } + + @Override + protected List getPackages() { + return Arrays.asList( + new MainReactPackage() + ); + } + }; + + @Override + public ReactNativeHost getReactNativeHost() { + return mReactNativeHost; + } +} diff --git a/Examples/UIExplorer/android/app/src/main/AndroidManifest.xml b/Examples/UIExplorer/android/app/src/main/AndroidManifest.xml index 8efcb2ef4ecef6..ab2757720e6519 100644 --- a/Examples/UIExplorer/android/app/src/main/AndroidManifest.xml +++ b/Examples/UIExplorer/android/app/src/main/AndroidManifest.xml @@ -16,6 +16,7 @@ android:targetSdkVersion="23" /> getPackages() { - return Arrays.asList( - new MainReactPackage() - ); - } -} diff --git a/Examples/UIExplorer/android/app/src/main/java/com/facebook/react/uiapp/UIExplorerActivity.java b/Examples/UIExplorer/android/app/src/main/java/com/facebook/react/uiapp/UIExplorerActivity.java new file mode 100644 index 00000000000000..1867e884dc4112 --- /dev/null +++ b/Examples/UIExplorer/android/app/src/main/java/com/facebook/react/uiapp/UIExplorerActivity.java @@ -0,0 +1,49 @@ +/** + * The examples provided by Facebook are for non-commercial testing and + * evaluation purposes only. + * + * Facebook reserves all rights not expressly granted. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL + * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.facebook.react.uiapp; + +import android.os.Bundle; + +import com.facebook.react.ReactActivity; + +public class UIExplorerActivity extends ReactActivity { + private final String PARAM_ROUTE = "route"; + private Bundle mInitialProps = null; + + @Override + protected void onCreate(Bundle savedInstanceState) { + // Get remote param before calling super which uses it + Bundle bundle = getIntent().getExtras(); + if (bundle != null && bundle.containsKey(PARAM_ROUTE)) { + String routeUri = new StringBuilder("rnuiexplorer://example/") + .append(bundle.getString(PARAM_ROUTE)) + .append("Example") + .toString(); + mInitialProps = new Bundle(); + mInitialProps.putString("exampleFromAppetizeParams", routeUri); + } + super.onCreate(savedInstanceState); + } + + @Override + protected Bundle getLaunchOptions() { + return mInitialProps; + } + + @Override + protected String getMainComponentName() { + return "UIExplorerApp"; + } +} diff --git a/Examples/UIExplorer/android/app/src/main/java/com/facebook/react/uiapp/UIExplorerApplication.java b/Examples/UIExplorer/android/app/src/main/java/com/facebook/react/uiapp/UIExplorerApplication.java new file mode 100644 index 00000000000000..87dbd3735d4b3d --- /dev/null +++ b/Examples/UIExplorer/android/app/src/main/java/com/facebook/react/uiapp/UIExplorerApplication.java @@ -0,0 +1,58 @@ +/** + * The examples provided by Facebook are for non-commercial testing and + * evaluation purposes only. + * + * Facebook reserves all rights not expressly granted. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL + * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.facebook.react.uiapp; + +import android.app.Application; + +import com.facebook.react.ReactApplication; +import com.facebook.react.ReactNativeHost; +import com.facebook.react.ReactPackage; +import com.facebook.react.shell.MainReactPackage; + +import java.util.Arrays; +import java.util.List; + +import javax.annotation.Nullable; + +public class UIExplorerApplication extends Application implements ReactApplication { + private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { + @Override + public String getJSMainModuleName() { + return "Examples/UIExplorer/UIExplorerApp.android"; + } + + @Override + public @Nullable String getBundleAssetName() { + return "UIExplorerApp.android.bundle"; + } + + @Override + public boolean getUseDeveloperSupport() { + return true; + } + + @Override + public List getPackages() { + return Arrays.asList( + new MainReactPackage() + ); + } + }; + + @Override + public ReactNativeHost getReactNativeHost() { + return mReactNativeHost; + } +};