Skip to content

Commit 154f80f

Browse files
Merge pull request #17 from callstack-internal/feat/kotlin-example
feat: Kotlin example
2 parents 293327f + 30249d0 commit 154f80f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+810
-2
lines changed

android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeActivity.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ class ReactNativeActivity : ReactActivity(), DefaultHardwareBackBtnHandler, Perm
5252

5353
if (ReactNativeBrownfield.shared.reactNativeHost.hasInstance()) {
5454
ReactNativeBrownfield.shared.reactNativeHost.reactInstanceManager?.onHostDestroy(this)
55-
ReactNativeBrownfield.shared.reactNativeHost.clear()
5655
}
5756
}
5857

android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeFragment.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ class ReactNativeFragment : Fragment(), PermissionAwareActivity {
8080

8181
if (reactInstanceMgr.lifecycleState != LifecycleState.RESUMED) {
8282
reactInstanceMgr.onHostDestroy(activity)
83-
ReactNativeBrownfield.shared.reactNativeHost.clear()
8483
}
8584
}
8685
}

example/java/app/src/main/java/com/callstack/nativeexample/MainActivity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ public void startReactNative(View view) {
2020
"ReactNative"
2121
);
2222
startActivity(intent);
23+
overridePendingTransition(R.anim.slide_fade_in, android.R.anim.fade_out);
2324
}
2425

2526
public void startReactNativeFragment(View view) {
2627
Intent intent = new Intent(this, ReactNativeFragmentActivity.class);
2728
startActivity(intent);
29+
overridePendingTransition(R.anim.slide_fade_in, android.R.anim.fade_out);
2830
}
2931
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<set xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:duration="200"
4+
>
5+
<translate
6+
android:fromYDelta="10%p"
7+
android:toYDelta="0"/>
8+
<alpha
9+
android:fromAlpha="0.0"
10+
android:toAlpha="1"/>
11+
</set>

example/kotlin/.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild

example/kotlin/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>kotlin</name>
4+
<comment>Project kotlin created by Buildship.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
16+
</natures>
17+
</projectDescription>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
connection.project.dir=
2+
eclipse.preferences.version=1

example/kotlin/app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

example/kotlin/app/build.gradle

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
apply plugin: 'com.android.application'
2+
3+
apply plugin: 'kotlin-android'
4+
5+
apply plugin: 'kotlin-android-extensions'
6+
7+
project.ext.react = [
8+
entryFile: "example/index.js"
9+
]
10+
11+
apply from: "../../../node_modules/react-native/react.gradle"
12+
13+
android {
14+
compileSdkVersion rootProject.ext.compileSdkVersion
15+
16+
sourceSets {
17+
main.java.srcDirs += 'build/generated/rncli/src/main/java'
18+
}
19+
20+
defaultConfig {
21+
applicationId "com.callstack.kotlinexample"
22+
minSdkVersion rootProject.ext.minSdkVersion
23+
targetSdkVersion rootProject.ext.targetSdkVersion
24+
versionCode 1
25+
versionName "1.0"
26+
}
27+
28+
buildTypes {
29+
release {
30+
minifyEnabled false
31+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
32+
}
33+
}
34+
}
35+
36+
dependencies {
37+
implementation fileTree(dir: 'libs', include: ['*.jar'])
38+
implementation "com.facebook.react:react-native:+"
39+
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
40+
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
41+
implementation 'androidx.appcompat:appcompat:1.1.0-beta01'
42+
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
43+
implementation 'org.webkit:android-jsc:+'
44+
}
45+
46+
apply from: file("../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle");
47+
applyNativeModulesAppBuildGradle(project, "../..")

example/kotlin/app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile

0 commit comments

Comments
 (0)