refactor attachment deletion
This commit is contained in:
parent
7af40cf7f5
commit
9ec0824100
1 changed files with 10 additions and 10 deletions
|
|
@ -673,11 +673,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
loadAttachmentPreview(attachmentView, compressedUri)
|
||||
} else {
|
||||
toast(R.string.compress_error)
|
||||
thread_attachments_wrapper.removeView(attachmentView)
|
||||
attachmentSelections.remove(originalUriString)
|
||||
if (attachmentSelections.isEmpty()) {
|
||||
thread_attachments_holder.beGone()
|
||||
}
|
||||
removeAttachment(attachmentView, originalUriString)
|
||||
}
|
||||
checkSendMessageAvailability()
|
||||
attachmentView.thread_attachment_progress.beGone()
|
||||
|
|
@ -691,11 +687,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
val attachmentView = layoutInflater.inflate(R.layout.item_attachment, null).apply {
|
||||
thread_attachments_wrapper.addView(this)
|
||||
thread_remove_attachment.setOnClickListener {
|
||||
thread_attachments_wrapper.removeView(this)
|
||||
attachmentSelections.remove(originalUri)
|
||||
if (attachmentSelections.isEmpty()) {
|
||||
thread_attachments_holder.beGone()
|
||||
}
|
||||
removeAttachment(this, originalUri)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -734,6 +726,14 @@ class ThreadActivity : SimpleActivity() {
|
|||
.into(attachmentView.thread_attachment_preview)
|
||||
}
|
||||
|
||||
private fun removeAttachment(attachmentView: View, originalUri: String) {
|
||||
thread_attachments_wrapper.removeView(attachmentView)
|
||||
attachmentSelections.remove(originalUri)
|
||||
if (attachmentSelections.isEmpty()) {
|
||||
thread_attachments_holder.beGone()
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkSendMessageAvailability() {
|
||||
if (thread_type_message.text.isNotEmpty() || (attachmentSelections.isNotEmpty() && !attachmentSelections.values.any { it.isPending })) {
|
||||
thread_send_message.isClickable = true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue