Skip to content

Commit ac5330a

Browse files
author
xiaoqi
committed
update plugin
(cherry picked from commit a5cdd91)
1 parent ac83b82 commit ac5330a

28 files changed

Lines changed: 582 additions & 218 deletions

.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.

SavePlugin.gradle

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
buildscript {
2+
3+
repositories {
4+
jcenter()
5+
}
6+
dependencies {
7+
classpath 'org.aspectj:aspectjtools:1.8.13'
8+
}
9+
}
10+
11+
import org.aspectj.bridge.IMessage
12+
import org.aspectj.bridge.MessageHandler
13+
import org.aspectj.tools.ajc.Main
14+
15+
final def log = project.logger
16+
final def variants = project.android.applicationVariants
17+
18+
variants.all { variant ->
19+
20+
JavaCompile javaCompile = variant.javaCompile
21+
javaCompile.doLast {
22+
String[] args = ["-showWeaveInfo",
23+
"-1.5",
24+
"-inpath", javaCompile.destinationDir.toString(),
25+
"-aspectpath", javaCompile.classpath.asPath,
26+
"-d", javaCompile.destinationDir.toString(),
27+
"-classpath", javaCompile.classpath.asPath,
28+
"-bootclasspath", project.android.bootClasspath.join(File.pathSeparator)]
29+
log.debug "ajc args: " + Arrays.toString(args)
30+
31+
MessageHandler handler = new MessageHandler(true);
32+
new Main().run(args, handler);
33+
for (IMessage message : handler.getMessages(null, true)) {
34+
switch (message.getKind()) {
35+
case IMessage.ABORT:
36+
case IMessage.ERROR:
37+
case IMessage.FAIL:
38+
log.error message.message, message.thrown
39+
break;
40+
case IMessage.WARNING:
41+
log.warn message.message, message.thrown
42+
break;
43+
case IMessage.INFO:
44+
log.info message.message, message.thrown
45+
break;
46+
case IMessage.DEBUG:
47+
log.debug message.message, message.thrown
48+
break;
49+
}
50+
}
51+
}
52+
}
53+
54+
55+
56+
dependencies {
57+
compile 'org.aspectj:aspectjrt:1.8.13'
58+
}

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ buildscript {
2020
// in the individual module build.gradle files
2121
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
2222
classpath 'com.noober.plugin:savehelper-plugin:1.0.0'
23+
classpath 'org.aspectj:aspectjtools:1.8.13'
2324
}
2425
}
2526

@@ -46,7 +47,7 @@ ext {
4647
userOrg = 'noober'
4748
groupId = 'com.noober'
4849
uploadName = 'AutoSaver'
49-
publishVersion = '2.2.6'
50+
publishVersion = '3.0.0'
5051
desc = "A light weight framework can automatically generate 'OnSaveInstanceState' code"
5152
website = 'https://github.com/JavaNoober/AutoSave'
5253
// gradlew clean build bintrayUpload -PbintrayUser=xiaoqiandroid -PbintrayKey=xxxxxxxxxxxxxxxx -PdryRun=false

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# The setting is particularly useful for tweaking memory settings.
1212
#org.gradle.jvmargs=-Xmx1536m
1313
#org.gradle.jvmargs= -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005;
14-
org.gradle.jvmargs=-Xmx512m
14+
org.gradle.jvmargs=-Xmx4096m
1515
org.gradle.parallel=true
1616
# When configured, Gradle will run in incubating parallel mode.
1717
# This option should only be used with decoupled projects. More details, visit

sample/build.gradle

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ apply plugin: 'kotlin-android-extensions'
44
apply plugin: 'kotlin-android'
55
apply plugin: 'myplugin'
66

7-
87
android {
98
compileSdkVersion 26
109
buildToolsVersion '26.0.2'
@@ -34,12 +33,12 @@ dependencies {
3433
})
3534
implementation 'com.android.support:appcompat-v7:26.0.1'
3635
// testImplementation 'junit:junit:4.12'
37-
implementation 'com.noober:savehelper:2.2.6'
38-
kapt 'com.noober:processor:2.2.6'
39-
implementation 'com.noober:savehelper-api:2.2.6'
40-
// implementation project(':savehelper')
41-
// implementation project(':savehelper-api')
42-
// kapt project(':savehelper-processor')
36+
// implementation 'com.noober:savehelper:2.2.6'
37+
// kapt 'com.noober:processor:2.2.6'
38+
// implementation 'com.noober:savehelper-api:2.2.6'
39+
implementation project(':savehelper')
40+
implementation project(':savehelper-api')
41+
kapt project(':savehelper-processor')
4342
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
4443
}
4544

