Skip to content

Commit 3350640

Browse files
committed
1:使用阿里ARouter替换ActivityRouter;
1 parent b82fe19 commit 3350640

File tree

10 files changed

+43
-52
lines changed

10 files changed

+43
-52
lines changed

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ ext {
5252
gsonVersion = "2.8.0"
5353
photoViewVersion = "2.0.0"
5454

55-
//需检查升级版本
56-
annotationProcessor = "1.1.7"
57-
routerVersion = "1.2.2"
55+
//检查时间:2017.6.6
56+
annotationProcessor = "1.0.3"
57+
routerVersion = "1.2.1.1"
5858
easyRecyclerVersion = "4.4.0"
5959
cookieVersion = "v1.0.1"
6060
toastyVersion = "1.1.3"

lib_common/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ dependencies {
3333
compile "com.github.GrenderG:Toasty:$rootProject.toastyVersion"
3434

3535
//router
36-
compile "com.github.mzule.activityrouter:activityrouter:$rootProject.routerVersion"
36+
compile "com.alibaba:arouter-api:$rootProject.routerVersion"
3737
}

module_main/build.gradle

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ android {
1313
targetSdkVersion rootProject.ext.targetSdkVersion
1414
versionCode rootProject.ext.versionCode
1515
versionName rootProject.ext.versionName
16+
17+
//ARouter
18+
javaCompileOptions {
19+
annotationProcessorOptions {
20+
arguments = [moduleName: project.getName()]
21+
}
22+
}
1623
}
1724

1825

@@ -29,14 +36,11 @@ android {
2936
}
3037
}
3138
}
32-
//设置了resourcePrefix值后,所有的资源名必须以指定的字符串做前缀,否则会报错。
33-
//但是resourcePrefix这个值只能限定xml里面的资源,并不能限定图片资源,所有图片资源仍然需要手动去修改资源名。
34-
//resourcePrefix "girls_"
3539

3640
}
3741

3842
dependencies {
3943
compile fileTree(dir: 'libs', include: ['*.jar'])
40-
annotationProcessor "com.github.mzule.activityrouter:compiler:$rootProject.annotationProcessor"
44+
annotationProcessor "com.alibaba:arouter-compiler:$rootProject.annotationProcessor"
4145
compile project(':lib_common')
4246
}

module_main/src/main/java/com/guiying/main/Main.java

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

module_main/src/main/java/com/guiying/main/MainActivity.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@
55
import android.view.View;
66
import android.widget.Button;
77

8-
import com.github.mzule.activityrouter.router.Routers;
8+
import com.alibaba.android.arouter.launcher.ARouter;
99
import com.guiying.common.base.BaseActivity;
1010
import com.guiying.common.base.BaseApplication;
1111
import com.guiying.common.utils.ToastUtils;
1212

13+
/**
14+
* <p>类说明</p>
15+
*
16+
* @author 张华洋 2017/7/1 13:13
17+
* @version V1.2.0
18+
* @name MainActivity
19+
*/
1320
public class MainActivity extends BaseActivity implements View.OnClickListener {
1421

1522
private long exitTime = 0;
@@ -29,9 +36,11 @@ protected void onCreate(Bundle savedInstanceState) {
2936
@Override
3037
public void onClick(View view) {
3138
if (view.getId() == R.id.news_button) {
32-
Routers.open(MainActivity.this, "module://news");
39+
//跳转到NewsCenterActivity
40+
ARouter.getInstance().build("/news/center").navigation();
3341
} else if (view.getId() == R.id.girls_button) {
34-
Routers.open(MainActivity.this, "module://girls");
42+
//跳转到GirlsActivity
43+
ARouter.getInstance().build("/girls/list").navigation();
3544
}
3645
}
3746

module_news/build.gradle

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ android {
1313
targetSdkVersion rootProject.ext.targetSdkVersion
1414
versionCode rootProject.ext.versionCode
1515
versionName rootProject.ext.versionName
16+
17+
//ARouter
18+
javaCompileOptions {
19+
annotationProcessorOptions {
20+
arguments = [moduleName: project.getName()]
21+
}
22+
}
1623
}
1724

1825
sourceSets {
@@ -29,15 +36,10 @@ android {
2936
}
3037
}
3138

32-
//设置了resourcePrefix值后,所有的资源名必须以指定的字符串做前缀,否则会报错。
33-
//但是resourcePrefix这个值只能限定xml里面的资源,并不能限定图片资源,所有图片资源仍然需要手动去修改资源名。
34-
//resourcePrefix "girls_"
35-
36-
3739
}
3840

3941
dependencies {
4042
compile fileTree(dir: 'libs', include: ['*.jar'])
41-
annotationProcessor "com.github.mzule.activityrouter:compiler:$rootProject.annotationProcessor"
43+
annotationProcessor "com.alibaba:arouter-compiler:$rootProject.annotationProcessor"
4244
compile project(':lib_common')
4345
}

module_news/src/main/java/com/guiying/news/News.java

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

module_news/src/main/java/com/guiying/news/detail/NewsDetailActivity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.os.Bundle;
44

5+
import com.alibaba.android.arouter.facade.annotation.Route;
56
import com.guiying.common.base.BaseActivity;
67

78
/**
@@ -11,6 +12,7 @@
1112
* @version V1.2.0
1213
* @name NewsDetailActivity
1314
*/
15+
@Route(path = "/news/detail")
1416
public class NewsDetailActivity extends BaseActivity {
1517

1618
@Override

module_news/src/main/java/com/guiying/news/main/NewsCenterActivity.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import android.support.v4.view.ViewPager;
66
import android.support.v7.widget.Toolbar;
77

8-
import com.github.mzule.activityrouter.annotation.Router;
8+
import com.alibaba.android.arouter.facade.annotation.Route;
99
import com.guiying.common.base.BaseActivity;
1010
import com.guiying.news.R;
1111

@@ -15,7 +15,14 @@
1515
import java.util.List;
1616
import java.util.Locale;
1717

18-
@Router("news")
18+
/**
19+
* <p>类说明</p>
20+
*
21+
* @author 张华洋 2017/4/20 22:26
22+
* @version V1.2.0
23+
* @name NewsCenterActivity
24+
*/
25+
@Route(path = "/news/center")
1926
public class NewsCenterActivity extends BaseActivity {
2027

2128
protected Toolbar mToolBar;

module_news/src/main/java/com/guiying/news/main/NewsListAdapter.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
* @version V1.2.0
2323
* @name NewsListAdapter
2424
*/
25-
26-
2725
public class NewsListAdapter extends RecyclerArrayAdapter<Story> {
2826

2927
public NewsListAdapter(Context context) {

0 commit comments

Comments
 (0)