use of com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation in project android_packages_apps_Gallery2 by LineageOS.
the class ImagePreset method fillImageStateAdapter.
public void fillImageStateAdapter(StateAdapter imageStateAdapter) {
if (imageStateAdapter == null) {
return;
}
Vector<State> states = new Vector<State>();
for (FilterRepresentation filter : mFilters) {
if (filter instanceof FilterUserPresetRepresentation) {
// do not show the user preset itself in the state panel
continue;
}
State state = new State(filter.getName());
state.setFilterRepresentation(filter);
states.add(state);
}
imageStateAdapter.fill(states);
}
use of com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation in project android_packages_apps_Gallery2 by LineageOS.
the class UserPresetsAdapter method changePreset.
private void changePreset(Action action) {
FilterRepresentation rep = action.getRepresentation();
rep.setName(action.getName());
if (rep instanceof FilterUserPresetRepresentation) {
mChangedRepresentations.add((FilterUserPresetRepresentation) rep);
}
}
use of com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation in project android_packages_apps_Gallery2 by LineageOS.
the class FilterEnvironment method applyRepresentation.
public Bitmap applyRepresentation(FilterRepresentation representation, Bitmap bitmap) {
if (representation instanceof FilterUserPresetRepresentation) {
// applied directly they do not themselves need to do any kind of filtering.
return bitmap;
}
ImageFilter filter = mFiltersManager.getFilterForRepresentation(representation);
if (filter == null) {
Log.e(LOGTAG, "No ImageFilter for " + representation.getSerializationName());
return bitmap;
}
filter.useRepresentation(representation);
filter.setEnvironment(this);
Bitmap ret = filter.apply(bitmap, mScaleFactor, mQuality);
if (bitmap != ret) {
cache(bitmap);
}
filter.setGeneralParameters();
filter.setEnvironment(null);
return ret;
}
use of com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation 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);
}
use of com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation in project android_packages_apps_Gallery2 by LineageOS.
the class FilterShowActivity method updateUserPresetsFromManager.
public void updateUserPresetsFromManager() {
ArrayList<FilterUserPresetRepresentation> presets = mUserPresetsManager.getRepresentations();
if (presets == null) {
return;
}
if (mCategoryLooksAdapter != null) {
fillLooks();
}
/* if (presets.size() > 0) {
mCategoryLooksAdapter.add(new Action(this, Action.SPACER));
} */
mUserPresetsAdapter.clear();
if (presets.size() > 0) {
mCategoryLooksAdapter.add(new Action(this, Action.ADD_ACTION));
}
for (int i = 0; i < presets.size(); i++) {
FilterUserPresetRepresentation representation = presets.get(i);
mCategoryLooksAdapter.add(new Action(this, representation, Action.FULL_VIEW, true));
mUserPresetsAdapter.add(new Action(this, representation, Action.FULL_VIEW));
}
mCategoryLooksAdapter.notifyDataSetChanged();
mCategoryLooksAdapter.notifyDataSetInvalidated();
}
Aggregations