Refactoring

pull/207/head
M66B 3 years ago
parent 67d5cb97e3
commit 74fa856ff0

@ -6527,83 +6527,83 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
return; return;
} }
SimpleTask<Void> move = new SimpleTask<Void>() { String title = getString(R.string.title_move_undo, getNames(result, true), result.size());
@Override ((ActivityView) activity).undo(title, args, taskUndoMove, taskUndoShow);
protected Void onExecute(Context context, Bundle args) { }
ArrayList<MessageTarget> result = args.getParcelableArrayList("result");
DB db = DB.getInstance(context);
try {
db.beginTransaction();
for (MessageTarget target : result) { @Override
EntityMessage message = db.message().getMessage(target.id); protected void onException(Bundle args, Throwable ex) {
if (message == null || !message.ui_hide) Log.unexpectedError(getParentFragmentManager(), ex);
continue; }
}.execute(this, args, "undo:hide");
}
Log.i("Move id=" + target.id + " target=" + target.targetFolder.name); private static final SimpleTask<Void> taskUndoMove = new SimpleTask<Void>() {
db.message().setMessageUiBusy(target.id, null); @Override
db.message().setMessageLastAttempt(target.id, new Date().getTime()); protected Void onExecute(Context context, Bundle args) {
EntityOperation.queue(context, message, EntityOperation.MOVE, target.targetFolder.id); ArrayList<MessageTarget> result = args.getParcelableArrayList("result");
}
db.setTransactionSuccessful(); DB db = DB.getInstance(context);
} finally { try {
db.endTransaction(); db.beginTransaction();
}
ServiceSynchronize.eval(context, "move"); for (MessageTarget target : result) {
EntityMessage message = db.message().getMessage(target.id);
if (message == null || !message.ui_hide)
continue;
return null; Log.i("Move id=" + target.id + " target=" + target.targetFolder.name);
} db.message().setMessageUiBusy(target.id, null);
db.message().setMessageLastAttempt(target.id, new Date().getTime());
EntityOperation.queue(context, message, EntityOperation.MOVE, target.targetFolder.id);
}
@Override db.setTransactionSuccessful();
protected void onException(Bundle args, Throwable ex) { } finally {
Log.e(ex); db.endTransaction();
} }
};
SimpleTask<Void> show = new SimpleTask<Void>() { ServiceSynchronize.eval(context, "move");
@Override
protected Void onExecute(Context context, Bundle args) {
ArrayList<MessageTarget> result = args.getParcelableArrayList("result");
DB db = DB.getInstance(context); return null;
try { }
db.beginTransaction();
for (MessageTarget target : result) { @Override
Log.i("Move undo id=" + target.id); protected void onException(Bundle args, Throwable ex) {
db.message().setMessageUiBusy(target.id, null); Log.e(ex);
db.message().setMessageUiHide(target.id, false); }
db.message().setMessageFound(target.id, target.found); };
db.message().setMessageLastAttempt(target.id, new Date().getTime());
}
db.setTransactionSuccessful(); private static final SimpleTask<Void> taskUndoShow = new SimpleTask<Void>() {
} finally { @Override
db.endTransaction(); protected Void onExecute(Context context, Bundle args) {
} ArrayList<MessageTarget> result = args.getParcelableArrayList("result");
return null; DB db = DB.getInstance(context);
} try {
db.beginTransaction();
@Override for (MessageTarget target : result) {
protected void onException(Bundle args, Throwable ex) { Log.i("Move undo id=" + target.id);
Log.e(ex); db.message().setMessageUiBusy(target.id, null);
} db.message().setMessageUiHide(target.id, false);
}; db.message().setMessageFound(target.id, target.found);
db.message().setMessageLastAttempt(target.id, new Date().getTime());
}
String title = getString(R.string.title_move_undo, getNames(result, true), result.size()); db.setTransactionSuccessful();
((ActivityView) activity).undo(title, args, move, show); } finally {
db.endTransaction();
} }
@Override return null;
protected void onException(Bundle args, Throwable ex) { }
Log.unexpectedError(getParentFragmentManager(), ex);
} @Override
}.execute(this, args, "undo:hide"); protected void onException(Bundle args, Throwable ex) {
} Log.e(ex);
}
};
private static String getNames(ArrayList<MessageTarget> result, boolean dest) { private static String getNames(ArrayList<MessageTarget> result, boolean dest) {
boolean across = false; boolean across = false;

Loading…
Cancel
Save