Remove unused click listeners and callbacks
This commit is contained in:
parent
fedc52adc3
commit
7c02e33bbd
2 changed files with 2 additions and 25 deletions
|
|
@ -916,7 +916,6 @@ class ThreadActivity : SimpleActivity() {
|
||||||
adapter = AttachmentsAdapter(
|
adapter = AttachmentsAdapter(
|
||||||
activity = this,
|
activity = this,
|
||||||
recyclerView = thread_attachments_recyclerview,
|
recyclerView = thread_attachments_recyclerview,
|
||||||
onItemClick = {},
|
|
||||||
onAttachmentsRemoved = {
|
onAttachmentsRemoved = {
|
||||||
thread_attachments_recyclerview.beGone()
|
thread_attachments_recyclerview.beGone()
|
||||||
checkSendMessageAvailability()
|
checkSendMessageAvailability()
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ import kotlinx.android.synthetic.main.item_remove_attachment_button.view.*
|
||||||
class AttachmentsAdapter(
|
class AttachmentsAdapter(
|
||||||
val activity: BaseSimpleActivity,
|
val activity: BaseSimpleActivity,
|
||||||
val recyclerView: RecyclerView,
|
val recyclerView: RecyclerView,
|
||||||
val onItemClick: (AttachmentSelection) -> Unit,
|
|
||||||
val onAttachmentsRemoved: () -> Unit,
|
val onAttachmentsRemoved: () -> Unit,
|
||||||
val onReady: (() -> Unit)
|
val onReady: (() -> Unit)
|
||||||
) : ListAdapter<AttachmentSelection, AttachmentsAdapter.ViewHolder>(AttachmentDiffCallback()) {
|
) : ListAdapter<AttachmentSelection, AttachmentsAdapter.ViewHolder>(AttachmentDiffCallback()) {
|
||||||
|
|
@ -85,7 +84,7 @@ class AttachmentsAdapter(
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
val attachment = getItem(position)
|
val attachment = getItem(position)
|
||||||
holder.bindView(attachment, allowSingleClick = true, allowLongClick = false) { view, position ->
|
holder.bindView() { view, _ ->
|
||||||
when (attachment.viewType) {
|
when (attachment.viewType) {
|
||||||
ATTACHMENT_DOCUMENT -> {
|
ATTACHMENT_DOCUMENT -> {
|
||||||
view.setupDocumentPreview(
|
view.setupDocumentPreview(
|
||||||
|
|
@ -189,32 +188,11 @@ class AttachmentsAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
open inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
open inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||||
fun bindView(
|
fun bindView(callback: (itemView: View, adapterPosition: Int) -> Unit): View {
|
||||||
any: AttachmentSelection,
|
|
||||||
allowSingleClick: Boolean,
|
|
||||||
allowLongClick: Boolean,
|
|
||||||
callback: (itemView: View, adapterPosition: Int) -> Unit
|
|
||||||
): View {
|
|
||||||
return itemView.apply {
|
return itemView.apply {
|
||||||
callback(this, adapterPosition)
|
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() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue