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));
}
}
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;
}
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);
}
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;
}
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);
}
}
Aggregations