From 13ae2608e04998f0d13bc3f58cda5237bdde0b7d Mon Sep 17 00:00:00 2001 From: nicolasroard Date: Mon, 15 Jul 2013 11:24:36 -0700 Subject: Add user presets saving/loading Change-Id: I85c5dd0df1e9264a01c8d7a6d44602e87799890c --- src/com/android/gallery3d/filtershow/category/Action.java | 7 +++++-- .../android/gallery3d/filtershow/category/CategoryAdapter.java | 3 +++ src/com/android/gallery3d/filtershow/category/CategoryTrack.java | 9 +++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) (limited to 'src/com/android/gallery3d/filtershow/category') diff --git a/src/com/android/gallery3d/filtershow/category/Action.java b/src/com/android/gallery3d/filtershow/category/Action.java index de282cc28..332ca18b0 100644 --- a/src/com/android/gallery3d/filtershow/category/Action.java +++ b/src/com/android/gallery3d/filtershow/category/Action.java @@ -24,6 +24,9 @@ import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.Rect; import android.graphics.RectF; +import android.widget.ArrayAdapter; +import android.widget.ListAdapter; +import com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation; import com.android.gallery3d.filtershow.pipeline.RenderingRequest; import com.android.gallery3d.filtershow.pipeline.RenderingRequestCaller; import com.android.gallery3d.filtershow.filters.FilterRepresentation; @@ -37,7 +40,7 @@ public class Action implements RenderingRequestCaller { private String mName; private Rect mImageFrame; private Bitmap mImage; - private CategoryAdapter mAdapter; + private ArrayAdapter mAdapter; public static final int FULL_VIEW = 0; public static final int CROP_VIEW = 1; private int mType = CROP_VIEW; @@ -100,7 +103,7 @@ public class Action implements RenderingRequestCaller { mImage = image; } - public void setAdapter(CategoryAdapter adapter) { + public void setAdapter(ArrayAdapter adapter) { mAdapter = adapter; } diff --git a/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java b/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java index 445ef5f6a..6451c39df 100644 --- a/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java +++ b/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java @@ -149,6 +149,9 @@ public class CategoryAdapter extends ArrayAdapter { } public void reflectImagePreset(ImagePreset preset) { + if (preset == null) { + return; + } int selected = 0; // if nothing found, select "none" (first element) FilterRepresentation rep = null; if (mCategory == MainPanel.LOOKS) { diff --git a/src/com/android/gallery3d/filtershow/category/CategoryTrack.java b/src/com/android/gallery3d/filtershow/category/CategoryTrack.java index f55431293..ac8245a3b 100644 --- a/src/com/android/gallery3d/filtershow/category/CategoryTrack.java +++ b/src/com/android/gallery3d/filtershow/category/CategoryTrack.java @@ -35,6 +35,11 @@ public class CategoryTrack extends LinearLayout { super.onChanged(); invalidate(); } + @Override + public void onInvalidated() { + super.onInvalidated(); + fillContent(); + } }; public CategoryTrack(Context context, AttributeSet attrs) { @@ -45,14 +50,14 @@ public class CategoryTrack extends LinearLayout { public void setAdapter(CategoryAdapter adapter) { mAdapter = adapter; - mAdapter.setItemWidth(mElemSize); - mAdapter.setItemHeight(LayoutParams.MATCH_PARENT); mAdapter.registerDataSetObserver(mDataSetObserver); fillContent(); } public void fillContent() { removeAllViews(); + mAdapter.setItemWidth(mElemSize); + mAdapter.setItemHeight(LayoutParams.MATCH_PARENT); int n = mAdapter.getCount(); for (int i = 0; i < n; i++) { View view = mAdapter.getView(i, null, this); -- cgit v1.2.3