sample/src/main/AndroidManifest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
<activity
1111
android:name=".SampleActivity"
1212
android:persistableMode="persistAcrossReboots">
13+
14+
</activity>
15+
<activity android:name=".TestActivity">
1316
<intent-filter>
1417
<action android:name="android.intent.action.MAIN" />
1518

1619
<category android:name="android.intent.category.LAUNCHER" />
1720
</intent-filter>
1821
</activity>
19-
<activity android:name=".TestActivity"></activity>
2022
<activity android:name=".KotlinActivity">
2123

2224
</activity>

sample/src/main/java/com/recover/autosavesample/BaseActivity.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
public class BaseActivity extends AppCompatActivity {
1313

1414

15-
@Override
16-
protected void onRestoreInstanceState(Bundle savedInstanceState) {
17-
super.onRestoreInstanceState(savedInstanceState);
18-
SaveHelper.recover(this, savedInstanceState);
19-
}
15+
// @Override
16+
// protected void onRestoreInstanceState(Bundle savedInstanceState) {
17+
// super.onRestoreInstanceState(savedInstanceState);
18+
// SaveHelper.recover(this, savedInstanceState);
19+
// }
2020

2121
@Override
2222
protected void onSaveInstanceState(Bundle outState) {

sample/src/main/java/com/recover/autosavesample/KotlinActivity.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ class KotlinActivity : AppCompatActivity() {
2424
}
2525

2626

27-
override fun onSaveInstanceState(outState: Bundle?) {
28-
Log.e("KotlinActivity", "onSaveInstanceState")
29-
a = 2
30-
SaveHelper.save(this, outState)
31-
super.onSaveInstanceState(outState)
32-
}
27+
// override fun onSaveInstanceState(outState: Bundle?) {
28+
// Log.e("KotlinActivity", "onSaveInstanceState")
29+
// a = 2
30+
// SaveHelper.save(this, outState)
31+
// super.onSaveInstanceState(outState)
32+
// }
3333
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//package com.recover.autosavesample;
2+
//
3+
//import android.util.Log;
4+
//
5+
//import org.aspectj.lang.ProceedingJoinPoint;
6+
//import org.aspectj.lang.annotation.Around;
7+
//import org.aspectj.lang.annotation.Aspect;
8+
//
9+
///**
10+
// * Created by xiaoqi on 2018/3/13
11+
// */
12+
//
13+
//@Aspect
14+
//public class SaveAspectj {
15+
//
16+
// public static final String TAG = "Statistics";
17+
//
18+
//// @Around("execution(@com.noob.databurialpoint.Statistics * *(..)) && @annotation(statistics)")
19+
//// public void aroundJoinPoint(ProceedingJoinPoint joinPoint, Statistics statistics) throws Throwable {
20+
//// calculate(statistics);
21+
//// joinPoint.proceed();//执行原方法
22+
//// }
23+
////
24+
//// private void calculate(Statistics statistics){
25+
//// if(statistics != null){
26+
//// Log.e(TAG, "对" + statistics.function().getFunctionName() + "进行统计");
27+
//// // select * from FunctionsTable where operatorId=statistics.getFunctionId()
28+
//// //if(size > 0){
29+
//// // int counts = operateCounts ++
30+
//// // update FunctionsTable set operateCounts = counts
31+
//// // }else {
32+
//// // insert into FunctionsTable values (xxx, statistics.getFunctionId(), 1)
33+
//// // }
34+
//// }
35+
//// }
36+
//
37+
// @Around("execution(* android.app.Activity.onCreate(..))")
38+
// public void onClickLitener(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
39+
//// Log.e(TAG, "OnClick");
40+
// Log.e(TAG, "OnClick");
41+
// proceedingJoinPoint.proceed();
42+
// }
43+
//}

sample/src/main/java/com/recover/autosavesample/TestActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import android.widget.TextView;
99

1010
import com.noober.api.NeedSave;
11+
import com.noober.savehelper.SaveHelper;
1112

1213
import java.util.ArrayList;
1314
import java.util.HashMap;
@@ -19,7 +20,7 @@ public class TestActivity extends BaseActivity {
1920
private Button button;
2021
private final static String testContent = "This is a test code:";
2122

22-
// @NeedSave
23+
@NeedSave
2324
String testString = "11111111";
2425

2526
@NeedSave

0 commit comments

Comments
 (0)