diff options
author | nicolasroard <nicolasroard@google.com> | 2013-02-05 17:09:05 -0800 |
---|---|---|
committer | nicolasroard <nicolasroard@google.com> | 2013-02-06 12:52:34 -0800 |
commit | 082803ec883c8182485872bbc34b63705b04d101 (patch) | |
tree | 60d8746608089445ba162625439f1d5df281b4c6 /src/com/android/gallery3d/filtershow/editors | |
parent | 083074c72999425c7e8a54ecafc965ae17dcbea8 (diff) | |
download | android_packages_apps_Snap-082803ec883c8182485872bbc34b63705b04d101.tar.gz android_packages_apps_Snap-082803ec883c8182485872bbc34b63705b04d101.tar.bz2 android_packages_apps_Snap-082803ec883c8182485872bbc34b63705b04d101.zip |
Refactor to use direct manipulations of FilterRepresentations.
Change-Id: If5f92f137283cb126835be004d315942ff95021c
Diffstat (limited to 'src/com/android/gallery3d/filtershow/editors')
-rw-r--r-- | src/com/android/gallery3d/filtershow/editors/BasicEditor.java | 21 | ||||
-rw-r--r-- | src/com/android/gallery3d/filtershow/editors/Editor.java | 20 |
2 files changed, 29 insertions, 12 deletions
diff --git a/src/com/android/gallery3d/filtershow/editors/BasicEditor.java b/src/com/android/gallery3d/filtershow/editors/BasicEditor.java index fa3bd4a4a..b7f5d7d26 100644 --- a/src/com/android/gallery3d/filtershow/editors/BasicEditor.java +++ b/src/com/android/gallery3d/filtershow/editors/BasicEditor.java @@ -20,12 +20,12 @@ import com.android.gallery3d.R; import com.android.gallery3d.filtershow.filters.*; import android.content.Context; -import android.util.Log; import android.view.View; import android.widget.FrameLayout; import android.widget.SeekBar; import android.widget.SeekBar.OnSeekBarChangeListener; import com.android.gallery3d.filtershow.imageshow.MasterImage; +import com.android.gallery3d.filtershow.presets.ImagePreset; /** * The basic editor that all the one parameter filters @@ -47,8 +47,8 @@ public class BasicEditor extends Editor implements OnSeekBarChangeListener { protected BasicEditor(int id, int layoutID, int viewID) { super(id); - int mLayoutID = layoutID; - int mViewID = viewID; + mLayoutID = layoutID; + mViewID = viewID; } @Override @@ -61,9 +61,9 @@ public class BasicEditor extends Editor implements OnSeekBarChangeListener { @Override public void reflectCurrentFilter() { - FilterRepresentation filterRepresentation = MasterImage.getImage().getCurrentFilterRepresentation(); - if (filterRepresentation != null && filterRepresentation instanceof FilterBasicRepresentation) { - FilterBasicRepresentation interval = (FilterBasicRepresentation) filterRepresentation; + super.reflectCurrentFilter(); + if (getLocalRepresentation() != null && getLocalRepresentation() instanceof FilterBasicRepresentation) { + FilterBasicRepresentation interval = (FilterBasicRepresentation) getLocalRepresentation(); boolean f = interval.showParameterValue(); mSeekBar.setVisibility((f) ? View.VISIBLE : View.INVISIBLE); int value = interval.getValue(); @@ -76,9 +76,8 @@ public class BasicEditor extends Editor implements OnSeekBarChangeListener { @Override public void onProgressChanged(SeekBar sbar, int progress, boolean arg2) { - FilterRepresentation filterRepresentation = MasterImage.getImage().getCurrentFilterRepresentation(); - if (filterRepresentation != null && filterRepresentation instanceof FilterBasicRepresentation) { - FilterBasicRepresentation interval = (FilterBasicRepresentation) filterRepresentation; + if (getLocalRepresentation() != null && getLocalRepresentation() instanceof FilterBasicRepresentation) { + FilterBasicRepresentation interval = (FilterBasicRepresentation) getLocalRepresentation(); int value = progress + interval.getMinimum(); interval.setValue(value); mImageShow.onNewValue(value); @@ -86,9 +85,7 @@ public class BasicEditor extends Editor implements OnSeekBarChangeListener { if (interval.showParameterValue()) { mPanelController.onNewValue(value); } - - Log.v(LOGTAG, " #### progress=" + value); - MasterImage.getImage().updateBuffers(); + commitLocalRepresentation(); } } diff --git a/src/com/android/gallery3d/filtershow/editors/Editor.java b/src/com/android/gallery3d/filtershow/editors/Editor.java index a9b2fd425..bea591c63 100644 --- a/src/com/android/gallery3d/filtershow/editors/Editor.java +++ b/src/com/android/gallery3d/filtershow/editors/Editor.java @@ -25,7 +25,10 @@ import android.widget.LinearLayout; import com.android.gallery3d.filtershow.PanelController; import com.android.gallery3d.filtershow.cache.ImageLoader; +import com.android.gallery3d.filtershow.filters.FilterRepresentation; import com.android.gallery3d.filtershow.imageshow.ImageShow; +import com.android.gallery3d.filtershow.imageshow.MasterImage; +import com.android.gallery3d.filtershow.presets.ImagePreset; /** * Base class for Editors Must contain a mImageShow and a top level view @@ -38,6 +41,7 @@ public class Editor { protected PanelController mPanelController; protected int mID; private final String LOGTAG = "Editor"; + protected FilterRepresentation mLocalRepresentation = null; public void setPanelController(PanelController panelController) { this.mPanelController = panelController; @@ -53,6 +57,7 @@ public class Editor { public void createEditor(Context context,FrameLayout frameLayout) { mContext = context; mFrameLayout = frameLayout; + mLocalRepresentation = null; } protected void unpack(int viewid, int layoutid) { @@ -105,10 +110,25 @@ public class Editor { mView.setVisibility(visible); } + public FilterRepresentation getLocalRepresentation() { + if (mLocalRepresentation == null) { + ImagePreset preset = MasterImage.getImage().getPreset(); + FilterRepresentation filterRepresentation = MasterImage.getImage().getCurrentFilterRepresentation(); + mLocalRepresentation = preset.getFilterRepresentationCopyFrom(filterRepresentation); + } + return mLocalRepresentation; + } + + public void commitLocalRepresentation() { + ImagePreset preset = MasterImage.getImage().getPreset(); + preset.updateFilterRepresentation(getLocalRepresentation()); + } + /** * called after the filter is set and the select is called */ public void reflectCurrentFilter() { + mLocalRepresentation = null; } public boolean useUtilityPanel() { |