summaryrefslogtreecommitdiffstats
path: root/src_pd/com
diff options
context:
space:
mode:
authornicolasroard <nicolasroard@google.com>2013-01-28 16:36:46 -0800
committernicolasroard <nicolasroard@google.com>2013-02-05 00:03:18 -0800
commitda4de5aa86b49be455efe396455b77be44dec684 (patch)
tree4d35214fecb7af9f2f09cd44b4910cf793d2af6d /src_pd/com
parent465e25bd3cb2c76732102d7be98bc0335962f715 (diff)
downloadandroid_packages_apps_Snap-da4de5aa86b49be455efe396455b77be44dec684.zip
android_packages_apps_Snap-da4de5aa86b49be455efe396455b77be44dec684.tar.gz
android_packages_apps_Snap-da4de5aa86b49be455efe396455b77be44dec684.tar.bz2
Refactor filters parameters
- introduce FilterRepresentations - change filters lifecycle Change-Id: I9416fca47a334d532a347cd5577795738c870933
Diffstat (limited to 'src_pd/com')
-rw-r--r--src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java41
1 files changed, 38 insertions, 3 deletions
diff --git a/src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java b/src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java
index 915041b..3b3326c 100644
--- a/src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java
+++ b/src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java
@@ -16,17 +16,45 @@
package com.android.gallery3d.filtershow.filters;
-import android.util.Log;
-
import com.android.gallery3d.filtershow.cache.ImageLoader;
+import java.util.HashMap;
import java.util.Vector;
public class FiltersManager {
private static final String LOGTAG = "FiltersManager";
+ private static FiltersManager gInstance = null;
+ private static HashMap<Class, ImageFilter> mFilters = new HashMap<Class, ImageFilter>();
- public static void addFilters(Vector<ImageFilter> filters, ImageLoader imageLoader) {
+ private FiltersManager() {
+ Vector<ImageFilter> filters = new Vector<ImageFilter>();
+ FiltersManager.addFilters(filters);
+ for (ImageFilter filter : filters) {
+ mFilters.put(filter.getClass(), filter);
+ }
+ }
+
+ public ImageFilter getFilter(Class c) {
+ return mFilters.get(c);
+ }
+
+ public ImageFilter getFilterForRepresentation(FilterRepresentation representation) {
+ return mFilters.get(representation.getFilterClass());
+ }
+
+ public void addFilter(Class filterClass, ImageFilter filter) {
+ mFilters.put(filterClass, filter);
+ }
+
+ public static FiltersManager getManager() {
+ if (gInstance == null) {
+ gInstance = new FiltersManager();
+ }
+ return gInstance;
+ }
+
+ public static void addFilters(Vector<ImageFilter> filters) {
filters.add(new ImageFilterTinyPlanet());
filters.add(new ImageFilterWBalance());
filters.add(new ImageFilterExposure());
@@ -43,6 +71,13 @@ public class FiltersManager {
filters.add(new ImageFilterNegative());
filters.add(new ImageFilterEdge());
filters.add(new ImageFilterKMeans());
+ }
+
+ public static void addFilters(Vector<ImageFilter> filters, ImageLoader imageLoader) {
+ FiltersManager.addFilters(filters);
filters.add(new ImageFilterDownsample(imageLoader));
+ FiltersManager.getManager().addFilter(ImageFilterDownsample.class,
+ new ImageFilterDownsample(imageLoader));
}
+
}