Skip to content

Commit 5a2d8e3

Browse files
authored
Merge pull request #17 from petterh/petterh/rename-index
Rename index file so as not to be android-specific
2 parents 9aae246 + 0f234c7 commit 5a2d8e3

File tree

7 files changed

+44
-12
lines changed

7 files changed

+44
-12
lines changed

.gitignore

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
.npmrc
22

33
# OSX
4-
#
54
.DS_Store
65

76
# Xcode
8-
#
97
build/
108
*.pbxuser
119
!default.pbxuser
@@ -27,15 +25,16 @@ DerivedData
2725
ios/Pods/
2826

2927
# Android/IntelliJ
30-
#
31-
build/
28+
.classpath
3229
.idea
3330
.gradle
31+
.project
32+
.settings/
33+
build/
3434
local.properties
3535
*.iml
3636

3737
# node.js
38-
#
3938
node_modules/
4039
npm-debug.log
4140
yarn-error.log

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ The starting point for this sample is a slightly tweaked standard React Native p
3030

3131
![Android Demo App](img/AndroidScreenShot.png)
3232

33-
The `TextInput` box appears only in the Android version. Since both platforms use the same JavaScript, I took the opportunity to demonstrate how to handle platform-specific tweaks – look for `Platform.select` in [`index.android.js`](index.android.js).
33+
The `TextInput` box appears only in the Android version. Since both platforms use the same JavaScript, I took the opportunity to demonstrate how to handle platform-specific tweaks – look for `Platform.select` in [`index.js`](index.js).
3434

3535
## Getting started
3636

@@ -83,7 +83,7 @@ export default class ActivityDemoComponent extends Component {
8383
Welcome to React Native!
8484
</Text>
8585
<Text style={styles.instructions}>
86-
To get started, edit index.android.js
86+
To get started, edit index.js
8787
</Text>
8888
<!-- Menu buttons: https://facebook.github.io/react-native/docs/debugging -->
8989
<Text style={styles.instructions}>

android/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ final useDevSupport = !bundleInDebug
2020

2121
project.ext.react = [
2222
// The name of the generated asset file containing your JS bundle
23-
// bundleAssetName: "index.android.bundle",
23+
bundleAssetName: "index.bundle",
2424

2525
// The entry file for bundle generation
26-
// entryFile: "index.android.js",
26+
entryFile: "index.js",
2727

2828
// Whether to bundle JS and assets in debug mode. Set this to false if you want to load
2929
// JavaScript from a bundler, true if you want to embed the bundle in the apk.

android/app/src/main/java/com/demo/activity/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import com.facebook.react.devsupport.interfaces.DevSupportManager;
1717

1818
/**
19-
* The main activity, which hosts the React Native view registered in {@code index.android.js}.
19+
* The main activity, which hosts the React Native view registered in {@code index.js}.
2020
*/
2121
public final class MainActivity extends ReactActivity {
2222

android/app/src/main/java/com/demo/activity/MainApplication.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,50 @@
1414
import java.util.Arrays;
1515
import java.util.List;
1616

17+
import javax.annotation.Nullable;
18+
1719
/**
1820
* Base class for maintaining global application state -- in this case, the {@link ReactNativeHost}.
1921
*/
2022
public final class MainApplication extends Application implements ReactApplication {
2123

24+
private static final String JS_BUNDLE_NAME = "index.bundle";
25+
private static final String JS_MAIN_MODULE_NAME = "index";
26+
2227
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
2328
@Override
2429
public boolean getUseDeveloperSupport() {
2530
return BuildConfig.USE_DEVELOPER_SUPPORT;
2631
}
2732

33+
/**
34+
* Returns the name of the main module. Determines the URL used to fetch the JS bundle
35+
* from the packager server. It is only used when dev support is enabled.
36+
*/
37+
@NonNull
38+
@Override
39+
protected String getJSMainModuleName() {
40+
return JS_MAIN_MODULE_NAME;
41+
}
42+
43+
/**
44+
* Returns the name of the bundle in assets.
45+
*/
46+
@NonNull
47+
@Override
48+
protected String getBundleAssetName() {
49+
return JS_BUNDLE_NAME;
50+
}
51+
52+
/**
53+
* <p>
54+
* Returns a list of {@link ReactPackage}s used by the app.
55+
* </p>
56+
* <p>
57+
* This method is called by the React Native framework.
58+
* It is not normally called by the application itself.
59+
* </p>
60+
*/
2861
@Override
2962
protected List<ReactPackage> getPackages() {
3063
return Arrays.asList(

index.android.js renamed to index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export default class ActivityDemoComponent extends Component {
5555
</Text>
5656
<Text style={styles.instructions}>
5757
<Text>To get started, edit </Text>
58-
<Text style={styles.bold}>index.android.js</Text>
58+
<Text style={styles.bold}>index.js</Text>
5959
<Text>.</Text>
6060
</Text>
6161
<Text style={styles.instructions}>

ios/Activity/AppDelegate.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ - (void) callJavaScript
5959
}
6060

6161
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
62-
NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.android"
62+
NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"
6363
fallbackResource:nil];
6464
return jsCodeLocation;
6565
}

0 commit comments

Comments
 (0)