Loading src/com/android/gallery3d/filtershow/FilterShowActivity.java +9 −8 Original line number Diff line number Diff line Loading @@ -427,7 +427,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL ImagePreset oldPreset = MasterImage.getImage().getPreset(); ImagePreset copy = new ImagePreset(oldPreset); copy.removeFilter(filterRepresentation); MasterImage.getImage().setPreset(copy, true); MasterImage.getImage().setPreset(copy, copy.getLastRepresentation(), true); if (MasterImage.getImage().getCurrentFilterRepresentation() == filterRepresentation) { FilterRepresentation lastRepresentation = copy.getLastRepresentation(); MasterImage.getImage().setCurrentFilterRepresentation(lastRepresentation); Loading @@ -449,12 +449,11 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL } else { if (filterRepresentation.allowsSingleInstanceOnly()) { representation.updateTempParametersFrom(filterRepresentation); copy.setHistoryName(filterRepresentation.getName()); representation.synchronizeRepresentation(); } filterRepresentation = representation; } MasterImage.getImage().setPreset(copy, true); MasterImage.getImage().setPreset(copy, filterRepresentation, true); MasterImage.getImage().setCurrentFilterRepresentation(filterRepresentation); } Loading Loading @@ -558,7 +557,8 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL mLoadBitmapTask = null; if (mOriginalPreset != null) { MasterImage.getImage().setPreset(mOriginalPreset, true); MasterImage.getImage().setPreset(mOriginalPreset, mOriginalPreset.getLastRepresentation(), true); mOriginalPreset = null; } Loading Loading @@ -822,10 +822,10 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL public void setDefaultPreset() { // Default preset (original) ImagePreset preset = new ImagePreset(getString(R.string.history_original)); // empty ImagePreset preset = new ImagePreset(); // empty preset.setImageLoader(mImageLoader); mMasterImage.setPreset(preset, true); mMasterImage.setPreset(preset, preset.getLastRepresentation(), true); } // ////////////////////////////////////////////////////////////////////////////// Loading Loading @@ -905,8 +905,9 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL void resetHistory() { HistoryAdapter adapter = mMasterImage.getHistory(); adapter.reset(); ImagePreset original = new ImagePreset(adapter.getItem(0)); mMasterImage.setPreset(original, true); HistoryItem historyItem = adapter.getItem(0); ImagePreset original = new ImagePreset(historyItem.getImagePreset()); mMasterImage.setPreset(original, historyItem.getFilterRepresentation(), true); invalidateViews(); backToMain(); } Loading src/com/android/gallery3d/filtershow/HistoryAdapter.java +12 −11 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ import com.android.gallery3d.filtershow.presets.ImagePreset; import java.util.Vector; public class HistoryAdapter extends ArrayAdapter<ImagePreset> { public class HistoryAdapter extends ArrayAdapter<HistoryItem> { private static final String LOGTAG = "HistoryAdapter"; private int mCurrentPresetPosition = 0; private String mBorders = null; Loading Loading @@ -115,33 +115,33 @@ public class HistoryAdapter extends ArrayAdapter<ImagePreset> { if (getCount() == 0) { return; } ImagePreset first = getItem(getCount() - 1); HistoryItem first = getItem(getCount() - 1); clear(); addHistoryItem(first); updateMenuItems(); } public ImagePreset getLast() { public HistoryItem getLast() { if (getCount() == 0) { return null; } return getItem(0); } public ImagePreset getCurrent() { public HistoryItem getCurrent() { return getItem(mCurrentPresetPosition); } public void addHistoryItem(ImagePreset preset) { public void addHistoryItem(HistoryItem preset) { insert(preset, 0); updateMenuItems(); } @Override public void insert(ImagePreset preset, int position) { public void insert(HistoryItem preset, int position) { if (mCurrentPresetPosition != 0) { // in this case, let's discount the presets before the current one Vector<ImagePreset> oldItems = new Vector<ImagePreset>(); Vector<HistoryItem> oldItems = new Vector<HistoryItem>(); for (int i = mCurrentPresetPosition; i < getCount(); i++) { oldItems.add(getItem(i)); } Loading Loading @@ -186,14 +186,15 @@ public class HistoryAdapter extends ArrayAdapter<ImagePreset> { view = inflater.inflate(R.layout.filtershow_history_operation_row, null); } ImagePreset item = getItem(position); HistoryItem historyItem = getItem(position); ImagePreset item = historyItem.getImagePreset(); if (item != null) { TextView itemView = (TextView) view.findViewById(R.id.rowTextView); if (itemView != null) { itemView.setText(item.historyName()); if (itemView != null && historyItem.getFilterRepresentation() != null) { itemView.setText(historyItem.getFilterRepresentation().getName()); } ImageView preview = (ImageView) view.findViewById(R.id.preview); Bitmap bmp = item.getPreviewImage(); Bitmap bmp = historyItem.getPreviewImage(); if (position == getCount()-1 && mOriginalBitmap != null) { bmp = mOriginalBitmap; } Loading src/com/android/gallery3d/filtershow/HistoryItem.java 0 → 100644 +57 −0 Original line number Diff line number Diff line /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.gallery3d.filtershow; import android.graphics.Bitmap; import android.util.Log; import com.android.gallery3d.filtershow.filters.FilterRepresentation; import com.android.gallery3d.filtershow.presets.ImagePreset; public class HistoryItem { private static final String LOGTAG = "HistoryItem"; private ImagePreset mImagePreset; private FilterRepresentation mFilterRepresentation; private Bitmap mPreviewImage; public HistoryItem(ImagePreset preset, FilterRepresentation representation) { mImagePreset = new ImagePreset(preset); try { if (representation != null) { mFilterRepresentation = representation.clone(); } } catch (CloneNotSupportedException e) { Log.e(LOGTAG, "clone not supported", e); } } public ImagePreset getImagePreset() { return mImagePreset; } public FilterRepresentation getFilterRepresentation() { return mFilterRepresentation; } public Bitmap getPreviewImage() { return mPreviewImage; } public void setPreviewImage(Bitmap previewImage) { mPreviewImage = previewImage; } } src/com/android/gallery3d/filtershow/cache/CachingPipeline.java +0 −2 Original line number Diff line number Diff line Loading @@ -287,8 +287,6 @@ public class CachingPipeline implements PipelineInterface { if (request.getType() == RenderingRequest.ICON_RENDERING) { mEnvironment.setQuality(FilterEnvironment.QUALITY_ICON); } else if (request.getType() == RenderingRequest.STYLE_ICON_RENDERING) { mEnvironment.setQuality(ImagePreset.STYLE_ICON); } else { mEnvironment.setQuality(FilterEnvironment.QUALITY_PREVIEW); } Loading src/com/android/gallery3d/filtershow/category/CategoryAdapter.java +2 −12 Original line number Diff line number Diff line Loading @@ -67,19 +67,9 @@ public class CategoryAdapter extends ArrayAdapter<Action> { public void initializeSelection(int category) { mCategory = category; if (category == MainPanel.LOOKS || category == MainPanel.BORDERS) { ImagePreset preset = MasterImage.getImage().getPreset(); if (preset != null) { for (int i = 0; i < getCount(); i++) { if (preset.historyName().equals(getItem(i).getRepresentation().getName())) { mSelectedPosition = i; } } } } else { // TODO: fix this mSelectedPosition = -1; } } @Override public View getView(int position, View convertView, ViewGroup parent) { Loading Loading
src/com/android/gallery3d/filtershow/FilterShowActivity.java +9 −8 Original line number Diff line number Diff line Loading @@ -427,7 +427,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL ImagePreset oldPreset = MasterImage.getImage().getPreset(); ImagePreset copy = new ImagePreset(oldPreset); copy.removeFilter(filterRepresentation); MasterImage.getImage().setPreset(copy, true); MasterImage.getImage().setPreset(copy, copy.getLastRepresentation(), true); if (MasterImage.getImage().getCurrentFilterRepresentation() == filterRepresentation) { FilterRepresentation lastRepresentation = copy.getLastRepresentation(); MasterImage.getImage().setCurrentFilterRepresentation(lastRepresentation); Loading @@ -449,12 +449,11 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL } else { if (filterRepresentation.allowsSingleInstanceOnly()) { representation.updateTempParametersFrom(filterRepresentation); copy.setHistoryName(filterRepresentation.getName()); representation.synchronizeRepresentation(); } filterRepresentation = representation; } MasterImage.getImage().setPreset(copy, true); MasterImage.getImage().setPreset(copy, filterRepresentation, true); MasterImage.getImage().setCurrentFilterRepresentation(filterRepresentation); } Loading Loading @@ -558,7 +557,8 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL mLoadBitmapTask = null; if (mOriginalPreset != null) { MasterImage.getImage().setPreset(mOriginalPreset, true); MasterImage.getImage().setPreset(mOriginalPreset, mOriginalPreset.getLastRepresentation(), true); mOriginalPreset = null; } Loading Loading @@ -822,10 +822,10 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL public void setDefaultPreset() { // Default preset (original) ImagePreset preset = new ImagePreset(getString(R.string.history_original)); // empty ImagePreset preset = new ImagePreset(); // empty preset.setImageLoader(mImageLoader); mMasterImage.setPreset(preset, true); mMasterImage.setPreset(preset, preset.getLastRepresentation(), true); } // ////////////////////////////////////////////////////////////////////////////// Loading Loading @@ -905,8 +905,9 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL void resetHistory() { HistoryAdapter adapter = mMasterImage.getHistory(); adapter.reset(); ImagePreset original = new ImagePreset(adapter.getItem(0)); mMasterImage.setPreset(original, true); HistoryItem historyItem = adapter.getItem(0); ImagePreset original = new ImagePreset(historyItem.getImagePreset()); mMasterImage.setPreset(original, historyItem.getFilterRepresentation(), true); invalidateViews(); backToMain(); } Loading
src/com/android/gallery3d/filtershow/HistoryAdapter.java +12 −11 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ import com.android.gallery3d.filtershow.presets.ImagePreset; import java.util.Vector; public class HistoryAdapter extends ArrayAdapter<ImagePreset> { public class HistoryAdapter extends ArrayAdapter<HistoryItem> { private static final String LOGTAG = "HistoryAdapter"; private int mCurrentPresetPosition = 0; private String mBorders = null; Loading Loading @@ -115,33 +115,33 @@ public class HistoryAdapter extends ArrayAdapter<ImagePreset> { if (getCount() == 0) { return; } ImagePreset first = getItem(getCount() - 1); HistoryItem first = getItem(getCount() - 1); clear(); addHistoryItem(first); updateMenuItems(); } public ImagePreset getLast() { public HistoryItem getLast() { if (getCount() == 0) { return null; } return getItem(0); } public ImagePreset getCurrent() { public HistoryItem getCurrent() { return getItem(mCurrentPresetPosition); } public void addHistoryItem(ImagePreset preset) { public void addHistoryItem(HistoryItem preset) { insert(preset, 0); updateMenuItems(); } @Override public void insert(ImagePreset preset, int position) { public void insert(HistoryItem preset, int position) { if (mCurrentPresetPosition != 0) { // in this case, let's discount the presets before the current one Vector<ImagePreset> oldItems = new Vector<ImagePreset>(); Vector<HistoryItem> oldItems = new Vector<HistoryItem>(); for (int i = mCurrentPresetPosition; i < getCount(); i++) { oldItems.add(getItem(i)); } Loading Loading @@ -186,14 +186,15 @@ public class HistoryAdapter extends ArrayAdapter<ImagePreset> { view = inflater.inflate(R.layout.filtershow_history_operation_row, null); } ImagePreset item = getItem(position); HistoryItem historyItem = getItem(position); ImagePreset item = historyItem.getImagePreset(); if (item != null) { TextView itemView = (TextView) view.findViewById(R.id.rowTextView); if (itemView != null) { itemView.setText(item.historyName()); if (itemView != null && historyItem.getFilterRepresentation() != null) { itemView.setText(historyItem.getFilterRepresentation().getName()); } ImageView preview = (ImageView) view.findViewById(R.id.preview); Bitmap bmp = item.getPreviewImage(); Bitmap bmp = historyItem.getPreviewImage(); if (position == getCount()-1 && mOriginalBitmap != null) { bmp = mOriginalBitmap; } Loading
src/com/android/gallery3d/filtershow/HistoryItem.java 0 → 100644 +57 −0 Original line number Diff line number Diff line /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.gallery3d.filtershow; import android.graphics.Bitmap; import android.util.Log; import com.android.gallery3d.filtershow.filters.FilterRepresentation; import com.android.gallery3d.filtershow.presets.ImagePreset; public class HistoryItem { private static final String LOGTAG = "HistoryItem"; private ImagePreset mImagePreset; private FilterRepresentation mFilterRepresentation; private Bitmap mPreviewImage; public HistoryItem(ImagePreset preset, FilterRepresentation representation) { mImagePreset = new ImagePreset(preset); try { if (representation != null) { mFilterRepresentation = representation.clone(); } } catch (CloneNotSupportedException e) { Log.e(LOGTAG, "clone not supported", e); } } public ImagePreset getImagePreset() { return mImagePreset; } public FilterRepresentation getFilterRepresentation() { return mFilterRepresentation; } public Bitmap getPreviewImage() { return mPreviewImage; } public void setPreviewImage(Bitmap previewImage) { mPreviewImage = previewImage; } }
src/com/android/gallery3d/filtershow/cache/CachingPipeline.java +0 −2 Original line number Diff line number Diff line Loading @@ -287,8 +287,6 @@ public class CachingPipeline implements PipelineInterface { if (request.getType() == RenderingRequest.ICON_RENDERING) { mEnvironment.setQuality(FilterEnvironment.QUALITY_ICON); } else if (request.getType() == RenderingRequest.STYLE_ICON_RENDERING) { mEnvironment.setQuality(ImagePreset.STYLE_ICON); } else { mEnvironment.setQuality(FilterEnvironment.QUALITY_PREVIEW); } Loading
src/com/android/gallery3d/filtershow/category/CategoryAdapter.java +2 −12 Original line number Diff line number Diff line Loading @@ -67,19 +67,9 @@ public class CategoryAdapter extends ArrayAdapter<Action> { public void initializeSelection(int category) { mCategory = category; if (category == MainPanel.LOOKS || category == MainPanel.BORDERS) { ImagePreset preset = MasterImage.getImage().getPreset(); if (preset != null) { for (int i = 0; i < getCount(); i++) { if (preset.historyName().equals(getItem(i).getRepresentation().getName())) { mSelectedPosition = i; } } } } else { // TODO: fix this mSelectedPosition = -1; } } @Override public View getView(int position, View convertView, ViewGroup parent) { Loading