Permalink
Browse files

So long, @icicle

  • Loading branch information...
frankiesardo committed Jul 22, 2015
1 parent 0d7706e commit f60b4b9c0307be208178381661ee13b958eda531
View
@@ -9,7 +9,7 @@ It uses annotation processing to generate code that does bundle manipulation and
```java
class ExampleActivity extends Activity {
- @Icicle String username; // This will be automatically saved and restored
+ @State String username; // This will be automatically saved and restored
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -32,7 +32,7 @@ Icepick can also generate the instance state code for custom Views:
```java
class CustomView extends View {
- @Icicle int selectedPosition; // This will be automatically saved and restored
+ @State int selectedPosition; // This will be automatically saved and restored
@Override public Parcelable onSaveInstanceState() {
return Icepick.saveInstanceState(this, super.onSaveInstanceState());
@@ -55,8 +55,8 @@ If Proguard is enabled make sure you add these rules to your configuration:
```
-dontwarn icepick.**
--keep class **$$Icicle { *; }
--keepnames class * { @icepick.Icicle *;}
+-keep class **$$State { *; }
+-keepnames class * { @icepick.State *;}
-keepclasseswithmembernames class * {
@icepick.* <fields>;
}
@@ -2,7 +2,7 @@
(:require [clojure.java.io :as io]
[clojure.string :as str]
[stencil.core :as mustache])
- (:import (icepick Icicle
+ (:import (icepick State
Icepick)
(javax.tools Diagnostic$Kind)
(javax.lang.model.type TypeMirror
@@ -128,7 +128,7 @@ public class {{name}}<T extends {{target}}> extends {{parent}}<T> {
(defn- annotated-class? [^TypeElement elem]
(seq (for [field (ElementFilter/fieldsIn (.getEnclosedElements elem))
ann (.getAnnotationMirrors field)
- :when (= (.getName Icicle)
+ :when (= (.getName State)
(-> ann .getAnnotationType .asElement str))]
field)))
@@ -22,7 +22,7 @@
import clojure.lang.IFn;
import clojure.lang.Compiler;
-import icepick.Icicle;
+import icepick.State;
import com.google.auto.service.AutoService;
@@ -60,6 +60,6 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
}
@Override public Set<String> getSupportedAnnotationTypes() {
- return new HashSet<String>(Arrays.asList(Icicle.class.getName()));
+ return new HashSet<String>(Arrays.asList(State.class.getName()));
}
}
@@ -44,38 +44,38 @@
(check-fails
["test.Test"
["package test;"
- "import icepick.Icicle;"
+ "import icepick.State;"
"public class Test {"
- " @Icicle private int f1;"
+ " @State private int f1;"
"}"]]))
(testing "private class"
(check-fails
["test.Test"
["package test;"
- "import icepick.Icicle;"
+ "import icepick.State;"
"public class Test {"
" private static class Inner {"
- " @Icicle private int f1;"
+ " @State private int f1;"
" }"
"}"]])))
(deftest simple
(check-compiles
["test.Test"
["package test;"
- "import icepick.Icicle;"
+ "import icepick.State;"
"public class Test {"
- " @Icicle int f1;"
- " @Icicle boolean f2;"
- " @Icicle char[] f3;"
+ " @State int f1;"
+ " @State boolean f2;"
+ " @State char[] f3;"
"}"]]
- ["test.Test$$Icicle"
+ ["test.Test$$Icepick"
["package test;"
"import android.os.Bundle;"
"import icepick.Injector.Helper;"
"import icepick.Injector.Object;"
- "public class Test$$Icicle<T extends Test> extends Object<T> {"
- " private final static Helper H = new Helper(\"test.Test$$Icicle.\");"
+ "public class Test$$Icepick<T extends Test> extends Object<T> {"
+ " private final static Helper H = new Helper(\"test.Test$$Icepick.\");"
" public void restore(T target, Bundle state) {"
" if (state == null) return;"
" target.f1 = H.getInt(state, \"f1\");"
@@ -95,17 +95,17 @@
(check-compiles
["test.Test"
["package test;"
- "import icepick.Icicle;"
+ "import icepick.State;"
"public class Test {"
- " @Icicle Float f1;"
+ " @State Float f1;"
"}"]]
- ["test.Test$$Icicle"
+ ["test.Test$$Icepick"
["package test;"
"import android.os.Bundle;"
"import icepick.Injector.Helper;"
"import icepick.Injector.Object;"
- "public class Test$$Icicle<T extends Test> extends Object<T> {"
- " private final static Helper H = new Helper(\"test.Test$$Icicle.\");"
+ "public class Test$$Icepick<T extends Test> extends Object<T> {"
+ " private final static Helper H = new Helper(\"test.Test$$Icepick.\");"
" public void restore(T target, Bundle state) {"
" if (state == null) return;"
" target.f1 = H.getBoxedFloat(state, \"f1\");"
@@ -122,26 +122,26 @@
(check-fails
["test.Test"
["package test;"
- "import icepick.Icicle;"
+ "import icepick.State;"
"public class Test<T extends CharSequence> {"
- " @Icicle T f1;"
+ " @State T f1;"
"}"]]))
(testing "unless T is Parcelable"
(check-compiles
["test.Test"
["package test;"
- "import icepick.Icicle;"
+ "import icepick.State;"
"import android.os.Parcelable;"
"public class Test<T extends Parcelable> {"
- " @Icicle T f1;"
+ " @State T f1;"
"}"]]
- ["test.Test$$Icicle"
+ ["test.Test$$Icepick"
["package test;"
"import android.os.Bundle;"
"import icepick.Injector.Helper;"
"import icepick.Injector.Object;"
- "public class Test$$Icicle<T extends Test> extends Object<T> {"
- " private final static Helper H = new Helper(\"test.Test$$Icicle.\");"
+ "public class Test$$Icepick<T extends Test> extends Object<T> {"
+ " private final static Helper H = new Helper(\"test.Test$$Icepick.\");"
" public void restore(T target, Bundle state) {"
" if (state == null) return;"
" target.f1 = H.getParcelable(state, \"f1\");"
@@ -156,21 +156,21 @@
(check-compiles
["test.Test"
["package test;"
- "import icepick.Icicle;"
+ "import icepick.State;"
"import java.util.ArrayList;"
"import android.util.SparseArray;"
"import android.os.Parcelable;"
"public class Test<T extends Parcelable> {"
- " @Icicle ArrayList<T> f1;"
- " @Icicle SparseArray<T> f2;"
+ " @State ArrayList<T> f1;"
+ " @State SparseArray<T> f2;"
"}"]]
- ["test.Test$$Icicle"
+ ["test.Test$$Icepick"
["package test;"
"import android.os.Bundle;"
"import icepick.Injector.Helper;"
"import icepick.Injector.Object;"
- "public class Test$$Icicle<T extends Test> extends Object<T> {"
- " private final static Helper H = new Helper(\"test.Test$$Icicle.\");"
+ "public class Test$$Icepick<T extends Test> extends Object<T> {"
+ " private final static Helper H = new Helper(\"test.Test$$Icepick.\");"
" public void restore(T target, Bundle state) {"
" if (state == null) return;"
" target.f1 = H.getParcelableArrayList(state, \"f1\");"
@@ -187,24 +187,24 @@
(check-compiles
["test.Test"
["package test;"
- "import icepick.Icicle;"
+ "import icepick.State;"
"import java.util.ArrayList;"
"import android.os.Bundle;"
"public class Test {"
" static class AL<T> extends ArrayList<T> {}"
- " @Icicle AL<Integer> f1;"
- " @Icicle AL<String> f2;"
- " @Icicle AL<CharSequence> f3;"
- " @Icicle Bundle[] f4;"
- " @Icicle StringBuffer[] f5;"
+ " @State AL<Integer> f1;"
+ " @State AL<String> f2;"
+ " @State AL<CharSequence> f3;"
+ " @State Bundle[] f4;"
+ " @State StringBuffer[] f5;"
"}"]]
- ["test.Test$$Icicle"
+ ["test.Test$$Icepick"
["package test;"
"import android.os.Bundle;"
"import icepick.Injector.Helper;"
"import icepick.Injector.Object;"
- "public class Test$$Icicle<T extends Test> extends Object<T> {"
- " private final static Helper H = new Helper(\"test.Test$$Icicle.\");"
+ "public class Test$$Icepick<T extends Test> extends Object<T> {"
+ " private final static Helper H = new Helper(\"test.Test$$Icepick.\");"
" public void restore(T target, Bundle state) {"
" if (state == null) return;"
" target.f1 = H.getSerializable(state, \"f1\");"
@@ -228,22 +228,22 @@
(check-compiles
["test.Test"
["package test;"
- "import icepick.Icicle;"
+ "import icepick.State;"
"import android.os.Parcelable;"
"import android.os.Bundle;"
"public class Test<T extends Parcelable> {"
- " @Icicle T f1;"
+ " @State T f1;"
" static class Inner extends Test<Bundle> {"
- " @Icicle String f2;"
+ " @State String f2;"
" }"
"}"]]
- ["test.Test$$Icicle"
+ ["test.Test$$Icepick"
["package test;"
"import android.os.Bundle;"
"import icepick.Injector.Helper;"
"import icepick.Injector.Object;"
- "public class Test$$Icicle<T extends Test> extends Object<T> {"
- " private final static Helper H = new Helper(\"test.Test$$Icicle.\");"
+ "public class Test$$Icepick<T extends Test> extends Object<T> {"
+ " private final static Helper H = new Helper(\"test.Test$$Icepick.\");"
" public void restore(T target, Bundle state) {"
" if (state == null) return;"
" target.f1 = H.getParcelable(state, \"f1\");"
@@ -254,13 +254,13 @@
" H.putParcelable(state, \"f1\", target.f1);"
" }"
"}"]]
- ["test.Test$Inner$$Icicle"
+ ["test.Test$Inner$$Icepick"
["package test;"
"import android.os.Bundle;"
"import icepick.Injector.Helper;"
"import icepick.Injector.Object;"
- "public class Test$Inner$$Icicle<T extends Test.Inner> extends test.Test$$Icicle<T> {"
- " private final static Helper H = new Helper(\"test.Test$Inner$$Icicle.\");"
+ "public class Test$Inner$$Icepick<T extends Test.Inner> extends test.Test$$Icepick<T> {"
+ " private final static Helper H = new Helper(\"test.Test$Inner$$Icepick.\");"
" public void restore(T target, Bundle state) {"
" if (state == null) return;"
" target.f2 = H.getString(state, \"f2\");"
@@ -276,27 +276,27 @@
(check-compiles
["test.Test"
["package test;"
- "import icepick.Icicle;"
+ "import icepick.State;"
"import android.view.View;"
"import android.content.Context;"
"import android.os.Parcelable;"
"import android.os.Bundle;"
"public class Test<T extends Parcelable> extends View {"
" public Test(Context c) {super(c);}"
- " @Icicle T f1;"
+ " @State T f1;"
" static class Inner extends Test<Bundle> {"
" public Inner(Context c) {super(c);}"
- " @Icicle String f2;"
+ " @State String f2;"
" }"
"}"]]
- ["test.Test$$Icicle"
+ ["test.Test$$Icepick"
["package test;"
"import android.os.Bundle;"
"import android.os.Parcelable;"
"import icepick.Injector.Helper;"
"import icepick.Injector.View;"
- "public class Test$$Icicle<T extends Test> extends View<T> {"
- " private final static Helper H = new Helper(\"test.Test$$Icicle.\");"
+ "public class Test$$Icepick<T extends Test> extends View<T> {"
+ " private final static Helper H = new Helper(\"test.Test$$Icepick.\");"
" public Parcelable restore(T target, Parcelable p) {"
" Bundle state = (Bundle) p;"
" target.f1 = H.getParcelable(state, \"f1\");"
@@ -308,14 +308,14 @@
" return state;"
" }"
"}"]]
- ["test.Test$Inner$$Icicle"
+ ["test.Test$Inner$$Icepick"
["package test;"
"import android.os.Bundle;"
"import android.os.Parcelable;"
"import icepick.Injector.Helper;"
"import icepick.Injector.View;"
- "public class Test$Inner$$Icicle<T extends Test.Inner> extends test.Test$$Icicle<T> {"
- " private final static Helper H = new Helper(\"test.Test$Inner$$Icicle.\");"
+ "public class Test$Inner$$Icepick<T extends Test.Inner> extends test.Test$$Icepick<T> {"
+ " private final static Helper H = new Helper(\"test.Test$Inner$$Icepick.\");"
" public Parcelable restore(T target, Parcelable p) {"
" Bundle state = (Bundle) p;"
" target.f2 = H.getString(state, \"f2\");"
@@ -9,7 +9,7 @@
public class Icepick {
- public static final String SUFFIX = "$$Icicle";
+ public static final String SUFFIX = "$$Icepick";
public static final String ANDROID_PREFIX = "android.";
public static final String JAVA_PREFIX = "java.";
@@ -7,5 +7,5 @@
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.CLASS)
-public @interface Icicle {
+public @interface State {
}
@@ -4,11 +4,11 @@
import android.os.Parcelable;
import android.util.AttributeSet;
import com.sample.icepick.lib.BaseCustomView;
-import icepick.Icicle;
+import icepick.State;
public class CustomView extends BaseCustomView {
- @Icicle Integer textColor;
+ @State Integer textColor;
public CustomView(Context context) {
super(context);
@@ -5,11 +5,11 @@
import android.view.Menu;
import android.view.MenuItem;
import com.sample.icepick.lib.BaseActivity;
-import icepick.Icicle;
+import icepick.State;
public class MainActivity extends BaseActivity {
- @Icicle String message;
+ @State String message;
CustomView customView;
@@ -4,11 +4,11 @@
import android.os.Bundle;
import android.os.Parcelable;
import icepick.Icepick;
-import icepick.Icicle;
+import icepick.State;
import android.util.Log;
public class BaseActivity extends Activity {
- @Icicle protected String baseMessage;
+ @State protected String baseMessage;
@Override
protected void onCreate(Bundle savedInstanceState) {
Oops, something went wrong.

0 comments on commit f60b4b9

Please sign in to comment.