Search in sources :

Example 1 with SaveOption

use of com.android.gallery3d.filtershow.data.FilterPresetSource.SaveOption in project android_packages_apps_Gallery2 by LineageOS.

the class FilterShowActivity method fillPresetFilter.

private void fillPresetFilter() {
    FiltersManager filtersManager = FiltersManager.getManager();
    ArrayList<FilterRepresentation> filtersRepresentations = filtersManager.getFilterPreset();
    if (mChangeable) {
        ArrayList<FilterRepresentation> mFilterPreset = new ArrayList<FilterRepresentation>();
        ArrayList<SaveOption> ret = mFilterPresetSource.getAllUserPresets();
        if (ret == null)
            return;
        for (int id = 0; id < ret.size(); id++) {
            FilterPresetRepresentation representation = new FilterPresetRepresentation(ret.get(id).name, ret.get(id)._id, id + 1);
            Uri filteredUri = Uri.parse(ret.get(id).Uri);
            representation.setUri(filteredUri);
            representation.setSerializationName("Custom");
            mFilterPreset.add(representation);
        }
        if (tempFilterArray.size() != 0) {
            for (int id = 0; id < tempFilterArray.size(); id++) {
                FilterPresetRepresentation representation = new FilterPresetRepresentation(tempFilterArray.get(id).name, tempFilterArray.get(id)._id, id + 1);
                Uri filteredUri = Uri.parse(tempFilterArray.get(id).Uri);
                representation.setUri(filteredUri);
                representation.setSerializationName("Custom");
                mFilterPreset.add(representation);
            }
        }
        filtersRepresentations = mFilterPreset;
        mChangeable = false;
    }
    if (filtersRepresentations == null)
        return;
    for (FilterRepresentation representation : filtersRepresentations) {
        mCategoryLooksAdapter.add(new Action(this, representation, Action.FULL_VIEW, true));
    }
}
Also used : Action(com.android.gallery3d.filtershow.category.Action) FiltersManager(com.android.gallery3d.filtershow.filters.FiltersManager) ArrayList(java.util.ArrayList) FilterPresetRepresentation(com.android.gallery3d.filtershow.filters.FilterPresetRepresentation) FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation) Uri(android.net.Uri) Point(android.graphics.Point) SaveOption(com.android.gallery3d.filtershow.data.FilterPresetSource.SaveOption)

Example 2 with SaveOption

use of com.android.gallery3d.filtershow.data.FilterPresetSource.SaveOption in project android_packages_apps_Gallery2 by LineageOS.

the class FilterShowActivity method nameFilter.

private int nameFilter(FilterPresetSource source, ArrayList<SaveOption> tempFilterArray) {
    String s, s1, s2;
    ArrayList<SaveOption> sp = source.getAllUserPresets();
    ArrayList<Integer> temp = new ArrayList<Integer>();
    if (sp != null) {
        for (int i = 0; i < sp.size(); i++) {
            s = sp.get(i).name;
            if (s.length() > "Custom".length()) {
                s1 = s.substring(0, 6);
                if (s1.equals("Custom")) {
                    s2 = s.substring(6);
                    int tem;
                    try {
                        tem = Integer.parseInt(s2);
                    } catch (NumberFormatException e) {
                        continue;
                    }
                    temp.add(tem);
                }
            }
        }
    }
    if (tempFilterArray.size() != 0) {
        for (int i = 0; i < tempFilterArray.size(); i++) {
            s = tempFilterArray.get(i).name;
            if (s.length() > "Custom".length()) {
                s1 = s.substring(0, 6);
                if (s1.equals("Custom")) {
                    s2 = s.substring(6);
                    int tem;
                    try {
                        tem = Integer.parseInt(s2);
                    } catch (NumberFormatException e) {
                        continue;
                    }
                    temp.add(tem);
                }
            }
        }
    }
    if (temp != null) {
        Collections.sort(temp);
        for (int i = 1; i <= temp.size(); i++) {
            if (temp.get(i - 1) != i) {
                return i;
            }
        }
    }
    return temp.size() + 1;
}
Also used : ArrayList(java.util.ArrayList) Point(android.graphics.Point) SaveOption(com.android.gallery3d.filtershow.data.FilterPresetSource.SaveOption)

Example 3 with SaveOption

use of com.android.gallery3d.filtershow.data.FilterPresetSource.SaveOption in project android_packages_apps_Gallery2 by LineageOS.

the class FilterShowActivity method onMediaPickerResult.

