Minor code improvement

This commit is contained in:
Naveen 2023-08-17 16:45:03 +05:30
parent 0c01e607bb
commit c7a9f44663
No known key found for this signature in database
GPG Key ID: 0E155DAD31671DA3
1 changed files with 5 additions and 5 deletions

View File

@ -34,7 +34,7 @@ class AttachmentsAdapter(
val recyclerView: RecyclerView,
val onAttachmentsRemoved: () -> Unit,
val onReady: (() -> Unit)
) : ListAdapter<AttachmentSelection, AttachmentsAdapter.ViewHolder>(AttachmentDiffCallback()) {
) : ListAdapter<AttachmentSelection, AttachmentsAdapter.AttachmentsViewHolder>(AttachmentDiffCallback()) {
private val config = activity.config
private val resources = activity.resources
@ -47,7 +47,7 @@ class AttachmentsAdapter(
return getItem(position).viewType
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AttachmentsViewHolder {
val inflater = LayoutInflater.from(parent.context)
val binding = when (viewType) {
ATTACHMENT_DOCUMENT -> ItemAttachmentDocumentPreviewBinding.inflate(inflater, parent, false)
@ -56,10 +56,10 @@ class AttachmentsAdapter(
else -> throw IllegalArgumentException("Unknown view type: $viewType")
}
return ViewHolder(binding)
return AttachmentsViewHolder(binding)
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
override fun onBindViewHolder(holder: AttachmentsViewHolder, position: Int) {
val attachment = getItem(position)
holder.bindView { binding, _ ->
when (attachment.viewType) {
@ -193,7 +193,7 @@ class AttachmentsAdapter(
.into(binding.thumbnail)
}
inner class ViewHolder(val binding: ViewBinding) : RecyclerView.ViewHolder(binding.root) {
inner class AttachmentsViewHolder(val binding: ViewBinding) : RecyclerView.ViewHolder(binding.root) {
fun bindView(callback: (binding: ViewBinding, adapterPosition: Int) -> Unit) {
callback(binding, adapterPosition)
}