From 93cf923348a2d5992a201b51b292bfe8280e9d1d Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sun, 22 Apr 2018 09:13:21 +0200 Subject: fix crash in resendMessage --- .../de/pixart/messenger/ui/ConversationFragment.java | 2 +- .../de/pixart/messenger/ui/adapter/MessageAdapter.java | 16 +++------------- 2 files changed, 4 insertions(+), 14 deletions(-) (limited to 'src/main/java/de') diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 7dc0697db..8a1db5736 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -1840,7 +1840,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } public void resendMessage(final Message message) { - if (message.isFileOrImage()) { + if (message != null && message.isFileOrImage()) { DownloadableFile file = activity.xmppConnectionService.getFileBackend().getFile(message); if (file.exists()) { final Conversation conversation = message.getConversation(); 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 3eba89ffe..0b464e096 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java @@ -36,7 +36,6 @@ import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; import android.view.View; -import android.view.View.OnClickListener; import android.view.ViewGroup; import android.view.WindowManager; import android.widget.ArrayAdapter; @@ -72,8 +71,8 @@ import de.pixart.messenger.persistance.FileBackend; import de.pixart.messenger.services.AudioPlayer; import de.pixart.messenger.services.MessageArchiveService; import de.pixart.messenger.services.NotificationService; -import de.pixart.messenger.ui.ConversationsActivity; import de.pixart.messenger.ui.ConversationFragment; +import de.pixart.messenger.ui.ConversationsActivity; import de.pixart.messenger.ui.ShowFullscreenMessageActivity; import de.pixart.messenger.ui.XmppActivity; import de.pixart.messenger.ui.text.DividerSpan; @@ -336,14 +335,7 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie } viewHolder.resend_button.setText(R.string.send_again); viewHolder.resend_button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_resend_grey600_48dp, 0, 0, 0); - viewHolder.resend_button.setOnClickListener(new OnClickListener() { - final Message mMessage = message; - - @Override - public void onClick(View v) { - mConversationFragment.resendMessage(mMessage); - } - }); + viewHolder.resend_button.setOnClickListener(v -> mConversationFragment.resendMessage(message)); } else if (!error && type == SENT) { viewHolder.resend_button.setVisibility(View.GONE); if (darkBackground) { @@ -365,9 +357,7 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie } else { boolean verified = false; if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL) { - final FingerprintStatus status = message.getConversation() - .getAccount().getAxolotlService().getFingerprintTrust( - message.getFingerprint()); + final FingerprintStatus status = message.getConversation().getAccount().getAxolotlService().getFingerprintTrust(message.getFingerprint()); if (status != null && status.isVerified()) { verified = true; } -- cgit v1.2.3