Skip to content

Commit 498adae

Browse files
author
mrzhang
committed
UI router by Uri
1 parent 1c1064d commit 498adae

File tree

46 files changed

+496
-518
lines changed

Some content is hidden

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

46 files changed

+496
-518
lines changed

app/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ android {
1010
versionCode 1
1111
versionName "1.0"
1212
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13+
14+
dataBinding {
15+
enabled = true
16+
}
17+
1318
}
1419
buildTypes {
1520
release {
Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,46 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3-
android:layout_width="match_parent"
4-
android:layout_height="match_parent"
5-
android:orientation="vertical">
2+
<layout>
63

7-
<LinearLayout
4+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
85
android:layout_width="match_parent"
9-
android:layout_height="wrap_content"
10-
android:gravity="center_horizontal">
6+
android:layout_height="match_parent"
7+
android:orientation="vertical">
118

12-
<Button
13-
android:id="@+id/install_share"
14-
android:layout_width="wrap_content"
9+
<LinearLayout
10+
android:layout_width="match_parent"
1511
android:layout_height="wrap_content"
16-
android:text="加载分享组件"
17-
android:textColor="@color/common_color_black" />
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>
1841

19-
<Button
20-
android:id="@+id/uninstall_share"
21-
android:layout_width="wrap_content"
22-
android:layout_height="wrap_content"
23-
android:layout_marginLeft="15dp"
24-
android:text="卸载分享组件"
25-
android:textColor="@color/common_color_black" />
26-
</LinearLayout>
27-
28-
<FrameLayout
29-
android:id="@+id/tab_content"
30-
android:layout_width="fill_parent"
31-
android:layout_height="0dp"
32-
android:layout_weight="1" />
33-
34-
<View
35-
android:layout_width="match_parent"
36-
android:layout_height="1dp"
37-
android:background="#858585"></View>
3842

43+
</LinearLayout>
3944

40-
</LinearLayout>
45+
</layout>
4146

componentlib/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ android {
88
buildToolsVersion "26.0.0"
99

1010
defaultConfig {
11-
minSdkVersion 14
11+
minSdkVersion 15
1212
targetSdkVersion 26
1313
versionCode 1
1414
versionName "1.0"
@@ -31,7 +31,7 @@ dependencies {
3131
exclude group: 'com.android.support', module: 'support-annotations'
3232
})
3333
testCompile 'junit:junit:4.12'
34-
compile project(':router-annotation')
34+
compile project(':router-di-lib')
3535
}
3636

3737

componentlib/src/main/java/com/mrzhang/component/componentlib/router/ui/IUIRouter.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,11 @@ public interface IUIRouter extends IComponentRouter {
1515

1616
void registerUI(IComponentRouter router);
1717

18+
void registerUI(String host);
19+
20+
void registerUI(String host, int priority);
21+
1822
void unregisterUI(IComponentRouter router);
23+
24+
void unregisterUI(String host);
1925
}

componentlib/src/main/java/com/mrzhang/component/componentlib/router/ui/UIRouter.java

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
import android.text.TextUtils;
88

99
import com.ljsw.router.facade.Constants;
10-
import com.ljsw.router.facade.annotation.Router;
1110

12-
import java.lang.annotation.Annotation;
1311
import java.util.ArrayList;
1412
import java.util.HashMap;
1513
import java.util.Iterator;
@@ -69,6 +67,22 @@ public void registerUI(IComponentRouter router) {
6967
registerUI(router, PRIORITY_NORMAL);
7068
}
7169

70+
@Override
71+
public void registerUI(String host) {
72+
IComponentRouter router = fetch(host);
73+
if (router != null) {
74+
registerUI(router, PRIORITY_NORMAL);
75+
}
76+
}
77+
78+
@Override
79+
public void registerUI(String host, int priority) {
80+
IComponentRouter router = fetch(host);
81+
if (router != null) {
82+
registerUI(router, priority);
83+
}
84+
}
85+
7286
@Override
7387
public void unregisterUI(IComponentRouter router) {
7488
for (int i = 0; i < uiRouters.size(); i++) {
@@ -80,6 +94,14 @@ public void unregisterUI(IComponentRouter router) {
8094
}
8195
}
8296

97+
@Override
98+
public void unregisterUI(String host) {
99+
IComponentRouter router = fetch(host);
100+
if (router != null) {
101+
unregisterUI(router);
102+
}
103+
}
104+
83105
@Override
84106
public boolean openUri(Context context, String url, Bundle bundle) {
85107
url = url.trim();
@@ -132,16 +154,11 @@ private void removeOldUIRouter(IComponentRouter router) {
132154
}
133155
}
134156

135-
public static IComponentRouter fetch(@NonNull Class<? extends IComponentRouter> clz) {
136-
if (!clz.isInterface())
137-
throw new IllegalArgumentException("need a interface, but this isn't a interface:" + clz.getName());
138-
139-
Router router = clz.getAnnotation(Router.class);
140-
if (router == null)
141-
throw new IllegalArgumentException("not annotated with Router:" + clz.getName());
157+
private IComponentRouter fetch(@NonNull String host) {
142158

143159
String path = Constants.ROUTERIMPL_OUTPUT_PKG +
144-
Constants.DOT + router.group() + Constants.DOT + clz.getSimpleName() + "Impl";
160+
Constants.DOT + host + Constants.UIROUTER;
161+
145162
if (routerInstanceCache.containsKey(path))
146163
return routerInstanceCache.get(path);
147164

-17.7 KB
Binary file not shown.
-17.5 KB
Binary file not shown.

componentservice/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ android {
2424
dependencies {
2525
compile project(':componentlib')
2626
compile project(':basicres')
27-
compile project(':jsonlib')
28-
compile project(':dilib')
2927
compile fileTree(include: ['*.jar'], dir: 'libs')
3028
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
3129
exclude group: 'com.android.support', module: 'support-annotations'
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.mrzhang.componentservice.share.bean;
2+
3+
/**
4+
* Created by mrzhang on 2017/12/14.
5+
*/
6+
7+
public class Author {
8+
private String name;
9+
private int age;
10+
private String county;
11+
12+
public String getName() {
13+
return name;
14+
}
15+
16+
public void setName(String name) {
17+
this.name = name;
18+
}
19+
20+
public int getAge() {
21+
return age;
22+
}
23+
24+
public void setAge(int age) {
25+
this.age = age;
26+
}
27+
28+
public String getCounty() {
29+
return county;
30+
}
31+
32+
public void setCounty(String county) {
33+
this.county = county;
34+
}
35+
}

dilib/build.gradle

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

0 commit comments

Comments
 (0)