1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-26 17:57:16 +00:00

Refactored undo (2)

This commit is contained in:
M66B 2020-12-15 09:22:56 +01:00
parent d57584385b
commit f5d81a17b5

View file

@ -748,24 +748,31 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
if (drawerLayout == null || drawerLayout.getChildCount() == 0) {
Log.e("Undo: drawer missing");
show.execute(this, args, "undo:move");
return;
}
final View content = drawerLayout.getChildAt(0);
if (lastSnackbar != null && lastSnackbar.isShown())
lastSnackbar.dismiss();
final Snackbar snackbar = Snackbar.make(content, title, Snackbar.LENGTH_INDEFINITE)
.setGestureInsetBottomIgnored(true);
lastSnackbar = snackbar;
final Runnable timeout = new Runnable() {
@Override
public void run() {
Log.i("Undo timeout");
snackbar.dismiss();
move.execute(ActivityView.this, args, "undo:move");
}
};
snackbar.setAction(R.string.title_undo, new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.i("Undo cancel");
snackbar.getView().setTag(true);
getMainHandler().removeCallbacks(timeout);
snackbar.dismiss();
show.execute(ActivityView.this, args, "undo:show");
}
@ -792,16 +799,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
snackbar.show();
// Wait
getMainHandler().postDelayed(new Runnable() {
@Override
public void run() {
Log.i("Undo timeout");
snackbar.dismiss();
if (snackbar.getView().getTag() == null)
move.execute(ActivityView.this, args, "undo:move");
}
}, undo_timeout);
getMainHandler().postDelayed(timeout, undo_timeout);
}
private void checkFirst() {