diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-12-27 20:39:14 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-12-27 20:39:14 +0100 |
commit | 7a3e2db6c90ffd7a5fa1b5e91d84df2e7367fa6d (patch) | |
tree | 51580cfe051a9311c3bb8037e62af02e6b746088 /src/main/java | |
parent | 9e10915d8b546a0eb7482401364c91a58ce57a3d (diff) |
fixed some rare crashes caused by race conditions
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ConversationFragment.java | 2 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index e5ad20447..cd0a6e4d6 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -2034,7 +2034,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke if (scrollState != null) { outState.putParcelable(STATE_SCROLL_POSITION, scrollState); } - final ArrayList<Attachment> attachments = mediaPreviewAdapter.getAttachments(); + final ArrayList<Attachment> attachments = mediaPreviewAdapter == null ? new ArrayList<>() : mediaPreviewAdapter.getAttachments(); if (attachments.size() > 0) { outState.putParcelableArrayList(STATE_MEDIA_PREVIEWS, attachments); } diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java index 95ccda7d2..fd9074771 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java @@ -237,9 +237,10 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie viewHolder.edit_indicator.setVisibility(View.GONE); } } + final Transferable transferable = message.getTransferable(); boolean multiReceived = message.getConversation().getMode() == Conversation.MODE_MULTI && message.getMergedStatus() <= Message.STATUS_RECEIVED; - if (message.getType() == Message.TYPE_IMAGE || message.getType() == Message.TYPE_FILE || message.getTransferable() != null) { + if (message.getType() == Message.TYPE_IMAGE || message.getType() == Message.TYPE_FILE || transferable != null) { FileParams params = message.getFileParams(); if (params.size > (1 * 1024 * 1024)) { filesize = Math.round(params.size * 1f / (1024 * 1024)) + " MiB"; @@ -248,7 +249,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie } else if (params.size > 0){ filesize = params.size + " B"; } - if (message.getTransferable() != null && message.getTransferable().getStatus() == Transferable.STATUS_FAILED) { + if (transferable != null && transferable.getStatus() == Transferable.STATUS_FAILED) { error = true; } } @@ -257,9 +258,8 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie info = getContext().getString(R.string.waiting); break; case Message.STATUS_UNSEND: - Transferable d = message.getTransferable(); - if (d != null) { - info = getContext().getString(R.string.sending_file, d.getProgress()); + if (transferable != null) { + info = getContext().getString(R.string.sending_file, transferable.getProgress()); } else { info = getContext().getString(R.string.sending); } |