Search in sources :

Example 11 with FilterUserPresetRepresentation

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);
    }
}
Also used : FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation) IOException(java.io.IOException) FilterUserPresetRepresentation(com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation)

Example 12 with FilterUserPresetRepresentation

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();
}
Also used : FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation) FilterUserPresetRepresentation(com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation)

Example 13 with FilterUserPresetRepresentation

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);
}
Also used : Message(android.os.Message) FilterUserPresetRepresentation(com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation)

Example 14 with FilterUserPresetRepresentation

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;
}
Also used : ArrayList(java.util.ArrayList) ImagePreset(com.android.gallery3d.filtershow.pipeline.ImagePreset) Cursor(android.database.Cursor) FilterUserPresetRepresentation(com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation)

Aggregations

FilterUserPresetRepresentation (com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation)14 FilterRepresentation (com.android.gallery3d.filtershow.filters.FilterRepresentation)6 ImagePreset (com.android.gallery3d.filtershow.pipeline.ImagePreset)4 Action (com.android.gallery3d.filtershow.category.Action)2 Cursor (android.database.Cursor)1 Bitmap (android.graphics.Bitmap)1 Point (android.graphics.Point)1 Message (android.os.Message)1 FilterMirrorRepresentation (com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation)1 FilterRotateRepresentation (com.android.gallery3d.filtershow.filters.FilterRotateRepresentation)1 ImageFilter (com.android.gallery3d.filtershow.filters.ImageFilter)1 State (com.android.gallery3d.filtershow.state.State)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Vector (java.util.Vector)1