use of com.android.gallery3d.filtershow.pipeline.ImagePreset 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.pipeline.ImagePreset 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);
}
}
use of com.android.gallery3d.filtershow.pipeline.ImagePreset 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);
}
use of com.android.gallery3d.filtershow.pipeline.ImagePreset in project android_packages_apps_Gallery2 by LineageOS.
the class FilterShowActivity method updateCategories.
public void updateCategories() {
if (mMasterImage == null) {
return;
}
ImagePreset preset = mMasterImage.getPreset();
mCategoryLooksAdapter.reflectImagePreset(preset);
mCategoryBordersAdapter.reflectImagePreset(preset);
mCategoryFiltersAdapter.reflectImagePreset(preset);
if (mCategoryMakeupAdapter != null) {
mCategoryMakeupAdapter.reflectImagePreset(preset);
}
mCategoryDualCamAdapter.reflectImagePreset(preset);
mCategoryTruePortraitAdapter.reflectImagePreset(preset);
}
use of com.android.gallery3d.filtershow.pipeline.ImagePreset in project android_packages_apps_Gallery2 by LineageOS.
the class FilterShowActivity method resetHistory.
void resetHistory() {
if (mMasterImage == null) {
return;
}
HistoryManager adapter = mMasterImage.getHistory();
adapter.reset();
HistoryItem historyItem = adapter.getItem(0);
ImagePreset original = null;
original = new ImagePreset();
FilterRepresentation rep = null;
if (historyItem != null) {
rep = historyItem.getFilterRepresentation();
}
mMasterImage.setPreset(original, rep, true);
mMasterImage.setFusionUnderlay(null);
mMasterImage.resetTranslation();
mMasterImage.setScaleFactor(1);
mMasterImage.setCurrentFilterRepresentation(null);
ArrayList<FilterRepresentation> frList = FiltersManager.getManager().getTools();
for (FilterRepresentation fr : frList) {
if (fr instanceof FilterRotateRepresentation) {
((FilterRotateRepresentation) fr).resetRotation();
}
}
showDefaultImageView();
showSaveButtonIfNeed();
invalidateViews();
}
Aggregations