Skip to content

Commit 52879c3

Browse files
author
wangshuwen15222
committed
chore:整理工程结构
1 parent d8af47b commit 52879c3

File tree

24 files changed

+214
-103
lines changed

24 files changed

+214
-103
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ apply plugin: 'com.android.application'
22

33
android {
44
compileSdkVersion 29
5-
buildToolsVersion "29.0.2"
5+
buildToolsVersion "29.0.3"
66
defaultConfig {
77
applicationId "cn.cheney.test"
8-
minSdkVersion 19
8+
minSdkVersion 21
99
targetSdkVersion 29
1010
versionCode 1
1111
versionName "1.0"

app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
android:theme="@style/AppTheme"
1414
tools:ignore="GoogleAppIndexingWarning">
1515

16-
<activity android:name="cn.cheney.app.MainActivity">
16+
<activity
17+
android:name="cn.cheney.app.activity.MainActivity"
18+
android:theme="@style/AppTheme">
1719
<intent-filter>
1820
<action android:name="android.intent.action.MAIN" />
1921
<category android:name="android.intent.category.LAUNCHER" />
@@ -22,7 +24,8 @@
2224

2325
</activity>
2426

25-
<activity android:name="cn.cheney.app.ActivityA">
27+
<activity android:name="cn.cheney.app.activity.ActivityA">
28+
2629
</activity>
2730

2831
</application>

app/src/main/java/cn/cheney/app/AlertUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
public class AlertUtil {
88

9-
public static void showAlert(Context context,String msg) {
9+
public static void showAlert(Context context, String msg) {
1010
new AlertDialog.Builder(context)
1111
.setTitle("Result")
1212
.setMessage(msg)

app/src/main/java/cn/cheney/app/App.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ public class App extends Application {
1515
@Override
1616
public void onCreate() {
1717
super.onCreate();
18+
1819
XRouter.init(this, "cheney");
20+
1921
//url 拦截
2022
XRouter.getInstance().addInterceptor(new RouterInterceptor() {
2123
@Override

app/src/main/java/cn/cheney/app/ActivityA.java renamed to app/src/main/java/cn/cheney/app/activity/ActivityA.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package cn.cheney.app;
1+
package cn.cheney.app.activity;
22

33
import android.os.Bundle;
44
import android.util.Log;
@@ -9,12 +9,14 @@
99
import java.util.List;
1010
import java.util.Map;
1111

12+
import cn.cheney.app.entity.Book;
13+
import cn.cheney.app.R;
1214
import cn.cheney.xrouter.annotation.XMethod;
1315
import cn.cheney.xrouter.annotation.XParam;
1416
import cn.cheney.xrouter.annotation.XRoute;
1517
import cn.cheney.xrouter.core.XRouter;
1618

17-
@XRoute(path = "page", module = "moduleB")
19+
@XRoute( module = "moduleA",path = "page/a")
1820
public class ActivityA extends AppCompatActivity {
1921

2022
public static final String TAG = ActivityA.class.getSimpleName();
@@ -49,5 +51,9 @@ public static void activityMethod() {
4951

5052
}
5153

52-
54+
@Override
55+
public void finish() {
56+
super.finish();
57+
overridePendingTransition(R.anim.enter_bottom, 0);
58+
}
5359
}

app/src/main/java/cn/cheney/app/MainActivity.java renamed to app/src/main/java/cn/cheney/app/activity/MainActivity.java

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package cn.cheney.app;
1+
package cn.cheney.app.activity;
22

33
import android.content.Intent;
44
import android.net.Uri;
@@ -13,6 +13,9 @@
1313
import java.util.List;
1414
import java.util.Map;
1515

16+
import cn.cheney.app.AlertUtil;
17+
import cn.cheney.app.entity.Book;
18+
import cn.cheney.app.R;
1619
import cn.cheney.xrouter.core.XRouter;
1720
import cn.cheney.xrouter.core.call.MethodCall;
1821
import cn.cheney.xrouter.core.callback.RouteCallback;
@@ -25,53 +28,47 @@ protected void onCreate(Bundle savedInstanceState) {
2528
super.onCreate(savedInstanceState);
2629
setContentView(R.layout.activity_main);
2730

28-
findViewById(R.id.btn1).setOnClickListener(new View.OnClickListener() {
29-
@Override
30-
public void onClick(View v) {
31-
List<String> infoList = new ArrayList<>();
32-
infoList.add("value");
33-
Map<String, String> map = new HashMap<>();
34-
map.put("key", "value");
35-
Integer requestCode = XRouter.page("moduleB/page")
36-
.put("infoList", infoList)
37-
.put("infoMap", map)
38-
.action("cn.cheney.xrouter")
39-
.anim(R.anim.enter_bottom, R.anim.exit_bottom)
40-
.requestCode(1000)
41-
.call();
4231

43-
Logger.d("Route Page requestCode= " + requestCode);
44-
}
45-
});
32+
//路由跳转界面
33+
findViewById(R.id.btn1).setOnClickListener(v -> {
34+
List<String> infoList = new ArrayList<>();
35+
infoList.add("value");
36+
Map<String, String> map = new HashMap<>();
37+
map.put("key", "value");
38+
Integer requestCode = XRouter.page("moduleA/page/a")
39+
.put("infoList", infoList)
40+
.put("infoMap", map)
41+
.action("cn.cheney.xrouter")
42+
.anim(R.anim.enter_bottom,0)
43+
.requestCode(1000)
44+
.call();
4645

47-
findViewById(R.id.btn2).setOnClickListener(new View.OnClickListener() {
48-
@Override
49-
public void onClick(View v) {
50-
Book book = new Book();
51-
book.name = "Kotlin";
52-
MethodCall<Book> bookMethodCall = XRouter.<Book>method(
53-
"moduleA/getBookName");
54-
Book bookReturn = bookMethodCall.call();
55-
AlertUtil.showAlert(MainActivity.this, bookReturn.toString());
56-
}
46+
Logger.d("Route Page requestCode= " + requestCode);
5747
});
5848

49+
//路由执行同步方法
50+
findViewById(R.id.btn2).setOnClickListener(v -> {
51+
Book book = new Book();
52+
book.name = "Kotlin";
53+
MethodCall<Book> bookMethodCall = XRouter.<Book>method(
54+
"moduleA/getBookName");
55+
Book bookReturn = bookMethodCall.call();
56+
AlertUtil.showAlert(MainActivity.this, bookReturn.toString());
57+
});
5958

59+
//路由执行异步方法
6060
findViewById(R.id.btn3).setOnClickListener(new View.OnClickListener() {
6161
@Override
6262
public void onClick(View v) {
6363
Book book = new Book();
6464
book.name = "Kotlin";
65-
final MethodCall<Book> methodCall = XRouter.<Book>method("moduleA/getAsyncBookName")
66-
.put("book", book);
67-
methodCall.call(new RouteCallback() {
68-
@Override
69-
public void onResult(Map<String, Object> result) {
70-
AlertUtil.showAlert(MainActivity.this, result.toString());
71-
}
72-
});
65+
XRouter.<Book>method("moduleA/getAsyncBookName")
66+
.put("book", book).call(result ->
67+
AlertUtil.showAlert(MainActivity.this, result.toString()));
7368
}
7469
});
70+
71+
//Uri里面传入Map类型
7572
findViewById(R.id.btn4).setOnClickListener(new View.OnClickListener() {
7673
@Override
7774
public void onClick(View v) {
@@ -80,6 +77,7 @@ public void onClick(View v) {
8077
}
8178
});
8279

80+
8381
findViewById(R.id.btn5).setOnClickListener(new View.OnClickListener() {
8482
@Override
8583
public void onClick(View v) {

app/src/main/java/cn/cheney/app/Book.java renamed to app/src/main/java/cn/cheney/app/entity/Book.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
package cn.cheney.app;
1+
package cn.cheney.app.entity;
22

33
import android.os.Parcel;
44
import android.os.Parcelable;
55

66
public class Book implements Parcelable {
77

8-
String name;
8+
public String name;
99

1010
public String getName() {
1111
return name;

app/src/main/java/cn/cheney/app/ModuleA.java renamed to app/src/main/java/cn/cheney/app/module/ModuleA.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package cn.cheney.app;
1+
package cn.cheney.app.module;
22

33
import android.content.Context;
44
import android.util.Log;
@@ -8,6 +8,8 @@
88
import java.util.List;
99
import java.util.Map;
1010

11+
import cn.cheney.app.AlertUtil;
12+
import cn.cheney.app.entity.Book;
1113
import cn.cheney.xrouter.annotation.XMethod;
1214
import cn.cheney.xrouter.annotation.XParam;
1315
import cn.cheney.xrouter.annotation.XRoute;

app/src/main/res/drawable-v24/ic_launcher_foreground.xml

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

app/src/main/res/layout/activity_main.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
android:layout_width="match_parent"
66
android:layout_height="match_parent"
77
android:orientation="vertical"
8-
tools:context=".MainActivity">
8+
tools:context=".activity.MainActivity">
99

1010
<Button
1111
android:id="@+id/btn1"
@@ -17,13 +17,13 @@
1717
android:id="@+id/btn2"
1818
android:layout_width="wrap_content"
1919
android:layout_height="wrap_content"
20-
android:text="同步调用" />
20+
android:text="同步方法调用" />
2121

2222
<Button
2323
android:id="@+id/btn3"
2424
android:layout_width="wrap_content"
2525
android:layout_height="wrap_content"
26-
android:text="异步调用" />
26+
android:text="异步方法调用" />
2727

2828
<Button
2929
android:id="@+id/btn4"

app/src/main/res/layout/activity_test1.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
xmlns:tools="http://schemas.android.com/tools"
55
android:layout_width="match_parent"
66
android:layout_height="match_parent"
7-
tools:context=".MainActivity">
7+
tools:context=".activity.MainActivity">
88

99
</RelativeLayout>

app/src/main/res/layout/activity_test2.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xmlns:tools="http://schemas.android.com/tools"
55
android:layout_width="match_parent"
66
android:layout_height="match_parent"
7-
tools:context=".MainActivity">
7+
tools:context=".activity.MainActivity">
88

99
<TextView
1010
android:layout_width="wrap_content"

app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml

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

app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml

Lines changed: 0 additions & 5 deletions
This file was deleted.
-2.89 KB
Binary file not shown.
Binary file not shown.
-2.01 KB
Binary file not shown.
Binary file not shown.

app/src/main/res/values/styles.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
<resources>
22

33
<!-- Base application theme. -->
4-
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
4+
<style name="AppTheme" parent="Theme.AppCompat.Light">
55
<!-- Customize your theme here. -->
66
<item name="colorPrimary">@color/colorPrimary</item>
77
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
88
<item name="colorAccent">@color/colorAccent</item>
99
</style>
1010

11+
12+
<style name="XRouterPageTheme" parent="Theme.AppCompat.Light.NoActionBar">
13+
14+
</style>
15+
1116
</resources>

0 commit comments

Comments
 (0)