From 7a3e2db6c90ffd7a5fa1b5e91d84df2e7367fa6d Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Thu, 27 Dec 2018 20:39:14 +0100 Subject: fixed some rare crashes caused by race conditions --- .../java/de/pixart/messenger/ui/adapter/MessageAdapter.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/main/java/de/pixart/messenger/ui/adapter') 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 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 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 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); } -- cgit v1.2.3