import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
+import android.graphics.Color;
+import android.graphics.Matrix;
+import android.graphics.Point;
import android.graphics.Rect;
+import android.graphics.RectF;
+import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
+import android.os.CancellationSignal;
import android.os.Handler;
import android.os.IBinder;
import android.support.v4.app.DialogFragment;
import android.widget.FrameLayout;
import android.widget.ShareActionProvider;
import android.widget.ShareActionProvider.OnShareTargetSelectedListener;
+import android.widget.Spinner;
import android.widget.Toast;
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.cache.ImageLoader;
import com.android.gallery3d.filtershow.category.Action;
import com.android.gallery3d.filtershow.category.CategoryAdapter;
+import com.android.gallery3d.filtershow.category.CategorySelected;
+import com.android.gallery3d.filtershow.category.CategoryView;
import com.android.gallery3d.filtershow.category.MainPanel;
import com.android.gallery3d.filtershow.category.SwipableView;
import com.android.gallery3d.filtershow.data.UserPresetsManager;
import com.android.gallery3d.filtershow.editors.BasicEditor;
import com.android.gallery3d.filtershow.editors.Editor;
import com.android.gallery3d.filtershow.editors.EditorChanSat;
+import com.android.gallery3d.filtershow.editors.EditorColorBorder;
import com.android.gallery3d.filtershow.editors.EditorCrop;
import com.android.gallery3d.filtershow.editors.EditorDraw;
import com.android.gallery3d.filtershow.editors.EditorGrad;
import com.android.gallery3d.filtershow.editors.EditorStraighten;
import com.android.gallery3d.filtershow.editors.EditorTinyPlanet;
import com.android.gallery3d.filtershow.editors.ImageOnlyEditor;
+import com.android.gallery3d.filtershow.filters.FilterDrawRepresentation;
import com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation;
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.filters.FilterRotateRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterStraightenRepresentation;
import com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation;
import com.android.gallery3d.filtershow.filters.FiltersManager;
import com.android.gallery3d.filtershow.filters.ImageFilter;
import com.android.gallery3d.filtershow.ui.ExportDialog;
import com.android.gallery3d.filtershow.ui.FramedTextButton;
import com.android.gallery3d.util.GalleryUtils;
-import com.android.gallery3d.util.UsageStatistics;
+import com.android.gallery3d.util.PrintJob;
import com.android.photos.data.GalleryBitmapPool;
import java.io.File;
+import java.io.FileDescriptor;
+import java.io.FileOutputStream;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Vector;
public class FilterShowActivity extends FragmentActivity implements OnItemClickListener,
- OnShareTargetSelectedListener {
+ OnShareTargetSelectedListener, DialogInterface.OnShowListener,
+ DialogInterface.OnDismissListener{
private String mAction = "";
MasterImage mMasterImage = null;
private View mSaveButton = null;
private EditorPlaceHolder mEditorPlaceHolder = new EditorPlaceHolder(this);
+ private Editor mCurrentEditor = null;
private static final int SELECT_PICTURE = 1;
private static final String LOGTAG = "FilterShowActivity";
private boolean mShowingTinyPlanet = false;
private boolean mShowingImageStatePanel = false;
private boolean mShowingVersionsPanel = false;
- private boolean mShowingInformationPanel = false;
private final Vector<ImageShow> mImageViews = new Vector<ImageShow>();
private Uri mSelectedImageUri = null;
+ private ArrayList<Action> mActions = new ArrayList<Action>();
private UserPresetsManager mUserPresetsManager = null;
private UserPresetsAdapter mUserPresetsAdapter = null;
private CategoryAdapter mCategoryLooksAdapter = null;
private boolean mHandlingSwipeButton = false;
private View mHandledSwipeView = null;
private float mHandledSwipeViewLastDelta = 0;
+ private float mSwipeStartX = 0;
private float mSwipeStartY = 0;
private ProcessingService mBoundService;
private boolean mIsBound = false;
+ private Menu mMenu;
+ private DialogInterface mCurrentDialog = null;
+ private boolean mLoadingVisible = true;
public ProcessingService getProcessingService() {
return mBoundService;
}
}
- private void setupPipeline() {
- doBindService();
+ public void updateUIAfterServiceStarted() {
+ MasterImage.setMaster(mMasterImage);
ImageFilter.setActivityForMemoryToasts(this);
mUserPresetsManager = new UserPresetsManager(this);
mUserPresetsAdapter = new UserPresetsAdapter(this);
- }
- public void updateUIAfterServiceStarted() {
+ setupMasterImage();
+ setupMenu();
+ setDefaultValues();
+ fillEditors();
+ getWindow().setBackgroundDrawable(new ColorDrawable(0));
+ loadXML();
+
fillCategories();
loadMainPanel();
- setDefaultPreset();
extractXMPData();
processIntent();
}
if (onlyUsePortrait) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
- MasterImage.setMaster(mMasterImage);
clearGalleryBitmapPool();
- setupPipeline();
-
- setupMasterImage();
- setDefaultValues();
- fillEditors();
-
- loadXML();
- UsageStatistics.onContentViewChanged(UsageStatistics.COMPONENT_EDITOR, "Main");
- UsageStatistics.onEvent(UsageStatistics.COMPONENT_EDITOR,
- UsageStatistics.CATEGORY_LIFECYCLE, UsageStatistics.LIFECYCLE_START);
+ doBindService();
+ getWindow().setBackgroundDrawable(new ColorDrawable(Color.GRAY));
+ setContentView(R.layout.filtershow_splashscreen);
}
public boolean isShowingImageStatePanel() {
}
}
- private void hideInformationPanel() {
- FrameLayout infoLayout = (FrameLayout) findViewById(R.id.central_panel_container);
- infoLayout.setVisibility(View.GONE);
- Fragment fragment = getSupportFragmentManager().findFragmentByTag(InfoPanel.FRAGMENT_TAG);
- if (fragment != null) {
- FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
- transaction.remove(fragment);
- transaction.commit();
- }
- mShowingInformationPanel = false;
- }
-
- public void showInformationPanel() {
- mShowingInformationPanel = !mShowingInformationPanel;
- if (!mShowingInformationPanel) {
- hideInformationPanel();
- showDefaultImageView();
- return;
- }
+ public void toggleInformationPanel() {
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_left);
- FrameLayout infoLayout = (FrameLayout) findViewById(R.id.central_panel_container);
- infoLayout.setVisibility(View.VISIBLE);
- mEditorPlaceHolder.hide();
- mImageShow.setVisibility(View.GONE);
InfoPanel panel = new InfoPanel();
- transaction.replace(R.id.central_panel_container, panel, InfoPanel.FRAGMENT_TAG);
- transaction.commit();
+ panel.show(transaction, InfoPanel.FRAGMENT_TAG);
}
private void loadXML() {
ActionBar actionBar = getActionBar();
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setCustomView(R.layout.filtershow_actionbar);
+ actionBar.setBackgroundDrawable(new ColorDrawable(
+ getResources().getColor(R.color.background_screen)));
mSaveButton = actionBar.getCustomView();
mSaveButton.setOnClickListener(new OnClickListener() {
setupEditors();
mEditorPlaceHolder.hide();
- mImageShow.bindAsImageLoadListener();
+ mImageShow.attach();
setupStatePanel();
}
}
private void fillVersions() {
+ if (mCategoryVersionsAdapter != null) {
+ mCategoryVersionsAdapter.clear();
+ }
mCategoryVersionsAdapter = new CategoryAdapter(this);
mCategoryVersionsAdapter.setShowAddButton(true);
}
+ public void registerAction(Action action) {
+ if (mActions.contains(action)) {
+ return;
+ }
+ mActions.add(action);
+ }
+
+ private void loadActions() {
+ for (int i = 0; i < mActions.size(); i++) {
+ Action action = mActions.get(i);
+ action.setImageFrame(new Rect(0, 0, 96, 96), 0);
+ }
+ }
+
public void updateVersions() {
mCategoryVersionsAdapter.clear();
FilterUserPresetRepresentation originalRep = new FilterUserPresetRepresentation(
}
public void removeLook(Action action) {
- FilterUserPresetRepresentation rep = (FilterUserPresetRepresentation) action.getRepresentation();
+ FilterUserPresetRepresentation rep =
+ (FilterUserPresetRepresentation) action.getRepresentation();
if (rep == null) {
return;
}
mUserPresetsManager.delete(rep.getId());
+ updateUserPresetsFromManager();
}
private void fillEffects() {
FiltersManager filtersManager = FiltersManager.getManager();
ArrayList<FilterRepresentation> filtersRepresentations = filtersManager.getEffects();
+ if (mCategoryFiltersAdapter != null) {
+ mCategoryFiltersAdapter.clear();
+ }
mCategoryFiltersAdapter = new CategoryAdapter(this);
for (FilterRepresentation representation : filtersRepresentations) {
if (representation.getTextId() != 0) {
private void fillTools() {
FiltersManager filtersManager = FiltersManager.getManager();
ArrayList<FilterRepresentation> filtersRepresentations = filtersManager.getTools();
+ if (mCategoryGeometryAdapter != null) {
+ mCategoryGeometryAdapter.clear();
+ }
mCategoryGeometryAdapter = new CategoryAdapter(this);
+ boolean found = false;
for (FilterRepresentation representation : filtersRepresentations) {
mCategoryGeometryAdapter.add(new Action(this, representation));
+ if (representation instanceof FilterDrawRepresentation) {
+ found = true;
+ }
+ }
+ if (!found) {
+ FilterRepresentation representation = new FilterDrawRepresentation();
+ Action action = new Action(this, representation);
+ action.setIsDoubleAction(true);
+ mCategoryGeometryAdapter.add(action);
}
}
mEditorPlaceHolder.addEditor(new EditorChanSat());
mEditorPlaceHolder.addEditor(new EditorGrad());
mEditorPlaceHolder.addEditor(new EditorDraw());
+ mEditorPlaceHolder.addEditor(new EditorColorBorder());
mEditorPlaceHolder.addEditor(new BasicEditor());
mEditorPlaceHolder.addEditor(new ImageOnlyEditor());
mEditorPlaceHolder.addEditor(new EditorTinyPlanet());
int curveHandleSize = (int) res.getDimension(R.dimen.crop_indicator_size);
Spline.setCurveHandle(curveHandle, curveHandleSize);
Spline.setCurveWidth((int) getPixelsFromDip(3));
+
+ mOriginalImageUri = null;
}
private void startLoadBitmap(Uri uri) {
- final View loading = findViewById(R.id.loading);
final View imageShow = findViewById(R.id.imageShow);
imageShow.setVisibility(View.INVISIBLE);
- loading.setVisibility(View.VISIBLE);
+ startLoadingIndicator();
mShowingTinyPlanet = false;
mLoadBitmapTask = new LoadBitmapTask();
mLoadBitmapTask.execute(uri);
}
}
+ if (mCategoryBordersAdapter != null) {
+ mCategoryBordersAdapter.clear();
+ }
mCategoryBordersAdapter = new CategoryAdapter(this);
for (FilterRepresentation representation : borders) {
if (representation.getTextId() != 0) {
&& MasterImage.getImage().getCurrentFilterRepresentation() == filterRepresentation) {
return;
}
+ if (filterRepresentation instanceof FilterUserPresetRepresentation
+ || filterRepresentation instanceof FilterRotateRepresentation
+ || filterRepresentation instanceof FilterMirrorRepresentation) {
+ MasterImage.getImage().onNewLook(filterRepresentation);
+ }
ImagePreset oldPreset = MasterImage.getImage().getPreset();
ImagePreset copy = new ImagePreset(oldPreset);
FilterRepresentation representation = copy.getRepresentation(filterRepresentation);
if (representation == null) {
+ filterRepresentation = filterRepresentation.copy();
copy.addFilter(filterRepresentation);
- } else if (filterRepresentation.getFilterType() == FilterRepresentation.TYPE_GEOMETRY) {
- representation.useParametersFrom(filterRepresentation);
- filterRepresentation = representation;
} else {
if (filterRepresentation.allowsSingleInstanceOnly()) {
// Don't just update the filter representation. Centralize the
// logic in the addFilter(), such that we can keep "None" as
// null.
- copy.removeFilter(representation);
- copy.addFilter(filterRepresentation);
+ if (!representation.equals(filterRepresentation)) {
+ // Only do this if the filter isn't the same
+ // (state panel clicks can lead us here)
+ copy.removeFilter(representation);
+ copy.addFilter(filterRepresentation);
+ }
}
}
MasterImage.getImage().setPreset(copy, filterRepresentation, true);
FilterMirrorRepresentation r = (FilterMirrorRepresentation) representation;
r.cycle();
}
+ if (representation.isBooleanFilter()) {
+ ImagePreset preset = MasterImage.getImage().getPreset();
+ if (preset.getRepresentation(representation) != null) {
+ // remove
+ ImagePreset copy = new ImagePreset(preset);
+ copy.removeFilter(representation);
+ FilterRepresentation filterRepresentation = representation.copy();
+ MasterImage.getImage().setPreset(copy, filterRepresentation, true);
+ MasterImage.getImage().setCurrentFilterRepresentation(null);
+ return;
+ }
+ }
useFilterRepresentation(representation);
// show representation
- Editor mCurrentEditor = mEditorPlaceHolder.showEditor(representation.getEditorId());
+ if (mCurrentEditor != null) {
+ mCurrentEditor.detach();
+ }
+ mCurrentEditor = mEditorPlaceHolder.showEditor(representation.getEditorId());
loadEditorPanel(representation, mCurrentEditor);
- hideInformationPanel();
}
public Editor getEditor(int editorID) {
return findViewById(id);
}
+ @Override
+ public void onShow(DialogInterface dialog) {
+ mCurrentDialog = dialog;
+ }
+
+ @Override
+ public void onDismiss(DialogInterface dialogInterface) {
+ mCurrentDialog = null;
+ }
+
private class LoadHighresBitmapTask extends AsyncTask<Void, Void, Boolean> {
@Override
protected Boolean doInBackground(Void... params) {
/ (float) MasterImage.getImage().getOriginalBounds().width();
mBoundService.setHighresPreviewScaleFactor(highResPreviewScale);
}
+ MasterImage.getImage().warnListeners();
}
}
+ public boolean isLoadingVisible() {
+ return mLoadingVisible;
+ }
+
+ public void startLoadingIndicator() {
+ final View loading = findViewById(R.id.loading);
+ mLoadingVisible = true;
+ loading.setVisibility(View.VISIBLE);
+ }
+
+ public void stopLoadingIndicator() {
+ final View loading = findViewById(R.id.loading);
+ loading.setVisibility(View.GONE);
+ mLoadingVisible = false;
+ }
+
private class LoadBitmapTask extends AsyncTask<Uri, Boolean, Boolean> {
int mBitmapSize;
}
if (!result) {
- cannotLoadImage();
- // TODO: We should figure out the best way preventing this from
- // happening, e.g: early checking.
+ if (mOriginalImageUri != null
+ && !mOriginalImageUri.equals(mSelectedImageUri)) {
+ mOriginalImageUri = mSelectedImageUri;
+ mOriginalPreset = null;
+ Toast.makeText(FilterShowActivity.this,
+ R.string.cannot_edit_original, Toast.LENGTH_SHORT).show();
+ startLoadBitmap(mOriginalImageUri);
+ } else {
+ cannotLoadImage();
+ }
return;
}
Log.v(LOGTAG,"RenderScript context destroyed during load");
return;
}
- final View loading = findViewById(R.id.loading);
- loading.setVisibility(View.GONE);
final View imageShow = findViewById(R.id.imageShow);
imageShow.setVisibility(View.VISIBLE);
+
Bitmap largeBitmap = MasterImage.getImage().getOriginalBitmapLarge();
mBoundService.setOriginalBitmap(largeBitmap);
- MasterImage.getImage().resetGeometryImages();
float previewScale = (float) largeBitmap.getWidth()
/ (float) MasterImage.getImage().getOriginalBounds().width();
mCategoryFiltersAdapter.imageLoaded();
mLoadBitmapTask = null;
+ MasterImage.getImage().warnListeners();
+ loadActions();
+
if (mOriginalPreset != null) {
MasterImage.getImage().setLoadedPreset(mOriginalPreset);
MasterImage.getImage().setPreset(mOriginalPreset,
mOriginalPreset.getLastRepresentation(), true);
mOriginalPreset = null;
+ } else {
+ setDefaultPreset();
}
+ MasterImage.getImage().resetGeometryImages(true);
+
if (mAction == TINY_PLANET_ACTION) {
showRepresentation(mCategoryFiltersAdapter.getTinyPlanet());
}
LoadHighresBitmapTask highresLoad = new LoadHighresBitmapTask();
highresLoad.execute();
+ MasterImage.getImage().warnListeners();
super.onPostExecute(result);
}
.getActionProvider();
mShareActionProvider.setShareIntent(getDefaultShareIntent());
mShareActionProvider.setOnShareTargetSelectedListener(this);
+ mMenu = menu;
+ setupMenu();
+ return true;
+ }
- MenuItem undoItem = menu.findItem(R.id.undoButton);
- MenuItem redoItem = menu.findItem(R.id.redoButton);
- MenuItem resetItem = menu.findItem(R.id.resetHistoryButton);
+ private void setupMenu(){
+ if (mMenu == null || mMasterImage == null) {
+ return;
+ }
+ MenuItem undoItem = mMenu.findItem(R.id.undoButton);
+ MenuItem redoItem = mMenu.findItem(R.id.redoButton);
+ MenuItem resetItem = mMenu.findItem(R.id.resetHistoryButton);
mMasterImage.getHistory().setMenuItems(undoItem, redoItem, resetItem);
- return true;
}
@Override
mMasterImage.onHistoryItemClick(position);
backToMain();
invalidateViews();
- UsageStatistics.onEvent(UsageStatistics.COMPONENT_EDITOR,
- UsageStatistics.CATEGORY_BUTTON_PRESS, "Undo");
return true;
}
case R.id.redoButton: {
int position = adapter.redo();
mMasterImage.onHistoryItemClick(position);
invalidateViews();
- UsageStatistics.onEvent(UsageStatistics.COMPONENT_EDITOR,
- UsageStatistics.CATEGORY_BUTTON_PRESS, "Redo");
return true;
}
case R.id.resetHistoryButton: {
resetHistory();
- UsageStatistics.onEvent(UsageStatistics.COMPONENT_EDITOR,
- UsageStatistics.CATEGORY_BUTTON_PRESS, "ResetHistory");
return true;
}
case R.id.showImageStateButton: {
toggleImageStatePanel();
- UsageStatistics.onEvent(UsageStatistics.COMPONENT_EDITOR,
- UsageStatistics.CATEGORY_BUTTON_PRESS,
- mShowingImageStatePanel ? "ShowPanel" : "HidePanel");
return true;
}
case R.id.exportFlattenButton: {
return true;
}
case R.id.showInfoPanel: {
- showInformationPanel();
+ toggleInformationPanel();
+ return true;
+ }
+ case R.id.printButton: {
+ print();
return true;
}
}
return false;
}
+ public void print() {
+ Bitmap bitmap = MasterImage.getImage().getHighresImage();
+ PrintJob.printBitmap(this, "ImagePrint", bitmap);
+ }
+
public void addNewPreset() {
DialogFragment dialog = new PresetManagementDialog();
dialog.show(getSupportFragmentManager(), "NoticeDialogFragment");
public void loadUserPresets() {
mUserPresetsManager.load();
+ updateUserPresetsFromManager();
}
public void updateUserPresetsFromManager() {
if (presets.size() > 0) {
mCategoryLooksAdapter.add(new Action(this, Action.ADD_ACTION));
}
+ mCategoryLooksAdapter.notifyDataSetChanged();
mCategoryLooksAdapter.notifyDataSetInvalidated();
}
FiltersManager filtersManager = FiltersManager.getManager();
ArrayList<FilterRepresentation> filtersRepresentations = filtersManager.getLooks();
+ if (mCategoryLooksAdapter != null) {
+ mCategoryLooksAdapter.clear();
+ }
mCategoryLooksAdapter = new CategoryAdapter(this);
int verticalItemHeight = (int) getResources().getDimension(R.dimen.action_item_height);
mCategoryLooksAdapter.setItemHeight(verticalItemHeight);
|| mUserPresetsManager.getRepresentations().size() == 0) {
mCategoryLooksAdapter.add(new Action(this, Action.ADD_ACTION));
}
+
+ Fragment panel = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG);
+ if (panel != null) {
+ if (panel instanceof MainPanel) {
+ MainPanel mainPanel = (MainPanel) panel;
+ mainPanel.loadCategoryLookPanel(true);
+ }
+ }
}
public void setDefaultPreset() {
public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
+
setDefaultValues();
+ if (mMasterImage == null) {
+ return;
+ }
loadXML();
fillCategories();
loadMainPanel();
+ if (mCurrentDialog != null) {
+ mCurrentDialog.dismiss();
+ mCurrentDialog = null;
+ }
// mLoadBitmapTask==null implies you have looked at the intent
if (!mShowingTinyPlanet && (mLoadBitmapTask == null)) {
mCategoryFiltersAdapter.removeTinyPlanet();
}
- final View loading = findViewById(R.id.loading);
- loading.setVisibility(View.GONE);
+ stopLoadingIndicator();
}
public void setupMasterImage() {
}
public void showDefaultImageView() {
- hideInformationPanel();
mEditorPlaceHolder.hide();
mImageShow.setVisibility(View.VISIBLE);
MasterImage.getImage().setCurrentFilter(null);
return mSelectedImageUri;
}
- public void setHandlesSwipeForView(View view, float startY) {
+ public void setHandlesSwipeForView(View view, float startX, float startY) {
if (view != null) {
mHandlingSwipeButton = true;
} else {
mHandledSwipeView = view;
int[] location = new int[2];
view.getLocationInWindow(location);
+ mSwipeStartX = location[0] + startX;
mSwipeStartY = location[1] + startY;
}
public boolean dispatchTouchEvent (MotionEvent ev) {
if (mHandlingSwipeButton) {
+ int direction = CategoryView.HORIZONTAL;
+ if (mHandledSwipeView instanceof CategoryView) {
+ direction = ((CategoryView) mHandledSwipeView).getOrientation();
+ }
if (ev.getActionMasked() == MotionEvent.ACTION_MOVE) {
float delta = ev.getY() - mSwipeStartY;
- mHandledSwipeView.setTranslationY(delta);
+ float distance = mHandledSwipeView.getHeight();
+ if (direction == CategoryView.VERTICAL) {
+ delta = ev.getX() - mSwipeStartX;
+ mHandledSwipeView.setTranslationX(delta);
+ distance = mHandledSwipeView.getWidth();
+ } else {
+ mHandledSwipeView.setTranslationY(delta);
+ }
delta = Math.abs(delta);
- float transparency = Math.min(1, delta / mHandledSwipeView.getHeight());
+ float transparency = Math.min(1, delta / distance);
mHandledSwipeView.setAlpha(1.f - transparency);
mHandledSwipeViewLastDelta = delta;
}
if (ev.getActionMasked() == MotionEvent.ACTION_CANCEL
|| ev.getActionMasked() == MotionEvent.ACTION_UP) {
+ mHandledSwipeView.setTranslationX(0);
mHandledSwipeView.setTranslationY(0);
mHandledSwipeView.setAlpha(1.f);
mHandlingSwipeButton = false;
- if (mHandledSwipeViewLastDelta > mHandledSwipeView.getHeight()) {
+ float distance = mHandledSwipeView.getHeight();
+ if (direction == CategoryView.VERTICAL) {
+ distance = mHandledSwipeView.getWidth();
+ }
+ if (mHandledSwipeViewLastDelta > distance) {
((SwipableView) mHandledSwipeView).delete();
}
}
}
return super.dispatchTouchEvent(ev);
}
+
+ public Point mHintTouchPoint = new Point();
+
+ public Point hintTouchPoint(View view) {
+ int location[] = new int[2];
+ view.getLocationOnScreen(location);
+ int x = mHintTouchPoint.x - location[0];
+ int y = mHintTouchPoint.y - location[1];
+ return new Point(x, y);
+ }
+
+ public void startTouchAnimation(View target, float x, float y) {
+ final CategorySelected hint =
+ (CategorySelected) findViewById(R.id.categorySelectedIndicator);
+ int location[] = new int[2];
+ target.getLocationOnScreen(location);
+ mHintTouchPoint.x = (int) (location[0] + x);
+ mHintTouchPoint.y = (int) (location[1] + y);
+ int locationHint[] = new int[2];
+ ((View)hint.getParent()).getLocationOnScreen(locationHint);
+ int dx = (int) (x - (hint.getWidth())/2);
+ int dy = (int) (y - (hint.getHeight())/2);
+ hint.setTranslationX(location[0] - locationHint[0] + dx);
+ hint.setTranslationY(location[1] - locationHint[1] + dy);
+ hint.setVisibility(View.VISIBLE);
+ hint.animate().scaleX(2).scaleY(2).alpha(0).withEndAction(new Runnable() {
+ @Override
+ public void run() {
+ hint.setVisibility(View.INVISIBLE);
+ hint.setScaleX(1);
+ hint.setScaleY(1);
+ hint.setAlpha(1);
+ }
+ });
+ }
}