public void onMediaPickerResult(Uri selImg) {
    mFilterPresetSource = new FilterPresetSource(this);
    int id = nameFilter(mFilterPresetSource, tempFilterArray);
    FilterPresetRepresentation fp = new FilterPresetRepresentation(getString(R.string.filtershow_preset_title) + id, id, id);
    fp.setSerializationName("Custom");
    fp.setUri(selImg);
    ImagePreset preset = new ImagePreset();
    preset.addFilter(fp);
    SaveOption sp = new SaveOption();
    sp._id = id;
    sp.name = "Custom" + id;
    sp.Uri = selImg.toString();
    tempFilterArray.add(sp);
    FiltersManager.getManager().addRepresentation(fp);
    mCategoryLooksAdapter.add(new Action(this, fp, Action.FULL_VIEW, true));
    useFilterRepresentation(fp);
    int pos = mCategoryLooksAdapter.getPositionOfPresentation(fp);
    if (pos != -1)
        backAndSetCustomFilterSelected(pos);
}
Also used : FilterPresetSource(com.android.gallery3d.filtershow.data.FilterPresetSource) Action(com.android.gallery3d.filtershow.category.Action) ImagePreset(com.android.gallery3d.filtershow.pipeline.ImagePreset) FilterPresetRepresentation(com.android.gallery3d.filtershow.filters.FilterPresetRepresentation) Point(android.graphics.Point) SaveOption(com.android.gallery3d.filtershow.data.FilterPresetSource.SaveOption)

Example 4 with SaveOption

use of com.android.gallery3d.filtershow.data.FilterPresetSource.SaveOption in project android_packages_apps_Gallery2 by LineageOS.

the class FilterShowActivity method isDuplicateName.

public boolean isDuplicateName(String name) {
    ArrayList<String> nameSum = new ArrayList<String>();
    if (tempFilterArray.size() != 0) {
        for (int i = 0; i < tempFilterArray.size(); i++) nameSum.add(tempFilterArray.get(i).name);
    }
    ArrayList<SaveOption> ret = mFilterPresetSource.getAllUserPresets();
    if (ret != null) {
        for (int id = 0; id < ret.size(); id++) nameSum.add(ret.get(id).name);
    }
    for (int i = 0; i < nameSum.size(); i++) {
        if (name.equals(nameSum.get(i)))
            return true;
    }
    return false;
}
Also used : ArrayList(java.util.ArrayList) Point(android.graphics.Point) SaveOption(com.android.gallery3d.filtershow.data.FilterPresetSource.SaveOption)

Example 5 with SaveOption

use of com.android.gallery3d.filtershow.data.FilterPresetSource.SaveOption in project android_packages_apps_Gallery2 by LineageOS.

the class BaseFiltersManager method addFilterPreset.

public void addFilterPreset(Context context) {
    FilterPresetSource fp = new FilterPresetSource(context);
    ArrayList<SaveOption> ret = fp.getAllUserPresets();
    if (ret == null)
        return;
    for (int id = 0; id < ret.size(); id++) {
        FilterPresetRepresentation representation = new FilterPresetRepresentation(ret.get(id).name, ret.get(id)._id, id + 1);
        Uri filteredUri = Uri.parse(ret.get(id).Uri);
        representation.setUri(filteredUri);
        representation.setSerializationName("Custom");
        mFilterPreset.add(representation);
        ImagePreset preset = new ImagePreset();
        preset.addFilter(representation);
        addRepresentation(representation);
    }
}
Also used : FilterPresetSource(com.android.gallery3d.filtershow.data.FilterPresetSource) ImagePreset(com.android.gallery3d.filtershow.pipeline.ImagePreset) Uri(android.net.Uri) SaveOption(com.android.gallery3d.filtershow.data.FilterPresetSource.SaveOption)

Aggregations

SaveOption (com.android.gallery3d.filtershow.data.FilterPresetSource.SaveOption)5 Point (android.graphics.Point)4 ArrayList (java.util.ArrayList)3 Uri (android.net.Uri)2 Action (com.android.gallery3d.filtershow.category.Action)2 FilterPresetSource (com.android.gallery3d.filtershow.data.FilterPresetSource)2 FilterPresetRepresentation (com.android.gallery3d.filtershow.filters.FilterPresetRepresentation)2 ImagePreset (com.android.gallery3d.filtershow.pipeline.ImagePreset)2 FilterRepresentation (com.android.gallery3d.filtershow.filters.FilterRepresentation)1 FiltersManager (com.android.gallery3d.filtershow.filters.FiltersManager)1