Skip to content

Commit 90bd460

Browse files
author
xiaoqi
committed
update to 3.0.7
1 parent 012a7de commit 90bd460

6 files changed

Lines changed: 65 additions & 12 deletions

File tree

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

README.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,37 @@
2626
2.2.6 增加对自定义view的数据保存以及恢复
2727
3.0.0 增加autosave plugin,省去SaveHelper.save 和 SaveHelper.recover的调用
2828
3.0.6 简化引入方式
29+
3.0.7 添加对kotlin的支持
2930

3031
## 引入方式
3132
在project的gradle加入下面的依赖:
3233

3334
dependencies {
34-
classpath 'com.noober.save:plugin:3.0.6'
35+
...
36+
classpath 'com.noober.save:plugin:3.0.7'
3537
}
3638

3739
在app的gradle或者module的gradle中加入下面插件即可:
3840

3941
apply plugin: 'AutoSave'
4042

41-
如果需要支持kotlin:
43+
如果需要支持kotlin:
44+
project的gradle:
4245

46+
dependencies {
47+
...
48+
classpath 'com.noober.save:plugin:3.0.7'
49+
classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.2'
50+
}
51+
52+
53+
在app的gradle或者module的gradle:
54+
4355
apply plugin: 'kotlin-kapt'
4456
apply plugin: 'kotlin-android-extensions'
4557
apply plugin: 'kotlin-android'
4658
apply plugin: 'AutoSave'
59+
apply plugin: 'android-aspectjx'
4760

4861
## 混淆配置:
4962

@@ -62,8 +75,7 @@ _**注意:**_
6275
1.Activity和Fragment中使用的时候必须重写一下**onSaveInstanceState方法**,或者在父类BaseActivity和BaseFragment
6376
**重写一次**即可,否则保存数据的代码会注入失败
6477
2.如果想要自己定义内存恢复的位置可以使用**SaveHelper.recover**方法
65-
3.kotlin使用注意,kotlin暂时还不支持编译期间注入代码,需要自己去写**SaveHelper.recover** **SaveHelper.save**方法
66-
4.如果要在kotlin使用,与在java中使用相同,直接加注解即可,但是不同之出在于:
78+
3.如果要在kotlin使用,与在java中使用相同,直接加注解即可,但是不同之出在于:
6779
4.1:如果是基本数据类型,需要多添加一个注解@JvmField
6880
4.2:如果是其他数据类型,需要增加lateinit关键字或者添加一个注解@JvmField
6981
否则会报错"the modifier of the field must not be private, otherwise it won't work"。
@@ -138,7 +150,6 @@ _**注意:**_
138150
override fun onCreate(savedInstanceState: Bundle?) {
139151
super.onCreate(savedInstanceState)
140152
setContentView(R.layout.activity_kotlin)
141-
SaveHelper.recover(this, savedInstanceState)
142153
Log.e("KotlinActivity", a.toString())
143154

144155
}
@@ -147,7 +158,6 @@ _**注意:**_
147158
override fun onSaveInstanceState(outState: Bundle?) {
148159
Log.e("KotlinActivity", "onSaveInstanceState")
149160
a = 2
150-
SaveHelper.save(this, outState)
151161
super.onSaveInstanceState(outState)
152162
}
153163
}

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ buildscript {
2020
// NOTE: Do not place your application dependencies here; they belong
2121
// in the individual module build.gradle files
2222
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
23-
// classpath 'com.noober.plugin:savehelper-plugin:3.0.4-beta'
23+
classpath 'com.noober.plugin:savehelper-plugin:3.0.6'
2424
// classpath 'com.noober.save:plugin:3.0.1-beta'
2525
classpath 'org.aspectj:aspectjtools:1.8.13'
26-
// classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.2'
26+
classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.2'
2727
}
2828
}
2929

@@ -50,7 +50,7 @@ ext {
5050
userOrg = 'noober'
5151
groupId = 'com.noober'
5252
uploadName = 'AutoSaver'
53-
publishVersion = '3.0.6'
53+
publishVersion = '3.0.7'
5454
desc = "A light weight framework can automatically generate 'OnSaveInstanceState' code"
5555
website = 'https://github.com/JavaNoober/AutoSave'
5656
// gradlew clean build bintrayUpload -PbintrayUser=xiaoqiandroid -PbintrayKey=xxxxxxxxxxxxxxxx -PdryRun=false

sample/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ apply plugin: 'com.android.application'
22
apply plugin: 'kotlin-kapt'
33
apply plugin: 'kotlin-android-extensions'
44
apply plugin: 'kotlin-android'
5-
//apply plugin: 'JavasisstPlugin'
5+
apply plugin: 'AutoSave'
6+
apply plugin: 'android-aspectjx'
67

78
android {
89
compileSdkVersion 26

savehelper-plugin/src/main/groovy/com/noober/plugin/SavePlugin.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class SavePlugin implements Plugin<Project> {
2424
// project.dependencies {
2525
// implementation 'org.aspectj:aspectjrt:1.8.13'
2626
// }
27-
final def autoSaveVersion = "3.0.6"
27+
final def autoSaveVersion = "3.0.7"
2828
if (project.plugins.hasPlugin('kotlin-android')) {
2929
project.dependencies {
3030
implementation 'org.aspectj:aspectjrt:1.8.13'

savehelper/build.gradle

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import org.aspectj.bridge.IMessage
2+
import org.aspectj.bridge.MessageHandler
3+
import org.aspectj.tools.ajc.Main
4+
15
apply plugin: 'com.android.library'
26
apply plugin: 'bintray-release'
37

@@ -35,6 +39,44 @@ dependencies {
3539
testImplementation 'junit:junit:4.12'
3640
}
3741

42+
final def log = project.logger
43+
final def variants = project.android.libraryVariants
44+
45+
variants.all { variant ->
46+
JavaCompile javaCompile = variant.javaCompile
47+
javaCompile.doLast {
48+
String[] args = ["-showWeaveInfo",
49+
"-1.7",
50+
"-inpath", javaCompile.destinationDir.toString(),
51+
"-aspectpath", javaCompile.classpath.asPath,
52+
"-d", javaCompile.destinationDir.toString(),
53+
"-classpath", javaCompile.classpath.asPath,
54+
"-bootclasspath", project.android.bootClasspath.join(File.pathSeparator)]
55+
log.debug "ajc args: " + Arrays.toString(args)
56+
57+
MessageHandler handler = new MessageHandler(true);
58+
new Main().run(args, handler);
59+
for (IMessage message : handler.getMessages(null, true)) {
60+
switch (message.getKind()) {
61+
case IMessage.ABORT:
62+
case IMessage.ERROR:
63+
case IMessage.FAIL:
64+
log.error message.message, message.thrown
65+
break;
66+
case IMessage.WARNING:
67+
log.warn message.message, message.thrown
68+
break;
69+
case IMessage.INFO:
70+
log.info message.message, message.thrown
71+
break;
72+
case IMessage.DEBUG:
73+
log.debug message.message, message.thrown
74+
break;
75+
}
76+
}
77+
}
78+
}
79+
3880
//添加
3981
publish {
4082
artifactId = 'savehelper'

0 commit comments

Comments
 (0)