summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
diff options
context:
space:
mode:
authorJohn Hoford <hoford@google.com>2013-06-24 15:13:13 -0700
committerJohn Hoford <hoford@google.com>2013-06-26 16:52:37 -0700
commit5762138f8c561cb377d52f3379b89977fc2fbc14 (patch)
treef0428bfb6f875b931bad8e5fecde380370389b59 /src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
parent249892e2a3fb4b14d20395c9486bc73236fb636f (diff)
downloadandroid_packages_apps_Gallery2-5762138f8c561cb377d52f3379b89977fc2fbc14.tar.gz
android_packages_apps_Gallery2-5762138f8c561cb377d52f3379b89977fc2fbc14.tar.bz2
android_packages_apps_Gallery2-5762138f8c561cb377d52f3379b89977fc2fbc14.zip
support non destructive edits of Curves
Change-Id: I597be6570a17072a4116bf6227a6a35796266bc3
Diffstat (limited to 'src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java')
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java43
1 files changed, 41 insertions, 2 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
index b192b5aaa..096bedac9 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
@@ -16,10 +16,15 @@
package com.android.gallery3d.filtershow.filters;
+import android.util.JsonReader;
+import android.util.JsonWriter;
import android.util.Log;
import com.android.gallery3d.filtershow.editors.BasicEditor;
+import java.io.IOException;
+import java.util.ArrayList;
+
public class FilterRepresentation implements Cloneable {
private static final String LOGTAG = "FilterRepresentation";
private static final boolean DEBUG = false;
@@ -40,6 +45,7 @@ public class FilterRepresentation implements Cloneable {
public static final byte TYPE_VIGNETTE = 4;
public static final byte TYPE_NORMAL = 5;
public static final byte TYPE_TINYPLANET = 6;
+ protected static final String NAME_TAG = "Name";
private FilterRepresentation mTempRepresentation = null;
@@ -222,14 +228,47 @@ public class FilterRepresentation implements Cloneable {
return "";
}
+ /**
+ * Method must "beginObject()" add its info and "endObject()"
+ * @param writer
+ * @throws IOException
+ */
+ public void serializeRepresentation(JsonWriter writer) throws IOException {
+ writer.beginObject();
+ {
+ String[][] rep = serializeRepresentation();
+ for (int k = 0; k < rep.length; k++) {
+ writer.name(rep[k][0]);
+ writer.value(rep[k][1]);
+ }
+ }
+ writer.endObject();
+ }
+
+ // this is the old way of doing this and will be removed soon
public String[][] serializeRepresentation() {
- String[][] ret = { { "Name" , getName() }};
+ String[][] ret = {{NAME_TAG, getName()}};
return ret;
}
+ public void deSerializeRepresentation(JsonReader reader) throws IOException {
+ ArrayList<String[]> al = new ArrayList<String[]>();
+ reader.beginObject();
+ while (reader.hasNext()) {
+ String[] kv = {reader.nextName(), reader.nextString()};
+ al.add(kv);
+
+ }
+ reader.endObject();
+ String[][] oldFormat = al.toArray(new String[al.size()][]);
+
+ deSerializeRepresentation(oldFormat);
+ }
+
+ // this is the old way of doing this and will be removed soon
public void deSerializeRepresentation(String[][] rep) {
for (int i = 0; i < rep.length; i++) {
- if ("Name".equals(rep[i][0])) {
+ if (NAME_TAG.equals(rep[i][0])) {
mName = rep[i][1];
break;
}