Search in sources :

Example 41 with FilterRepresentation

use of com.android.gallery3d.filtershow.filters.FilterRepresentation in project android_packages_apps_Gallery2 by LineageOS.

the class FilterShowActivity method useFilterRepresentation.

public void useFilterRepresentation(FilterRepresentation filterRepresentation) {
    if (filterRepresentation == null) {
        return;
    }
    if (!(filterRepresentation instanceof FilterRotateRepresentation) && !(filterRepresentation instanceof FilterMirrorRepresentation) && MasterImage.getImage().getCurrentFilterRepresentation() == filterRepresentation) {
        return;
    }
    if (filterRepresentation.getFilterType() == FilterWatermarkRepresentation.TYPE_WATERMARK_CATEGORY) {
        return;
    }
    boolean addToHistory = filterRepresentation.getFilterType() != FilterWatermarkRepresentation.TYPE_WATERMARK;
    if (filterRepresentation instanceof FilterUserPresetRepresentation || filterRepresentation instanceof FilterRotateRepresentation || filterRepresentation instanceof FilterMirrorRepresentation) {
        MasterImage.getImage().onNewLook(filterRepresentation);
    }
    ImagePreset oldPreset = MasterImage.getImage().getPreset();
    ImagePreset copy = new ImagePreset(oldPreset);
    FilterRepresentation representation = copy.getRepresentation(filterRepresentation);
    if (representation == null) {
        filterRepresentation = filterRepresentation.copy();
        copy.addFilter(filterRepresentation);
    } else {
        if (filterRepresentation.allowsSingleInstanceOnly()) {
            // null.
            if (!representation.equals(filterRepresentation)) {
                // Only do this if the filter isn't the same
                // (state panel clicks can lead us here)
                copy.removeFilter(representation);
                copy.addFilter(filterRepresentation);
            }
        }
    }
    MasterImage.getImage().setPreset(copy, filterRepresentation, addToHistory);
    MasterImage.getImage().setCurrentFilterRepresentation(filterRepresentation);
}
Also used : FilterMirrorRepresentation(com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation) ImagePreset(com.android.gallery3d.filtershow.pipeline.ImagePreset) FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation) FilterRotateRepresentation(com.android.gallery3d.filtershow.filters.FilterRotateRepresentation) FilterUserPresetRepresentation(com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation)

Example 42 with FilterRepresentation

use of com.android.gallery3d.filtershow.filters.FilterRepresentation in project android_packages_apps_Gallery2 by LineageOS.

the class FilterShowActivity method fillWaterMarks.

private void fillWaterMarks() {
    FiltersManager filtersManager = FiltersManager.getManager();
    ArrayList<ArrayList<FilterRepresentation>> filters = new ArrayList<>();
    filters.add(filtersManager.getWaterMarks());
    filters.add(filtersManager.getLocations());
    filters.add(filtersManager.getTimes());
    filters.add(filtersManager.getWeathers());
    filters.add(filtersManager.getEmotions());
    filters.add(filtersManager.getFoods());
    if (mCategoryWatermarkAdapters != null) {
        mCategoryWatermarkAdapters.clear();
    }
    mCategoryWatermarkAdapters = new ArrayList<>();
    for (int i = 0; i < filters.size(); i++) {
        mCategoryWatermarkAdapters.add(new CategoryAdapter(this));
        for (FilterRepresentation representation : filters.get(i)) {
            mCategoryWatermarkAdapters.get(i).add(new Action(this, representation));
        }
    }
}
Also used : Action(com.android.gallery3d.filtershow.category.Action) FiltersManager(com.android.gallery3d.filtershow.filters.FiltersManager) CategoryAdapter(com.android.gallery3d.filtershow.category.CategoryAdapter) ArrayList(java.util.ArrayList) FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation) Point(android.graphics.Point)

Example 43 with FilterRepresentation

use of com.android.gallery3d.filtershow.filters.FilterRepresentation in project android_packages_apps_Gallery2 by LineageOS.

the class FilterShowActivity method fillTools.

