Skip to content

Commit 435c254

Browse files
author
mrzhang
committed
update kotlin demo
1 parent f45027b commit 435c254

10 files changed

Lines changed: 76 additions & 84 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
auto generated, do not change !!!!
2+
3+
HOST : kotlin
4+
5+
分享杂志页面
6+
/shareMagazine
7+
author:com.luojilab.componentservice.share.bean.Author
8+
bookName:String
9+

app/gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ org.gradle.jvmargs=-Xmx1536m
1212
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1313
# org.gradle.parallel=true
1414
isRunAlone=true
15-
debugComponent=readercomponent,sharecomponent
16-
compileComponent=readercomponent,sharecomponent
15+
debugComponent=readercomponent,sharecomponent,sharecomponentkotlin
16+
compileComponent=readercomponent,sharecomponent,sharecomponentkotlin
1717

1818

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,43 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<layout>
32

4-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
android:orientation="vertical">
7+
8+
<LinearLayout
59
android:layout_width="match_parent"
6-
android:layout_height="match_parent"
7-
android:orientation="vertical">
10+
android:layout_height="wrap_content"
11+
android:layout_marginTop="30dp"
12+
android:gravity="center_horizontal">
813

9-
<LinearLayout
10-
android:layout_width="match_parent"
14+
<Button
15+
android:id="@+id/install_share"
16+
android:layout_width="wrap_content"
1117
android:layout_height="wrap_content"
12-
android:layout_marginTop="30dp"
13-
android:gravity="center_horizontal">
14-
15-
<Button
16-
android:id="@+id/install_share"
17-
android:layout_width="wrap_content"
18-
android:layout_height="wrap_content"
19-
android:text="加载分享组件"
20-
android:textColor="@color/common_color_black" />
21-
22-
<Button
23-
android:id="@+id/uninstall_share"
24-
android:layout_width="wrap_content"
25-
android:layout_height="wrap_content"
26-
android:layout_marginLeft="15dp"
27-
android:text="卸载分享组件"
28-
android:textColor="@color/common_color_black" />
29-
</LinearLayout>
30-
31-
<FrameLayout
32-
android:id="@+id/tab_content"
33-
android:layout_width="fill_parent"
34-
android:layout_height="0dp"
35-
android:layout_weight="1" />
36-
37-
<View
38-
android:layout_width="match_parent"
39-
android:layout_height="1dp"
40-
android:background="#858585"></View>
41-
18+
android:text="加载分享组件"
19+
android:textColor="@color/common_color_black" />
4220

21+
<Button
22+
android:id="@+id/uninstall_share"
23+
android:layout_width="wrap_content"
24+
android:layout_height="wrap_content"
25+
android:layout_marginLeft="15dp"
26+
android:text="卸载分享组件"
27+
android:textColor="@color/common_color_black" />
4328
</LinearLayout>
4429

45-
</layout>
30+
<FrameLayout
31+
android:id="@+id/tab_content"
32+
android:layout_width="fill_parent"
33+
android:layout_height="0dp"
34+
android:layout_weight="1" />
35+
36+
<View
37+
android:layout_width="match_parent"
38+
android:layout_height="1dp"
39+
android:background="#858585"></View>
40+
41+
</LinearLayout>
42+
4643

readercomponent/gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ org.gradle.jvmargs=-Xmx1536m
1212
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1313
# org.gradle.parallel=true
1414
isRunAlone=true
15-
debugComponent=sharecomponent
16-
compileComponent=com.luojilab.share:sharecomponent
15+
debugComponent=sharecomponent,sharecomponentkotlin
16+
compileComponent=sharecomponent,sharecomponentkotlin

readercomponent/src/main/java/com/luojilab/reader/ReaderFragment.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,8 @@ private void goToShareActivityWithUri() {
7272
Author author = new Author();
7373
author.setName("Barack Obama");
7474
author.setCounty("New York");
75-
76-
//参数合法的uri字符串
77-
final String URI_LEGAL = "DDComp://share/shareMagazine?bookName=NYTIME&author=";
78-
79-
//参数非法的uri字符串 bookName是必须参数,并在注解中配置了错误外显策略。
80-
// final String URI_ILLEGAL = "DDComp://share/shareMagazine?bookNameeee=NYTIME&author=";
81-
82-
/* TODO: 2017/12/21 change the secondary param to see difference between
83-
legal and illegal data delivering*/
8475
UIRouter.getInstance().openUri(getActivity(),
85-
URI_LEGAL
76+
"DDComp://kotlin/shareMagazine?bookName=NYTIME&author="
8677
+ JsonService.Factory.getInstance().create().toJsonString(author), null);
8778
}
8879

readercomponent/src/main/runalone/java/com/luojilab/reader/runalone/application/ReaderApplication.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public void onCreate() {
1616

1717
//如果isRegisterCompoAuto为false,则需要通过反射加载组件
1818
Router.registerComponent("com.luojilab.share.applike.ShareApplike");
19+
Router.registerComponent("com.luojilab.share.kotlin.applike.KotlinApplike");
1920
}
2021

2122
}

sharecomponentkotlin/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ apply plugin: 'kotlin-android-extensions'
55

66
kapt {
77
arguments {
8-
arg(host: "kotlin")
8+
arg("host", "kotlin")
99
}
1010
}
1111

@@ -14,7 +14,7 @@ android {
1414
buildToolsVersion "26.0.1"
1515

1616
defaultConfig {
17-
minSdkVersion 14
17+
minSdkVersion 15
1818
targetSdkVersion 14
1919
versionCode 1
2020
versionName "1.0"

sharecomponentkotlin/src/androidTest/java/com/luojilab/share/kotlin/ExampleInstrumentedTest.java

Lines changed: 0 additions & 26 deletions
This file was deleted.

sharecomponentkotlin/src/main/java/com/luojilab/share/kotlin/ShareMessageActivity.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ class ShareMessageActivity : Activity() {
3030
override fun onCreate(savedInstanceState: Bundle?) {
3131
super.onCreate(savedInstanceState)
3232
AutowiredService.Factory.getInstance().create().autowire(this)
33-
setContentView(R.layout.share_activity_share)
33+
setContentView(R.layout.kotlin_activity_share)
3434

35-
tvShareTitle = findViewById(R.id.share_title) as TextView?
36-
tvShareBook = findViewById(R.id.share_tv_tag) as TextView?
37-
tvAuthor = findViewById(R.id.share_tv_author) as TextView?
38-
tvCounty = findViewById(R.id.share_tv_county) as TextView?
35+
tvShareTitle = findViewById<TextView>(R.id.share_title)
36+
tvShareBook = findViewById<TextView>(R.id.share_tv_tag)
37+
tvAuthor = findViewById<TextView>(R.id.share_tv_author)
38+
tvCounty = findViewById<TextView>(R.id.share_tv_county)
3939

4040

4141
tvShareTitle?.text = "Magazine"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.luojilab.share.kotlin.applike
2+
3+
import com.luojilab.component.componentlib.applicationlike.IApplicationLike
4+
import com.luojilab.component.componentlib.router.ui.UIRouter
5+
6+
/**
7+
* Created by mrzhang on 2018/1/3.
8+
*/
9+
class KotlinApplike : IApplicationLike {
10+
11+
val uiRouter = UIRouter.getInstance()
12+
13+
override fun onCreate() {
14+
uiRouter.registerUI("kotlin")
15+
}
16+
17+
override fun onStop() {
18+
uiRouter.unregisterUI("kotlin")
19+
}
20+
}

0 commit comments

Comments
 (0)