use of com.android.gallery3d.filtershow.category.SwipableView in project android_packages_apps_Gallery2 by LineageOS.
the class FilterShowActivity method handlePreset.
public void handlePreset(Action action, View view, int i) {
mChangeable = true;
mHandledSwipeView = view;
final Action ac = action;
mFilterPresetSource = new FilterPresetSource(this);
switch(i) {
case R.id.renameButton:
final View layout = View.inflate(this, R.layout.filtershow_default_edittext, null);
AlertDialog.Builder renameAlertDialogBuilder = new AlertDialog.Builder(this);
renameAlertDialogBuilder.setTitle(R.string.rename_before_exit);
renameAlertDialogBuilder.setView(layout);
renameAlertDialogBuilder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
EditText mEditText = (EditText) layout.findViewById(R.id.filtershow_default_edit);
String name = String.valueOf(mEditText.getText());
if ((name.trim().length() == 0) || name.isEmpty()) {
Toast.makeText(getApplicationContext(), getString(R.string.filter_name_notification), Toast.LENGTH_SHORT).show();
} else if (isDuplicateName(name)) {
Toast.makeText(getApplicationContext(), getString(R.string.filter_name_duplicate), Toast.LENGTH_SHORT).show();
} else {
renamePreset(ac, name);
}
dialog.dismiss();
}
});
renameAlertDialogBuilder.setNegativeButton(mCancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
}
});
renameAlertDialogBuilder.create().show();
break;
case R.id.deleteButton:
String name = action.getName();
AlertDialog.Builder deleteAlertDialogBuilder = new AlertDialog.Builder(this);
String textview = "Do you want to delete " + name + "?";
deleteAlertDialogBuilder.setMessage(textview).setTitle(R.string.delete_before_exit);
deleteAlertDialogBuilder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
((SwipableView) mHandledSwipeView).delete();
dialog.dismiss();
}
});
deleteAlertDialogBuilder.setNegativeButton(mCancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
deleteAlertDialogBuilder.create().show();
break;
}
}
use of com.android.gallery3d.filtershow.category.SwipableView in project android_packages_apps_Gallery2 by LineageOS.
the class FilterShowActivity method dispatchTouchEvent.
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;
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 / 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;
float distance = mHandledSwipeView.getHeight();
if (direction == CategoryView.VERTICAL) {
distance = mHandledSwipeView.getWidth();
}
if (mHandledSwipeViewLastDelta > distance) {
((SwipableView) mHandledSwipeView).delete();
}
}
return true;
}
return super.dispatchTouchEvent(ev);
}
Aggregations