Skip to content

Commit 213d465

Browse files
author
张磊
committed
Router 修改及功能完善
1、移除 Router 源码,改为 maven 依赖; 2、跳转传参、Activity 获取传参功能完善; 3、提供各种 base 类,包含 BaseActivity BaseFragment 等等。
1 parent 44b1648 commit 213d465

File tree

57 files changed

+527
-1376
lines changed

Some content is hidden

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

57 files changed

+527
-1376
lines changed

.idea/gradle.xml

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

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

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

.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: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ dependencies {
2828
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
2929
exclude group: 'com.android.support', module: 'support-annotations'
3030
})
31-
compile 'com.android.support:appcompat-v7:25.1.1'
31+
compile 'com.android.support:appcompat-v7:25.3.1'
3232
testCompile 'junit:junit:4.12'
3333

3434
if (isBuildModule.toBoolean()) {
@@ -41,8 +41,4 @@ dependencies {
4141
}
4242
compile 'com.jakewharton:butterknife:8.4.0'
4343
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
44-
45-
compile project(':Router')
46-
compile project(':RouterAnnotations')
47-
annotationProcessor project(':RouterCompiler')
4844
}

App/src/main/java/com/baronzhang/android/modularization/MainActivity.java

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
11
package com.baronzhang.android.modularization;
22

33
import android.os.Bundle;
4-
import android.support.v7.app.AppCompatActivity;
54

6-
import com.baronzhang.android.commonbusiness.HouseDetail;
7-
import com.baronzhang.android.commonbusiness.RouterService;
5+
import com.baronzhang.android.commonbusiness.base.activity.BaseActivity;
6+
import com.baronzhang.android.commonbusiness.model.HouseDetail;
7+
import com.baronzhang.android.commonbusiness.router.RouterService;
88
import com.baronzhang.android.router.Router;
9-
import com.baronzhang.android.router.annotations.inject.InjectIntentExtrasParam;
109

1110
import java.util.ArrayList;
1211

1312
import butterknife.ButterKnife;
1413
import butterknife.OnClick;
1514
import butterknife.Unbinder;
1615

17-
public class MainActivity extends AppCompatActivity {
16+
public class MainActivity extends BaseActivity {
1817

1918
private RouterService routerService;
2019

2120
private Unbinder unbinder;
2221

23-
@InjectIntentExtrasParam
24-
String cityId;
25-
2622
@Override
2723
protected void onCreate(Bundle savedInstanceState) {
2824
super.onCreate(savedInstanceState);
@@ -33,21 +29,30 @@ protected void onCreate(Bundle savedInstanceState) {
3329
}
3430

3531
@OnClick(R.id.btn_goto_new_house)
36-
public void startNewHouseActivity() {
37-
routerService.startNewHouseActivity("110", new HouseDetail());
32+
void startNewHouseActivity() {
33+
routerService.startNewHouseActivity("110", new HouseDetail("10000", "潍坊新村", 66));
3834
}
3935

4036
@OnClick(R.id.btn_goto_second_house)
41-
public void startSecondHouseActivity() {
42-
routerService.startSecondHouseActivity("111", 181818);
37+
void startSecondHouseActivity() {
38+
39+
ArrayList<HouseDetail> houseDetailList = new ArrayList<>();
40+
houseDetailList.add(new HouseDetail("10001", "潍坊一村", 88));
41+
houseDetailList.add(new HouseDetail("10002", "潍坊二村", 120));
42+
houseDetailList.add(new HouseDetail("10003", "潍坊二村", 99));
43+
houseDetailList.add(new HouseDetail("10004", "潍坊三村", 86));
44+
houseDetailList.add(new HouseDetail("10005", "潍坊五村", 80));
45+
46+
routerService.startSecondHouseActivity("111", houseDetailList);
4347
}
4448

4549
@OnClick(R.id.btn_goto_im)
46-
public void startIMActivity() {
47-
ArrayList<Integer> array = new ArrayList<>();
48-
array.add(123);
49-
array.add(123234);
50-
routerService.startIMActivity("112", array);
50+
void startIMActivity() {
51+
ArrayList<Integer> brokerIdList = new ArrayList<>();
52+
brokerIdList.add(20000);
53+
brokerIdList.add(20001);
54+
brokerIdList.add(20002);
55+
routerService.startIMActivity("112", brokerIdList);
5156
}
5257

5358
@Override

CommonBusiness/build.gradle

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ dependencies {
2626
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
2727
exclude group: 'com.android.support', module: 'support-annotations'
2828
})
29-
compile 'com.android.support:appcompat-v7:25.1.1'
3029
testCompile 'junit:junit:4.12'
31-
compile project(':Router')
30+
31+
compile 'com.android.support:appcompat-v7:25.3.1'
32+
compile 'com.android.support:recyclerview-v7:25.3.1'
33+
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
34+
35+
compile 'com.baronzhang.android:router-api:0.2.0'
36+
annotationProcessor 'com.baronzhang.android:router-compiler:0.2.0'
3237
}

CommonBusiness/src/main/java/com/baronzhang/android/commonbusiness/RouterService.java

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.baronzhang.android.commonbusiness.base.activity;
2+
3+
import android.os.Bundle;
4+
import android.support.v7.app.AppCompatActivity;
5+
import android.support.v7.app.AppCompatDelegate;
6+
7+
/**
8+
* @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com ==>> baronzhang.com)
9+
*/
10+
public class BaseActivity extends AppCompatActivity {
11+
12+
/*
13+
* 解决Vector兼容性问题
14+
*
15+
* First up, this functionality was originally released in 23.2.0,
16+
* but then we found some memory usage and Configuration updating
17+
* issues so we it removed in 23.3.0. In 23.4.0 (technically a fix
18+
* release) we’ve re-added the same functionality but behind a flag
19+
* which you need to manually enable.
20+
*
21+
* http://www.jianshu.com/p/e3614e7abc03
22+
*/
23+
static {
24+
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
25+
}
26+
27+
@Override
28+
protected void onCreate(Bundle savedInstanceState) {
29+
super.onCreate(savedInstanceState);
30+
}
31+
32+
@Override
33+
protected void onDestroy() {
34+
super.onDestroy();
35+
}
36+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.baronzhang.android.commonbusiness.base.adapter;
2+
3+
import android.support.v7.widget.RecyclerView;
4+
import android.widget.AdapterView;
5+
6+
/**
7+
* @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com ==>> baronzhang.com)
8+
* 16/4/15
9+
*/
10+
public abstract class BaseRecyclerViewAdapter<T extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<T>{
11+
12+
protected AdapterView.OnItemClickListener onItemClickListener;
13+
14+
public void setOnItemClickListener(AdapterView.OnItemClickListener onItemClickListener) {
15+
16+
this.onItemClickListener = onItemClickListener;
17+
}
18+
19+
protected void onItemHolderClick(RecyclerView.ViewHolder itemHolder) {
20+
if (onItemClickListener != null) {
21+
onItemClickListener.onItemClick(null, itemHolder.itemView,
22+
itemHolder.getAdapterPosition(), itemHolder.getItemId());
23+
} else {
24+
throw new IllegalStateException("Please call setOnItemClickListener method set the click event listeners");
25+
}
26+
}
27+
28+
}

0 commit comments

Comments
 (0)