Prevent crash

pull/147/head
M66B 6 years ago
parent 3b0209cf6e
commit 29248811f7

@ -1073,6 +1073,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
db.beginTransaction(); db.beginTransaction();
EntityMessage message = db.message().getMessage(id); EntityMessage message = db.message().getMessage(id);
if (message == null)
return null;
EntityFolder junk = db.folder().getFolderByType(message.account, EntityFolder.JUNK); EntityFolder junk = db.folder().getFolderByType(message.account, EntityFolder.JUNK);
EntityOperation.queue(db, message, EntityOperation.MOVE, junk.id); EntityOperation.queue(db, message, EntityOperation.MOVE, junk.id);
@ -1220,6 +1223,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
db.beginTransaction(); db.beginTransaction();
EntityMessage message = db.message().getMessage(id); EntityMessage message = db.message().getMessage(id);
if (message == null)
return null;
EntityOperation.queue(db, message, EntityOperation.SEEN, false); EntityOperation.queue(db, message, EntityOperation.SEEN, false);
db.setTransactionSuccessful(); db.setTransactionSuccessful();
@ -1258,11 +1264,22 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean thread = args.getBoolean("thread"); boolean thread = args.getBoolean("thread");
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
EntityMessage message = db.message().getMessage(id); try {
List<EntityMessage> messages = db.message().getMessageByThread( db.beginTransaction();
message.account, message.thread, threading && thread ? null : id, message.folder);
for (EntityMessage threaded : messages) EntityMessage message = db.message().getMessage(id);
EntityOperation.queue(db, threaded, EntityOperation.FLAG, flagged); if (message == null)
return null;
List<EntityMessage> messages = db.message().getMessageByThread(
message.account, message.thread, threading && thread ? null : id, message.folder);
for (EntityMessage threaded : messages)
EntityOperation.queue(db, threaded, EntityOperation.FLAG, flagged);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
return null; return null;
} }
@ -1291,9 +1308,21 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
@Override @Override
protected Void onExecute(Context context, Bundle args) { protected Void onExecute(Context context, Bundle args) {
Long id = args.getLong("id"); Long id = args.getLong("id");
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
EntityMessage message = db.message().getMessage(id); try {
EntityOperation.queue(db, message, EntityOperation.HEADERS); db.beginTransaction();
EntityMessage message = db.message().getMessage(id);
if (message == null)
return null;
EntityOperation.queue(db, message, EntityOperation.HEADERS);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
return null; return null;
} }
@ -1529,6 +1558,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
db.beginTransaction(); db.beginTransaction();
EntityMessage message = db.message().getMessage(id); EntityMessage message = db.message().getMessage(id);
if (message == null)
return null;
if (message.uid == null && !TextUtils.isEmpty(message.error)) { if (message.uid == null && !TextUtils.isEmpty(message.error)) {
// outbox // outbox
db.message().deleteMessage(id); db.message().deleteMessage(id);
@ -1568,11 +1600,24 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
new SimpleTask<List<EntityFolder>>() { new SimpleTask<List<EntityFolder>>() {
@Override @Override
protected List<EntityFolder> onExecute(Context context, Bundle args) { protected List<EntityFolder> onExecute(Context context, Bundle args) {
EntityMessage message;
List<EntityFolder> folders = new ArrayList<>();
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
try {
db.beginTransaction();
message = db.message().getMessage(args.getLong("id"));
if (message == null)
return folders;
EntityMessage message = db.message().getMessage(args.getLong("id")); folders = db.folder().getFolders(message.account);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
List<EntityFolder> folders = db.folder().getFolders(message.account);
List<EntityFolder> targets = new ArrayList<>(); List<EntityFolder> targets = new ArrayList<>();
for (EntityFolder folder : folders) for (EntityFolder folder : folders)
if (!folder.hide && if (!folder.hide &&

Loading…
Cancel
Save