private void fillTools() {
    FiltersManager filtersManager = FiltersManager.getManager();
    ArrayList<FilterRepresentation> filtersRepresentations = filtersManager.getTools();
    if (mCategoryGeometryAdapter != null) {
        mCategoryGeometryAdapter.clear();
    }
    mCategoryGeometryAdapter = new CategoryAdapter(this);
    for (FilterRepresentation representation : filtersRepresentations) {
        mCategoryGeometryAdapter.add(new Action(this, representation));
    }
}
Also used : Action(com.android.gallery3d.filtershow.category.Action) FiltersManager(com.android.gallery3d.filtershow.filters.FiltersManager) CategoryAdapter(com.android.gallery3d.filtershow.category.CategoryAdapter) FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation)

Example 44 with FilterRepresentation

use of com.android.gallery3d.filtershow.filters.FilterRepresentation in project android_packages_apps_Gallery2 by LineageOS.

the class FilterShowActivity method removeFilterRepresentation.

public void removeFilterRepresentation(FilterRepresentation filterRepresentation) {
    if (filterRepresentation == null) {
        return;
    }
    ImagePreset oldPreset = MasterImage.getImage().getPreset();
    ImagePreset copy = new ImagePreset(oldPreset);
    copy.removeFilter(filterRepresentation);
    MasterImage.getImage().setPreset(copy, copy.getLastRepresentation(), true);
    if (MasterImage.getImage().getCurrentFilterRepresentation() == filterRepresentation) {
        FilterRepresentation lastRepresentation = copy.getLastRepresentation();
        MasterImage.getImage().setCurrentFilterRepresentation(lastRepresentation);
    }
}
Also used : ImagePreset(com.android.gallery3d.filtershow.pipeline.ImagePreset) FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation)

Example 45 with FilterRepresentation

use of com.android.gallery3d.filtershow.filters.FilterRepresentation in project android_packages_apps_Gallery2 by LineageOS.

the class FilterShowActivity method fillHazeBuster.

private void fillHazeBuster() {
    FiltersManager filtersManager = FiltersManager.getManager();
    ArrayList<FilterRepresentation> hazeBusterRepresentations = filtersManager.getHazeBuster();
    if (mCategoryHazeBusterAdapter != null) {
        mCategoryHazeBusterAdapter.clear();
    }
    mCategoryHazeBusterAdapter = new CategoryAdapter(this);
    for (FilterRepresentation representation : hazeBusterRepresentations) {
        if (representation.getTextId() != 0) {
            representation.setName(getString(representation.getTextId()));
        }
        mCategoryHazeBusterAdapter.add(new Action(this, representation));
    }
}
Also used : Action(com.android.gallery3d.filtershow.category.Action) FiltersManager(com.android.gallery3d.filtershow.filters.FiltersManager) CategoryAdapter(com.android.gallery3d.filtershow.category.CategoryAdapter) FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation)

Aggregations

FilterRepresentation (com.android.gallery3d.filtershow.filters.FilterRepresentation)78 Action (com.android.gallery3d.filtershow.category.Action)12 FiltersManager (com.android.gallery3d.filtershow.filters.FiltersManager)12 CategoryAdapter (com.android.gallery3d.filtershow.category.CategoryAdapter)11 Point (android.graphics.Point)8 ImagePreset (com.android.gallery3d.filtershow.pipeline.ImagePreset)8 Bitmap (android.graphics.Bitmap)7 FilterUserPresetRepresentation (com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation)6 FilterShowActivity (com.android.gallery3d.filtershow.FilterShowActivity)5 FilterDualCamFusionRepresentation (com.android.gallery3d.filtershow.filters.FilterDualCamFusionRepresentation)5 FilterMirrorRepresentation (com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation)5 MasterImage (com.android.gallery3d.filtershow.imageshow.MasterImage)5 FilterGradRepresentation (com.android.gallery3d.filtershow.filters.FilterGradRepresentation)4 FilterRotateRepresentation (com.android.gallery3d.filtershow.filters.FilterRotateRepresentation)4 ArrayList (java.util.ArrayList)4 Uri (android.net.Uri)3 LayoutInflater (android.view.LayoutInflater)3 View (android.view.View)3 OnClickListener (android.view.View.OnClickListener)3 FilterCropRepresentation (com.android.gallery3d.filtershow.filters.FilterCropRepresentation)3