-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 #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 #8223 Differential Revision: D3456957 fbshipit-source-id: cc0b51e5bfaec71d210bfba81b1f7cd06a723d8c
- Loading branch information
Showing
7 changed files
with
167 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
Examples/Movies/android/app/src/main/java/com/facebook/react/movies/MoviesApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ReactPackage> getPackages() { | ||
return Arrays.<ReactPackage>asList( | ||
new MainReactPackage() | ||
); | ||
} | ||
}; | ||
|
||
@Override | ||
public ReactNativeHost getReactNativeHost() { | ||
return mReactNativeHost; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 0 additions & 78 deletions
78
Examples/UIExplorer/android/app/src/main/java/UIExplorerActivity.java
This file was deleted.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
...les/UIExplorer/android/app/src/main/java/com/facebook/react/uiapp/UIExplorerActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"; | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
.../UIExplorer/android/app/src/main/java/com/facebook/react/uiapp/UIExplorerApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ReactPackage> getPackages() { | ||
return Arrays.<ReactPackage>asList( | ||
new MainReactPackage() | ||
); | ||
} | ||
}; | ||
|
||
@Override | ||
public ReactNativeHost getReactNativeHost() { | ||
return mReactNativeHost; | ||
} | ||
}; |
dcc2abc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leeight thanks for fixing this!
dcc2abc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good demo.
dcc2abc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is great thanks, just wondering how to do it in cases like
CodePush
orOrientationPackage
etc they receive an instance of the activity.So I think there is no way to get Activity instance (
this
) inMainApplication
so need to wait to client package to be updated and support this version.dcc2abc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@agrcrobles How about Application.getCurrentActivity()
dcc2abc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dcc2abc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kietcroco @agrcrobles
Is what it says on the CodePush update notes somewhere I found.