Skip to content

Commit 4d166d8

Browse files
committed
支持arouter
1 parent 1196b4e commit 4d166d8

File tree

27 files changed

+310
-51
lines changed

27 files changed

+310
-51
lines changed

.idea/caches/build_file_checksums.ser

0 Bytes
Binary file not shown.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ android {
1010
versionName "1.0"
1111
javaCompileOptions {
1212
annotationProcessorOptions {
13-
arguments = [moduleName: project.getName()]
13+
arguments = [ AROUTER_MODULE_NAME : project.getName() ]
1414
}
1515
}
16+
17+
1618
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1719
}
1820
buildTypes {
@@ -31,6 +33,12 @@ dependencies {
3133
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
3234
api rootProject.ext.dependencies["appcompat-v7"]
3335
api rootProject.ext.dependencies["multidex"]
34-
implementation project(':module-home')
35-
implementation project(':module-push')
36+
api rootProject.ext.dependencies["arouter"]
37+
if (!isModule) {
38+
implementation project(':module-home')
39+
implementation project(':module-push')
40+
41+
}
42+
annotationProcessor rootProject.ext.dependencies["arouterCompile"]
43+
implementation project(':lib-core')
3644
}

app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package="com.example.kson.moduledemo">
44

55
<application
6+
android:name=".MyApp"
67
android:allowBackup="true"
78
android:icon="@mipmap/ic_launcher"
89
android:label="@string/app_name"
@@ -17,8 +18,9 @@
1718
</intent-filter>
1819
</activity>
1920
<activity android:name="com.example.kson.module_home.Main2Activity"/>
20-
2121
<activity android:name="com.example.kson.module_push.PushActivity"/>
22+
<activity android:name=".Main2Activity">
23+
</activity>
2224
</application>
2325

2426
</manifest>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.example.kson.moduledemo;
2+
3+
import android.support.v7.app.AppCompatActivity;
4+
import android.os.Bundle;
5+
6+
import com.alibaba.android.arouter.facade.annotation.Route;
7+
8+
@Route(path = "/com/main2")
9+
public class Main2Activity extends AppCompatActivity {
10+
11+
@Override
12+
protected void onCreate(Bundle savedInstanceState) {
13+
super.onCreate(savedInstanceState);
14+
setContentView(R.layout.activity_main22);
15+
}
16+
}
Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package com.example.kson.moduledemo;
22

3-
import android.content.Intent;
4-
import android.support.v7.app.AppCompatActivity;
53
import android.os.Bundle;
4+
import android.support.v4.app.Fragment;
5+
import android.support.v7.app.AppCompatActivity;
66
import android.view.View;
7+
import android.widget.Button;
78

8-
import com.example.kson.module_home.Main2Activity;
9-
import com.example.kson.module_push.PushActivity;
10-
9+
import com.alibaba.android.arouter.facade.Postcard;
10+
import com.alibaba.android.arouter.facade.callback.NavCallback;
11+
import com.alibaba.android.arouter.launcher.ARouter;
12+
import com.example.kson.lib_core.constants.Apath;
1113

1214
public class MainActivity extends AppCompatActivity {
1315

@@ -16,13 +18,50 @@ protected void onCreate(Bundle savedInstanceState) {
1618
super.onCreate(savedInstanceState);
1719
setContentView(R.layout.activity_main);
1820

21+
Button button = findViewById(R.id.fromg);
22+
button.setOnClickListener(new View.OnClickListener() {
23+
@Override
24+
public void onClick(View view) {
25+
26+
ARouter.getInstance().build("/home/home2").navigation(MainActivity.this, new NavCallback() {
27+
@Override
28+
public void onArrival(Postcard postcard) {
29+
30+
}
31+
32+
@Override
33+
public void onInterrupt(Postcard postcard) {
34+
super.onInterrupt(postcard);
35+
}
36+
});
37+
38+
}
39+
});
40+
41+
// Fragment fragmentHome = (Fragment) ARouter.getInstance().build(Apath.HOME_MAIN).navigation();
42+
//
43+
//
44+
//
45+
// getSupportFragmentManager().beginTransaction()
46+
// .add(R.id.fr_content, fragmentHome)
47+
//// .add(R.id.fl_Content, marketFragment)
48+
//// .add(R.id.fl_Content, messageFragment)
49+
//// .add(R.id.fl_Content, mineFragment)
50+
//// .add(R.id.fl_Content, walletFragment)
51+
// .show(fragmentHome)
52+
//// .hide(marketFragment)
53+
//// .hide(messageFragment)
54+
//// .hide(mineFragment)
55+
//// .hide(walletFragment)
56+
// .commit();
57+
1958

2059
}
2160

2261
public void home(View view) {
2362

2463
//集成开发模式,可以调用
25-
startActivity(new Intent(this, PushActivity.class));
64+
// startActivity(new Intent(this, PushActivity.class));
2665

2766
}
2867
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.example.kson.moduledemo;
2+
3+
import android.app.Application;
4+
5+
import com.alibaba.android.arouter.launcher.ARouter;
6+
7+
/**
8+
* Author:kson
9+
* E-mail:19655910@qq.com
10+
* Time:2018/10/30
11+
* Description:
12+
*/
13+
public class MyApp extends Application {
14+
15+
@Override
16+
public void onCreate() {
17+
super.onCreate();
18+
// 这两行必须写在init之前,否则这些配置在init过程中将无效
19+
ARouter.openLog(); // 打印日志
20+
ARouter.openDebug(); // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险) }
21+
ARouter.init(this);
22+
}
23+
}
Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<android.support.constraint.ConstraintLayout
2+
<LinearLayout
33
xmlns:android="http://schemas.android.com/apk/res/android"
44
xmlns:app="http://schemas.android.com/apk/res-auto"
55
xmlns:tools="http://schemas.android.com/tools"
66
android:layout_width="match_parent"
77
android:layout_height="match_parent"
8+
android:orientation="vertical"
89
tools:context=".MainActivity">
910

10-
<TextView
11-
android:onClick="home"
12-
android:layout_width="wrap_content"
13-
android:layout_height="wrap_content"
14-
android:text="Hello World!"
15-
app:layout_constraintBottom_toBottomOf="parent"
16-
app:layout_constraintLeft_toLeftOf="parent"
17-
app:layout_constraintRight_toRightOf="parent"
18-
app:layout_constraintTop_toTopOf="parent"/>
11+
<FrameLayout
12+
android:id="@+id/fr_content"
13+
android:layout_width="match_parent"
14+
android:layout_height="200dp"/>
1915

20-
</android.support.constraint.ConstraintLayout>
16+
<Button
17+
android:id="@+id/fromg"
18+
android:text="跳转"
19+
android:layout_width="match_parent"
20+
android:layout_height="wrap_content"/>
21+
22+
</LinearLayout>

module-home/src/main/res/layout/activity_main2.xml renamed to app/src/main/res/layout/activity_main2.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
tools:context=".Main2Activity">
99

1010
<TextView
11+
android:text="ninini"
1112
android:layout_width="wrap_content"
12-
android:layout_height="wrap_content"
13-
android:text="我是首页模块"/>
13+
android:layout_height="wrap_content"/>
1414

1515
</android.support.constraint.ConstraintLayout>

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
}
99
dependencies {
1010
classpath 'com.android.tools.build:gradle:3.1.4'
11-
11+
classpath "com.alibaba:arouter-register:1.0.2"
1212

1313
// NOTE: Do not place your application dependencies here; they belong
1414
// in the individual module build.gradle files

0 commit comments

Comments
 (0)