mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-06-05 21:49:22 +02:00
Remove unused click listeners and callbacks
This commit is contained in:
@@ -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() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user