Remove unused click listeners and callbacks

This commit is contained in:
Naveen 2022-11-03 00:32:34 +05:30
parent fedc52adc3
commit 7c02e33bbd
2 changed files with 2 additions and 25 deletions

View File

@ -916,7 +916,6 @@ class ThreadActivity : SimpleActivity() {
adapter = AttachmentsAdapter(
activity = this,
recyclerView = thread_attachments_recyclerview,
onItemClick = {},
onAttachmentsRemoved = {
thread_attachments_recyclerview.beGone()
checkSendMessageAvailability()

View File

@ -32,7 +32,6 @@ import kotlinx.android.synthetic.main.item_remove_attachment_button.view.*
class AttachmentsAdapter(
val activity: BaseSimpleActivity,
val recyclerView: RecyclerView,
val onItemClick: (AttachmentSelection) -> Unit,
val onAttachmentsRemoved: () -> Unit,
val onReady: (() -> Unit)
) : ListAdapter<AttachmentSelection, AttachmentsAdapter.ViewHolder>(AttachmentDiffCallback()) {
@ -85,7 +84,7 @@ class AttachmentsAdapter(
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val attachment = getItem(position)
holder.bindView(attachment, allowSingleClick = true, allowLongClick = false) { view, position ->
holder.bindView() { view, _ ->
when (attachment.viewType) {
ATTACHMENT_DOCUMENT -> {
view.setupDocumentPreview(
@ -189,32 +188,11 @@ class AttachmentsAdapter(
}
open inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
fun bindView(
any: AttachmentSelection,
allowSingleClick: Boolean,
allowLongClick: Boolean,
callback: (itemView: View, adapterPosition: Int) -> Unit
): View {
fun bindView(callback: (itemView: View, adapterPosition: Int) -> Unit): View {
return itemView.apply {
callback(this, adapterPosition)
if (allowSingleClick) {
setOnClickListener { viewClicked(any) }
setOnLongClickListener { if (allowLongClick) viewLongClicked() else viewClicked(any); true }
} else {
setOnClickListener(null)
setOnLongClickListener(null)
}
}
}
private fun viewClicked(any: AttachmentSelection) {
onItemClick.invoke(any)
}
private fun viewLongClicked() {
}
}
}