Skip to content

Commit e01460c

Browse files
author
xiaoqi
committed
update to 2.0.4, fix bugs
1 parent bda1a09 commit e01460c

9 files changed

Lines changed: 30 additions & 12 deletions

File tree

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
支持基本所有bundle可以传入的类型,包括SparseParcelableArray等, 如果传入的类型bundle不支持会抛异常(如果有遗漏的类型,请在github 提出issue);
1919
2.0.2 修复通过继承去实现Serializable的对象不能识别的bug;
2020
2.0.3 优化异常提示
21+
2.0.4 修复枚举类型保存的时候不能识别的问题
2122

2223

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

2526

26-
compile 'com.noober:savehelper:2.0.3'
27-
compile 'com.noober:savehelper-api:2.0.3'
28-
annotationProcessor 'com.noober:processor:2.0.3'
27+
compile 'com.noober:savehelper:2.0.4'
28+
compile 'com.noober:savehelper-api:2.0.4'
29+
annotationProcessor 'com.noober:processor:2.0.4'
2930

3031
# 引入
3132

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.3'
38+
publishVersion = '2.0.4'
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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ dependencies {
2727
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
2828
exclude group: 'com.android.support', module: 'support-annotations'
2929
})
30-
implementation 'com.android.support:appcompat-v7:+'
30+
implementation 'com.android.support:appcompat-v7:26.1.0'
3131
testImplementation 'junit:junit:4.12'
32-
implementation 'com.noober:savehelper:2.0.3'
33-
annotationProcessor 'com.noober:processor:2.0.3'
34-
implementation 'com.noober:savehelper-api:2.0.3'
32+
implementation 'com.noober:savehelper:2.0.4'
33+
annotationProcessor 'com.noober:processor:2.0.4'
34+
implementation 'com.noober:savehelper-api:2.0.4'
3535
// implementation project(':savehelper')
3636
// implementation project(':savehelper-api')
3737
// annotationProcessor project(':savehelper-processor')
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.recover.autosavesample;
2+
3+
/**
4+
* Created by xiaoqi on 2018/3/10
5+
*/
6+
7+
public enum EnumTest {
8+
9+
10+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ public class TestActivity extends BaseActivity {
2424
@NeedSave
2525
String[] stringArray;
2626

27+
@NeedSave
28+
EnumTest enumTest;
29+
2730
SerializableExample[] ssss;
2831
@Override
2932
protected void onCreate(Bundle savedInstanceState) {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ public ElementKind getKind(){
3131
return encloseElement.getKind();
3232
}
3333

34+
public VariableElement getElement(){
35+
return encloseElement;
36+
}
3437

3538
public Name getSimpleName(){
3639
return encloseElement.getSimpleName();

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.noober.processor;
22

3+
import com.noober.helper.HelperSavedValues;
34
import com.noober.utils.FieldConstant;
45

56
import java.lang.reflect.Field;
@@ -143,7 +144,9 @@ private static String getFieldInterface(Elements elementUtils, String outFieldNa
143144
}
144145
if(type.equals("unKnow")){
145146
TypeMirror typeMirror = typeElement.getSuperclass();
146-
if(!typeMirror.toString().equals(Object.class.getCanonicalName())){
147+
if(typeMirror.toString().startsWith("java.lang.Enum<")){
148+
type = SERIALIZABLE;
149+
}else if(!typeMirror.toString().equals(Object.class.getCanonicalName())){
147150
type = getFieldInterface(elementUtils, typeMirror.toString());
148151
}
149152
}

savehelper/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ dependencies {
3131
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
3232
exclude group: 'com.android.support', module: 'support-annotations'
3333
})
34-
provided 'com.android.support:appcompat-v7:+'
34+
// provided 'com.android.support:appcompat-v7:+'
3535
testImplementation 'junit:junit:4.12'
3636
}
3737

savehelper/src/main/java/com/noober/savehelper/SaveHelper.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.noober.savehelper;
22

33
import android.os.Bundle;
4-
import android.support.annotation.Nullable;
54

65
import java.util.HashMap;
76
import java.util.Map;
@@ -44,7 +43,6 @@ public static <T> void save(T save, Bundle outState){
4443
}
4544

4645

47-
@Nullable
4846
private static <T> ISaveInstanceStateHelper<T> findSaveHelper(T cl) {
4947
String clazz = cl.getClass().getName();
5048
ISaveInstanceStateHelper<T> saveInstanceStateHelper = helperCache.get(clazz);

0 commit comments

Comments
 (0)