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)
|
loadAttachmentPreview(attachmentView, compressedUri)
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.compress_error)
|
toast(R.string.compress_error)
|
||||||
thread_attachments_wrapper.removeView(attachmentView)
|
removeAttachment(attachmentView, originalUriString)
|
||||||
attachmentSelections.remove(originalUriString)
|
|
||||||
if (attachmentSelections.isEmpty()) {
|
|
||||||
thread_attachments_holder.beGone()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
checkSendMessageAvailability()
|
checkSendMessageAvailability()
|
||||||
attachmentView.thread_attachment_progress.beGone()
|
attachmentView.thread_attachment_progress.beGone()
|
||||||
|
|
@ -691,11 +687,7 @@ class ThreadActivity : SimpleActivity() {
|
||||||
val attachmentView = layoutInflater.inflate(R.layout.item_attachment, null).apply {
|
val attachmentView = layoutInflater.inflate(R.layout.item_attachment, null).apply {
|
||||||
thread_attachments_wrapper.addView(this)
|
thread_attachments_wrapper.addView(this)
|
||||||
thread_remove_attachment.setOnClickListener {
|
thread_remove_attachment.setOnClickListener {
|
||||||
thread_attachments_wrapper.removeView(this)
|
removeAttachment(this, originalUri)
|
||||||
attachmentSelections.remove(originalUri)
|
|
||||||
if (attachmentSelections.isEmpty()) {
|
|
||||||
thread_attachments_holder.beGone()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -734,6 +726,14 @@ class ThreadActivity : SimpleActivity() {
|
||||||
.into(attachmentView.thread_attachment_preview)
|
.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() {
|
private fun checkSendMessageAvailability() {
|
||||||
if (thread_type_message.text.isNotEmpty() || (attachmentSelections.isNotEmpty() && !attachmentSelections.values.any { it.isPending })) {
|
if (thread_type_message.text.isNotEmpty() || (attachmentSelections.isNotEmpty() && !attachmentSelections.values.any { it.isPending })) {
|
||||||
thread_send_message.isClickable = true
|
thread_send_message.isClickable = true
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue