Skip to content

Commit 9be86c7

Browse files
committed
1.升级aspectj版本
2.增加组件化使用案例
1 parent 6c0398e commit 9be86c7

File tree

20 files changed

+459
-44
lines changed

20 files changed

+459
-44
lines changed

app/build.gradle

+25-4
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,31 @@ android {
2929
versionName "1.0"
3030
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
3131
}
32+
33+
if (isNeedPackage.toBoolean()) {
34+
signingConfigs {
35+
release {
36+
storeFile file(app_release.storeFile)
37+
storePassword app_release.storePassword
38+
keyAlias app_release.keyAlias
39+
keyPassword app_release.keyPassword
40+
}
41+
}
42+
}
43+
3244
buildTypes {
3345
release {
34-
minifyEnabled false
46+
minifyEnabled true
47+
shrinkResources true
48+
if (isNeedPackage.toBoolean()) {
49+
signingConfig signingConfigs.release
50+
}
3551
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
3652
}
53+
debug {
54+
debuggable true
55+
minifyEnabled false
56+
}
3757
}
3858

3959
compileOptions {
@@ -51,9 +71,10 @@ dependencies {
5171
implementation fileTree(include: ['*.jar'], dir: 'libs')
5272
implementation deps.androidx.appcompat
5373
// implementation project(':xaop-runtime')
54-
implementation 'com.github.xuexiangjys.XAOP:xaop-runtime:1.1.0'
74+
// implementation 'com.github.xuexiangjys.XAOP:xaop-runtime:1.1.0'
5575

56-
implementation 'com.github.xuexiangjys.XUtil:xutil-core:2.0.0'
57-
implementation deps.gson
76+
// 这边为测试组件化测试module
77+
implementation project(':module-common-test')
78+
implementation project(':module1-test')
5879

5980
}

app/src/main/java/com/xuexiang/xaopdemo/MainActivity.java

+8
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616

1717
package com.xuexiang.xaopdemo;
1818

19+
import android.content.Intent;
1920
import android.os.Bundle;
2021
import android.util.Log;
2122
import android.view.View;
2223
import android.widget.TextView;
2324

2425
import androidx.appcompat.app.AppCompatActivity;
2526

27+
import com.xuexiang.module1_test.Module1Activity;
2628
import com.xuexiang.xaop.annotation.DebugLog;
2729
import com.xuexiang.xaop.annotation.DiskCache;
2830
import com.xuexiang.xaop.annotation.IOThread;
@@ -102,6 +104,9 @@ public void run() {
102104
case R.id.btn_lambda:
103105
AppExecutors.get().networkIO().execute(() -> doInMainThread(v));
104106
break;
107+
case R.id.btn_module1:
108+
startActivity(new Intent(this, Module1Activity.class));
109+
break;
105110
default:
106111
break;
107112
}
@@ -114,6 +119,9 @@ private void handleRequestPermission(View v) {
114119
ToastUtils.toast("权限申请通过!");
115120
}
116121

122+
/**
123+
* 设置5秒内响应一次点击
124+
*/
117125
@SingleClick(5000)
118126
@DebugLog(priority = Log.ERROR)
119127
@Intercept(3)

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
android:layout_width="match_parent"
4040
android:layout_height="wrap_content"
4141
android:onClick="onClick"
42-
android:text="快速点击" />
42+
android:text="快速点击(5秒内响应一次)" />
4343

4444
<Button
4545
android:id="@+id/btn_request_permission"
@@ -104,6 +104,13 @@
104104
android:onClick="onClick"
105105
android:text="lambda表达式使用AOP" />
106106

107+
<Button
108+
android:id="@+id/btn_module1"
109+
android:layout_width="match_parent"
110+
android:layout_height="wrap_content"
111+
android:onClick="onClick"
112+
android:text="测试Module1" />
113+
107114
</LinearLayout>
108115

109116

gradle.properties

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ org.gradle.jvmargs=-Xmx1536m
1616
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1717
# org.gradle.parallel=true
1818

19+
# 是否打包APK
20+
isNeedPackage=false
21+
1922
# 表示主工程使用AndroidX形式
2023
android.useAndroidX=true
2124
# 表示针对主工程中使用到的三方库,也会自动执行AndroidX的替换过程。

module-common-test/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

module-common-test/build.gradle

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (C) 2021 xuexiangjys([email protected])
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
apply plugin: 'com.android.library'
18+
apply plugin: 'com.xuexiang.xaop'
19+
20+
android {
21+
compileSdkVersion build_versions.target_sdk
22+
buildToolsVersion build_versions.build_tools
23+
24+
defaultConfig {
25+
minSdkVersion build_versions.min_sdk
26+
targetSdkVersion build_versions.target_sdk
27+
}
28+
29+
compileOptions {
30+
sourceCompatibility JavaVersion.VERSION_1_8
31+
targetCompatibility JavaVersion.VERSION_1_8
32+
}
33+
34+
lintOptions {
35+
abortOnError false
36+
}
37+
38+
}
39+
40+
dependencies {
41+
implementation deps.androidx.appcompat
42+
api 'com.github.xuexiangjys.XAOP:xaop-runtime:1.1.0'
43+
api 'com.github.xuexiangjys.XUtil:xutil-core:2.0.0'
44+
api deps.gson
45+
}

module-common-test/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!--
2+
~ Copyright (C) 2021 xuexiangjys([email protected])
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~
8+
~ http://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ Unless required by applicable law or agreed to in writing, software
11+
~ distributed under the License is distributed on an "AS IS" BASIS,
12+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
~ See the License for the specific language governing permissions and
14+
~ limitations under the License.
15+
-->
16+
17+
<manifest package="com.xuexiang.module_test" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* Copyright (C) 2021 xuexiangjys([email protected])
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.xuexiang.module_test;
18+
19+
import android.app.Activity;
20+
import android.content.Context;
21+
import android.graphics.Point;
22+
import android.view.Display;
23+
import android.view.WindowManager;
24+
25+
import com.xuexiang.xaop.annotation.MemoryCache;
26+
27+
/**
28+
* 这里是演示的工具类
29+
*
30+
* @author xuexiang
31+
* @since 2021/10/6 10:51 AM
32+
*/
33+
public final class CommonUtils {
34+
35+
private CommonUtils() {
36+
throw new UnsupportedOperationException("u can't instantiate me...");
37+
}
38+
39+
/**
40+
* 获取上下文所在的宽度
41+
*
42+
* @param context 上下文
43+
* @param isReal 是否是真实的尺寸
44+
* @return 上下文所在的宽度
45+
*/
46+
public static int getDisplayWidth(Context context, boolean isReal) {
47+
Point point = getDisplaySize(context, isReal);
48+
return point != null ? point.x : 0;
49+
}
50+
51+
/**
52+
* 获取上下文所在的尺寸
53+
*
54+
* @param context 上下文
55+
* @param isReal 是否是真实的尺寸
56+
* @return 上下文所在的尺寸
57+
*/
58+
@MemoryCache
59+
private static Point getDisplaySize(Context context, boolean isReal) {
60+
WindowManager windowManager;
61+
if (context instanceof Activity) {
62+
windowManager = ((Activity) context).getWindowManager();
63+
} else {
64+
windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
65+
}
66+
if (windowManager == null) {
67+
return null;
68+
}
69+
Display display = windowManager.getDefaultDisplay();
70+
Point point = new Point();
71+
if (isReal) {
72+
display.getRealSize(point);
73+
} else {
74+
display.getSize(point);
75+
}
76+
return point;
77+
}
78+
79+
80+
}

module1-test/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

module1-test/build.gradle

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (C) 2021 xuexiangjys([email protected])
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
apply plugin: 'com.android.library'
18+
apply plugin: 'com.xuexiang.xaop'
19+
20+
android {
21+
compileSdkVersion build_versions.target_sdk
22+
buildToolsVersion build_versions.build_tools
23+
24+
defaultConfig {
25+
minSdkVersion build_versions.min_sdk
26+
targetSdkVersion build_versions.target_sdk
27+
}
28+
29+
compileOptions {
30+
sourceCompatibility JavaVersion.VERSION_1_8
31+
targetCompatibility JavaVersion.VERSION_1_8
32+
}
33+
34+
lintOptions {
35+
abortOnError false
36+
}
37+
38+
}
39+
40+
dependencies {
41+
implementation deps.androidx.appcompat
42+
implementation project(':module-common-test')
43+
}

module1-test/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2021 xuexiangjys([email protected])
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
18+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
19+
package="com.xuexiang.module1_test">
20+
21+
<application>
22+
23+
<activity android:name=".Module1Activity"/>
24+
25+
</application>
26+
27+
</manifest>

0 commit comments

Comments
 (0)