Skip to content

Commit 0db7ae3

Browse files
committed
first commit for react.
1 parent 407c1af commit 0db7ae3

File tree

14 files changed

+202
-20
lines changed

14 files changed

+202
-20
lines changed

app/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 23
5-
buildToolsVersion "23.0.1"
4+
compileSdkVersion 25
5+
buildToolsVersion "25.0.2"
66
defaultConfig {
77
applicationId "com.example.ponycui_home.svgaplayer"
88
minSdkVersion 16
9-
targetSdkVersion 23
9+
targetSdkVersion 25
1010
versionCode 1
1111
versionName "1.0"
1212
}
@@ -30,7 +30,7 @@ android {
3030

3131
dependencies {
3232
compile fileTree(include: ['*.jar'], dir: 'libs')
33-
compile 'com.android.support:appcompat-v7:23.0.0'
33+
compile 'com.android.support:appcompat-v7:25.3.1'
3434
compile project(':library')
3535
compile 'com.squareup.okhttp3:okhttp:3.4.1'
3636
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,8 @@ buildscript {
1717
allprojects {
1818
repositories {
1919
jcenter()
20+
maven {
21+
url "https://raw.githubusercontent.com/yyued/react-native-android-runtime/master/"
22+
}
2023
}
2124
}

library/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ apply plugin: 'com.android.library'
22
apply plugin: 'kotlin-android'
33

44
android {
5-
compileSdkVersion 23
6-
buildToolsVersion "23.0.1"
5+
compileSdkVersion 25
6+
buildToolsVersion "25.0.2"
77
defaultConfig {
88
minSdkVersion 14
9-
targetSdkVersion 23
9+
targetSdkVersion 25
1010
versionCode 1
1111
versionName "1.0"
1212
}
@@ -30,7 +30,7 @@ android {
3030

3131
dependencies {
3232
compile fileTree(include: ['*.jar'], dir: 'libs')
33-
compile 'com.android.support:appcompat-v7:23.0.0'
33+
compile 'com.android.support:appcompat-v7:25.3.1'
3434
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
3535
}
3636
repositories {

library/src/main/java/com/opensource/svgaplayer/SVGAPlayer.kt

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@ import android.util.AttributeSet
66
/**
77
* Created by cuiminghui on 2017/3/30.
88
*/
9-
class SVGAPlayer: SVGAImageView {
10-
11-
constructor(context: Context) : super(context) {}
12-
13-
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {}
14-
15-
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {}
16-
17-
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {}
18-
19-
}
9+
open class SVGAPlayer @JvmOverloads constructor(
10+
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
11+
) : SVGAImageView(context, attrs, defStyleAttr)

react/.gitignore

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

react/build.gradle

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
apply plugin: 'com.android.library'
2+
apply plugin: 'kotlin-android'
3+
4+
android {
5+
compileSdkVersion 25
6+
buildToolsVersion "25.0.2"
7+
8+
defaultConfig {
9+
minSdkVersion 16
10+
targetSdkVersion 25
11+
versionCode 1
12+
versionName "1.0"
13+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14+
ndk {
15+
abiFilters "armeabi-v7a", "x86"
16+
}
17+
}
18+
buildTypes {
19+
release {
20+
minifyEnabled false
21+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22+
}
23+
}
24+
}
25+
26+
dependencies {
27+
compile fileTree(include: ['*.jar'], dir: 'libs')
28+
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
29+
exclude group: 'com.android.support', module: 'support-annotations'
30+
})
31+
compile 'com.android.support:appcompat-v7:25.3.1'
32+
testCompile 'junit:junit:4.12'
33+
compile project(':library')
34+
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
35+
compile 'com.facebook.react:react-native:+'
36+
}

react/proguard-rules.pro

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /usr/local/Cellar/android-sdk/24.4.1_1/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
18+
19+
# Uncomment this to preserve the line number information for
20+
# debugging stack traces.
21+
#-keepattributes SourceFile,LineNumberTable
22+
23+
# If you keep the line number information, uncomment this to
24+
# hide the original source file name.
25+
#-renamesourcefileattribute SourceFile
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.opensource.svgaplayer_react;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumentation test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() throws Exception {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("com.opensource.svgaplayer_react.test", appContext.getPackageName());
25+
}
26+
}

react/src/main/AndroidManifest.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
3+
package="com.opensource.svgaplayer_react">
4+
5+
<application android:allowBackup="true" android:label="@string/app_name"
6+
android:supportsRtl="true">
7+
8+
</application>
9+
10+
</manifest>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.opensource.svgaplayer_react
2+
3+
import android.content.Context
4+
import android.support.annotation.NonNull
5+
import com.facebook.react.uimanager.SimpleViewManager
6+
import com.facebook.react.uimanager.ThemedReactContext
7+
import com.facebook.react.uimanager.annotations.ReactProp
8+
import com.opensource.svgaplayer.SVGAImageView
9+
import com.opensource.svgaplayer.SVGAParser
10+
import com.opensource.svgaplayer.SVGAVideoEntity
11+
import java.net.URL
12+
13+
/**
14+
* Created by cuiminghui on 2017/6/16.
15+
*/
16+
class RCTSVGAPlayerManager: SimpleViewManager<SVGAImageView>() {
17+
18+
override fun getName(): String {
19+
return "SVGAPlayer"
20+
}
21+
22+
override fun createViewInstance(reactContext: ThemedReactContext?): SVGAImageView {
23+
return SVGAImageView(reactContext as Context)
24+
}
25+
26+
@ReactProp(name = "source")
27+
fun setSource(view: SVGAImageView, source: String) {
28+
if (source.startsWith("http") || source.startsWith("https")) {
29+
try {
30+
SVGAParser(view.context).parse(URL(source), object: SVGAParser.ParseCompletion {
31+
override fun onComplete(videoItem: SVGAVideoEntity) {
32+
view.setVideoItem(videoItem)
33+
view.startAnimation()
34+
}
35+
override fun onError() { }
36+
})
37+
} catch (e: Exception) {}
38+
}
39+
}
40+
41+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.opensource.svgaplayer_react
2+
3+
import android.view.View
4+
import com.facebook.react.ReactPackage
5+
import com.facebook.react.bridge.JavaScriptModule
6+
import com.facebook.react.bridge.NativeModule
7+
import com.facebook.react.bridge.ReactApplicationContext
8+
import com.facebook.react.uimanager.ReactShadowNode
9+
import com.facebook.react.uimanager.ViewManager
10+
11+
/**
12+
* Created by cuiminghui on 2017/6/16.
13+
*/
14+
class RCTSVGAPlayerPackage: ReactPackage {
15+
16+
override fun createJSModules(): MutableList<Class<out JavaScriptModule>> {
17+
return mutableListOf()
18+
}
19+
20+
override fun createNativeModules(reactContext: ReactApplicationContext?): MutableList<NativeModule> {
21+
return mutableListOf()
22+
}
23+
24+
override fun createViewManagers(reactContext: ReactApplicationContext?): MutableList<ViewManager<View, ReactShadowNode>> {
25+
return mutableListOf(RCTSVGAPlayerManager() as ViewManager<View, ReactShadowNode>)
26+
}
27+
28+
}

react/src/main/res/values/strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<resources>
2+
<string name="app_name">React</string>
3+
</resources>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.opensource.svgaplayer_react;
2+
3+
import org.junit.Test;
4+
5+
import static org.junit.Assert.*;
6+
7+
/**
8+
* Example local unit test, which will execute on the development machine (host).
9+
*
10+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
11+
*/
12+
public class ExampleUnitTest {
13+
@Test
14+
public void addition_isCorrect() throws Exception {
15+
assertEquals(4, 2 + 2);
16+
}
17+
}

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include ':app', ':library'
1+
include ':app', ':library', ':react'

0 commit comments

Comments
 (0)