Skip to content

Commit 7e3464e

Browse files
author
xiaoqi
committed
update to 2.0.2
1 parent f04df02 commit 7e3464e

8 files changed

Lines changed: 37 additions & 12 deletions

File tree

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616
2.0.0 去掉NeedSave注解中的isParcelable字段,自动可以支持不同类型;
1717
如果字段被标记为private在编译的时候会抛异常;
1818
支持基本所有bundle可以传入的类型,包括SparseParcelableArray等, 如果传入的类型bundle不支持会抛异常(如果有遗漏的类型,请在github 提出issue);
19+
2.0.2 修复通过继承去实现Serializable的对象不能识别的bug
1920

2021

2122
引入方式,在app的gradle中加入下面依赖即可:
2223

2324

24-
compile 'com.noober:savehelper:2.0.0'
25-
compile 'com.noober:savehelper-api:2.0.0'
26-
annotationProcessor 'com.noober:processor:2.0.0'
25+
compile 'com.noober:savehelper:2.0.2'
26+
compile 'com.noober:savehelper-api:2.0.2'
27+
annotationProcessor 'com.noober:processor:2.0.2'
2728

2829
# 引入
2930

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ ext {
3535
userOrg = 'noober'
3636
groupId = 'com.noober'
3737
uploadName = 'AutoSaver'
38-
publishVersion = '2.0.0'
38+
publishVersion = '2.0.2'
3939
desc = "A light weight framework can automatically generate 'OnSaveInstanceState' code"
4040
website = 'https://github.com/JavaNoober/AutoSave'
4141
// gradlew clean build bintrayUpload -PbintrayUser=xiaoqiandroid -PbintrayKey=xxxxxxxxxxxxxxxx -PdryRun=false

sample/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ dependencies {
2929
})
3030
implementation 'com.android.support:appcompat-v7:+'
3131
testImplementation 'junit:junit:4.12'
32-
implementation 'com.noober:savehelper:2.0.0'
33-
annotationProcessor 'com.noober:processor:2.0.0'
34-
implementation 'com.noober:savehelper-api:2.0.0'
32+
implementation 'com.noober:savehelper:2.0.2'
33+
annotationProcessor 'com.noober:processor:2.0.2'
34+
implementation 'com.noober:savehelper-api:2.0.2'
3535
// implementation project(':savehelper')
3636
// implementation project(':savehelper-api')
3737
// annotationProcessor project(':savehelper-processor')

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ public class SampleActivity extends AppCompatActivity {
6464
@NeedSave
6565
SizeF sizeFS;
6666

67+
@NeedSave
68+
SecondSExample secondSExample;
6769

70+
// @NeedSave
71+
// SecondSExample2 secondSExample2;
6872
@Override
6973
protected void onCreate(Bundle savedInstanceState) {
7074
super.onCreate(savedInstanceState);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.recover.autosavesample;
2+
3+
/**
4+
* Created by xiaoqi on 2018/2/9
5+
*/
6+
7+
public class SecondSExample extends SerializableExample {
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.recover.autosavesample;
2+
3+
/**
4+
* Created by xiaoqi on 2018/2/9
5+
*/
6+
7+
public class SecondSExample2{
8+
}

savehelper-processor/src/main/java/com/noober/helper/HelperClass.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ private void addMethodStatement(MethodSpec.Builder saveMethodBuilder,MethodSpec.
140140

141141
private void addMethodStatementForClassCast(MethodSpec.Builder saveMethodBuilder, MethodSpec.Builder recoverMethodBuilder, HelperSavedValues value, Name fieldName, String type) {
142142
saveMethodBuilder.addStatement(String.format("outState.put%s($S,save.$N)", type), fieldName
143-
.toString
144-
().toUpperCase(),fieldName);
143+
.toString().toUpperCase(),fieldName);
145144
recoverMethodBuilder.addStatement(String.format("recover.$N = ($T)savedInstanceState.get%s($S)", type),
146145
fieldName, ClassName.get(value.getFieldType()),fieldName.toString().toUpperCase());
147146
}

savehelper-processor/src/main/java/com/noober/processor/HelperConfig.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import javax.lang.model.util.Elements;
1111

1212
/**
13-
* Created by xiaoqi on 2017/1/10.
13+
* Created by xiaoqi on 2017/1/10
1414
*/
1515

1616
public class HelperConfig {
@@ -137,10 +137,15 @@ private static String getFieldInterface(Elements elementUtils, String outFieldNa
137137
break;
138138
} else if (tm.toString().equals(FieldConstant.SERIALIZABLE)) {
139139
type = SERIALIZABLE;
140+
break;
140141
}
141142
}
142-
} else {
143-
type = "unKnow";
143+
}
144+
if(type.equals("unKnow")){
145+
TypeMirror typeMirror = typeElement.getSuperclass();
146+
if(!typeMirror.toString().equals(Object.class.getCanonicalName())){
147+
type = getFieldInterface(elementUtils, typeMirror.toString());
148+
}
144149
}
145150
return type;
146151
}

0 commit comments

Comments
 (0)