Fix some lifecycle-related crashes.

This commit is contained in:
Greyson Parrelli
2022-06-16 11:41:56 -04:00
parent 69e2a138d9
commit 673a8f540b
3 changed files with 24 additions and 5 deletions

View File

@@ -814,7 +814,9 @@ public class ConversationFragment extends LoggingFragment implements Multiselect
items.add(new ActionItem(R.drawable.ic_reply_24_tinted, getResources().getString(R.string.conversation_selection__menu_reply), () -> {
maybeShowSwipeToReplyTooltip();
handleReplyMessage(getSelectedConversationMessage());
actionMode.finish();
if (actionMode != null) {
actionMode.finish();
}
}));
}
@@ -825,28 +827,36 @@ public class ConversationFragment extends LoggingFragment implements Multiselect
if (menuState.shouldShowSaveAttachmentAction()) {
items.add(new ActionItem(R.drawable.ic_save_24_tinted, getResources().getString(R.string.conversation_selection__menu_save), () -> {
handleSaveAttachment((MediaMmsMessageRecord) getSelectedConversationMessage().getMessageRecord());
actionMode.finish();
if (actionMode != null) {
actionMode.finish();
}
}));
}
if (menuState.shouldShowCopyAction()) {
items.add(new ActionItem(R.drawable.ic_copy_24_tinted, getResources().getString(R.string.conversation_selection__menu_copy), () -> {
handleCopyMessage(selectedParts);
actionMode.finish();
if (actionMode != null) {
actionMode.finish();
}
}));
}
if (menuState.shouldShowDetailsAction()) {
items.add(new ActionItem(R.drawable.ic_info_tinted_24, getResources().getString(R.string.conversation_selection__menu_message_details), () -> {
handleDisplayDetails(getSelectedConversationMessage());
actionMode.finish();
if (actionMode != null) {
actionMode.finish();
}
}));
}
if (menuState.shouldShowDeleteAction()) {
items.add(new ActionItem(R.drawable.ic_delete_tinted_24, getResources().getString(R.string.conversation_selection__menu_delete), () -> {
handleDeleteMessages(selectedParts);
actionMode.finish();
if (actionMode != null) {
actionMode.finish();
}
}));
}

View File

@@ -2171,6 +2171,11 @@ public class ConversationParentFragment extends Fragment
sendButton.setOnClickListener(sendButtonListener);
sendButton.setEnabled(true);
sendButton.addOnSelectionChangedListener((newMessageSendType, manuallySelected) -> {
if (getContext() == null) {
Log.w(TAG, "onSelectionChanged called in detached state. Ignoring.");
return;
}
calculateCharactersRemaining();
updateLinkPreviewState();
linkPreviewViewModel.onTransportChanged(newMessageSendType.usesSmsTransport());

View File

@@ -82,6 +82,10 @@ class CircularProgressMaterialButton @JvmOverloads constructor(
}
private fun transformTo(state: State, animate: Boolean) {
if (!isAttachedToWindow) {
return
}
if (state == currentState && state == requestedState) {
return
}