use of com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation in project android_packages_apps_Gallery2 by LineageOS.
the class ImagePreset method writeJson.
public void writeJson(JsonWriter writer, String name) {
int numFilters = mFilters.size();
try {
writer.beginObject();
for (int i = 0; i < numFilters; i++) {
FilterRepresentation filter = mFilters.get(i);
if (filter instanceof FilterUserPresetRepresentation) {
continue;
}
String sname = filter.getSerializationName();
if (sname == null) {
continue;
}
if (DEBUG) {
Log.v(LOGTAG, "Serialization: " + sname);
if (sname == null) {
Log.v(LOGTAG, "Serialization name null for filter: " + filter);
}
}
writer.name(sname);
filter.serializeRepresentation(writer);
}
writer.endObject();
} catch (IOException e) {
Log.e(LOGTAG, "Error encoding JASON", e);
}
}
use of com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation in project android_packages_apps_Gallery2 by LineageOS.
the class UserPresetsAdapter method deletePreset.
private void deletePreset(Action action) {
FilterRepresentation rep = action.getRepresentation();
if (rep instanceof FilterUserPresetRepresentation) {
mDeletedRepresentations.add((FilterUserPresetRepresentation) rep);
}
remove(action);
notifyDataSetChanged();
}
use of com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation in project android_packages_apps_Gallery2 by LineageOS.
the class UserPresetsManager method processLoad.
private void processLoad() {
ArrayList<FilterUserPresetRepresentation> list = mUserPresets.getAllUserPresets();
Message msg = mResultHandler.obtainMessage(LOAD_RESULT);
msg.obj = list;
mResultHandler.sendMessage(msg);
}
use of com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation in project android_packages_apps_Gallery2 by LineageOS.
the class FilterStackSource method getAllUserPresets.
public ArrayList<FilterUserPresetRepresentation> getAllUserPresets() {
ArrayList<FilterUserPresetRepresentation> ret = new ArrayList<FilterUserPresetRepresentation>();
Cursor c = null;
database.beginTransaction();
try {
c = database.query(FilterStack.TABLE, new String[] { FilterStack._ID, FilterStack.STACK_ID, FilterStack.FILTER_STACK }, null, null, null, null, null, null);
if (c != null) {
boolean loopCheck = c.moveToFirst();
while (loopCheck) {
int id = c.getInt(0);
String name = (c.isNull(1)) ? null : c.getString(1);
byte[] b = (c.isNull(2)) ? null : c.getBlob(2);
String json = new String(b);
ImagePreset preset = new ImagePreset();
preset.readJsonFromString(json);
FilterUserPresetRepresentation representation = new FilterUserPresetRepresentation(name, preset, id);
ret.add(representation);
loopCheck = c.moveToNext();
}
}
database.setTransactionSuccessful();
} finally {
if (c != null) {
c.close();
}
database.endTransaction();
}
return ret;
}
Aggregations