From d9a94a7b9f499cd9494930cf221360af0fe06436 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Fri, 8 Sep 2023 20:45:33 -0500 Subject: [PATCH] If we try to render when expecting removal, don't crash Show blank instead? Should remove soon... --- .../siacs/conversations/entities/Conversation.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index c33913b2a..a0a94c7e7 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -1778,7 +1778,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl @Override public void bind(Item note) { - binding.message.setText(note.el.getContent()); + binding.message.setText(note != null && note.el != null ? note.el.getContent() : ""); String type = note.el.getAttribute("type"); if (type != null && type.equals("error")) { @@ -2627,6 +2627,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl protected CommandPageBinding mBinding = null; protected IqPacket response = null; protected Element responseElement = null; + protected boolean expectingRemoval = false; protected List reported = null; protected SparseArray items = new SparseArray<>(); protected XmppConnectionService xmppConnectionService; @@ -2758,6 +2759,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl break; } if (scheme.equals("xmpp")) { + expectingRemoval = true; final Intent intent = new Intent(getView().getContext(), UriHandlerActivity.class); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); @@ -2790,6 +2792,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl xmppConnectionService.archiveConversation(Conversation.this); } + expectingRemoval = true; removeSession(this); return; } @@ -3007,7 +3010,12 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl return new ProgressBarViewHolder(binding); } default: - throw new IllegalArgumentException("Unknown viewType: " + viewType + " based on: " + response); + if (expectingRemoval) { + CommandNoteBinding binding = DataBindingUtil.inflate(LayoutInflater.from(container.getContext()), R.layout.command_note, container, false); + return new NoteViewHolder(binding); + } + + throw new IllegalArgumentException("Unknown viewType: " + viewType + " based on: " + response + ", " + responseElement + ", " + expectingRemoval); } } -- 2.45.2