representation.setName(getString(representation.getTextId()));
}
String text = representation.getName();
- icon.setup(text, this, panel);
+ icon.setup(text, mPanelController, panel);
icon.setFilterRepresentation(representation);
if (representation instanceof FilterTinyPlanetRepresentation) {
// needed to hide tinyplanet on startup
r.getDisplayMetrics());
}
- public void useFilterRepresentation(FilterRepresentation filterRepresentation) {
- if (filterRepresentation == null) {
- return;
- }
- if (mMasterImage.getCurrentFilterRepresentation() == filterRepresentation) {
- return;
- }
- ImagePreset oldPreset = mMasterImage.getPreset();
- ImagePreset copy = new ImagePreset(oldPreset);
- FilterRepresentation representation = copy.getRepresentation(filterRepresentation);
- if (representation == null) {
- copy.addFilter(filterRepresentation);
- } else {
- if (filterRepresentation.allowsMultipleInstances()) {
- representation.useParametersFrom(filterRepresentation);
- copy.setHistoryName(filterRepresentation.getName());
- }
- filterRepresentation = representation;
- }
- mMasterImage.setPreset(copy, true);
- mMasterImage.setCurrentFilterRepresentation(filterRepresentation);
- invalidateViews();
- }
-
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
*/
}
+ public void useFilterRepresentation(FilterRepresentation filterRepresentation) {
+ if (filterRepresentation == null) {
+ return;
+ }
+ if (MasterImage.getImage().getCurrentFilterRepresentation() == filterRepresentation) {
+ return;
+ }
+ ImagePreset oldPreset = MasterImage.getImage().getPreset();
+ ImagePreset copy = new ImagePreset(oldPreset);
+ FilterRepresentation representation = copy.getRepresentation(filterRepresentation);
+ if (representation == null) {
+ copy.addFilter(filterRepresentation);
+ } else {
+ if (filterRepresentation.allowsMultipleInstances()) {
+ representation.useParametersFrom(filterRepresentation);
+ copy.setHistoryName(filterRepresentation.getName());
+ }
+ filterRepresentation = representation;
+ }
+ MasterImage.getImage().setPreset(copy, true);
+ MasterImage.getImage().setCurrentFilterRepresentation(filterRepresentation);
+ }
+
public void showComponent(View view) {
boolean doPanelTransition = true;
if (view instanceof FilterIconButton) {
mCurrentEditor = null;
FilterIconButton component = (FilterIconButton) view;
- ImageFilter filter = component.getImageFilter();
FilterRepresentation representation = component.getFilterRepresentation();
if (representation != null) {
mUtilityPanel.setEffectName(representation.getName());
import android.widget.LinearLayout;
import com.android.gallery3d.filtershow.FilterShowActivity;
+import com.android.gallery3d.filtershow.PanelController;
import com.android.gallery3d.filtershow.cache.FilteringPipeline;
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.filters.FiltersManager;
public class FilterIconButton extends IconButton implements View.OnClickListener {
private Bitmap mOverlayBitmap = null;
- private FilterShowActivity mController = null;
+ private PanelController mController = null;
private ImageFilter mImageFilter = null;
private FilterRepresentation mFilterRepresentation = null;
private LinearLayout mParentContainer = null;
super(context, attrs, defStyle);
}
- public void setup(String text, FilterShowActivity controller, LinearLayout parent) {
+ public void setup(String text, PanelController controller, LinearLayout parent) {
mController = controller;
setText(text);
mParentContainer = parent;
invalidate();
}
- public void setup(String text, ImageFilter filter, FilterShowActivity controller,
- LinearLayout parent) {
- setup(text, controller, parent);
- mImageFilter = filter;
- }
-
@Override
protected Bitmap drawImage(Bitmap dst, Bitmap image, Rect destination) {
dst = super.drawImage(dst, image, destination);
@Override
public void onClick(View v) {
- if (mController != null && mImageFilter != null) {
+ if (mController != null) {
mController.useFilterRepresentation(mFilterRepresentation);
mParentContainer.dispatchSetSelected(false);
setSelected(true);
}
}
- public ImageFilter getImageFilter() {
- return mImageFilter;
- }
-
public FilterRepresentation getFilterRepresentation() {
return mFilterRepresentation;
}