From 634ec8f86c6dc58d3059510d69c01178616c1c9b Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 18 Jun 2024 20:30:55 +0930 Subject: [PATCH] Remove unused ContactListAdapter --- .../conversation/start/ContactListAdapter.kt | 103 ------------------ 1 file changed, 103 deletions(-) delete mode 100644 app/src/main/java/org/thoughtcrime/securesms/conversation/start/ContactListAdapter.kt diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/start/ContactListAdapter.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/start/ContactListAdapter.kt deleted file mode 100644 index df2bc1c371..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/start/ContactListAdapter.kt +++ /dev/null @@ -1,103 +0,0 @@ -package org.thoughtcrime.securesms.conversation.start - -import android.content.Context -import android.view.LayoutInflater -import android.view.ViewGroup -import androidx.recyclerview.widget.RecyclerView -import network.loki.messenger.databinding.ContactSectionHeaderBinding -import network.loki.messenger.databinding.ViewContactBinding -import org.session.libsession.utilities.recipients.Recipient -import org.thoughtcrime.securesms.mms.GlideRequests - -sealed class ContactListItem { - class Header(val name: String) : ContactListItem() - class Contact(val recipient: Recipient, val displayName: String) : ContactListItem() -} - -class ContactListAdapter( - private val context: Context, - private val glide: GlideRequests, - private val listener: (Recipient) -> Unit -) : RecyclerView.Adapter() { - var items = listOf() - set(value) { - field = value - notifyDataSetChanged() - } - - private object ViewType { - const val Contact = 0 - const val Header = 1 - } - - class ContactViewHolder(private val binding: ViewContactBinding) : RecyclerView.ViewHolder(binding.root) { - fun bind(contact: ContactListItem.Contact, glide: GlideRequests, listener: (Recipient) -> Unit) { - binding.profilePictureView.update(contact.recipient) - binding.nameTextView.text = contact.displayName - binding.root.setOnClickListener { listener(contact.recipient) } - - // TODO: When we implement deleting contacts (hide might be safest for now) then probably set a long-click listener here w/ something like: - /* - binding.root.setOnLongClickListener { - Log.w("[ACL]", "Long clicked on contact ${contact.recipient.name}") - binding.contentView.context.showSessionDialog { - title("Delete Contact") - text("Are you sure you want to delete this contact?") - button(R.string.delete) { - val contacts = configFactory.contacts ?: return - contacts.upsertContact(contact.recipient.address.serialize()) { priority = PRIORITY_HIDDEN } - ConfigurationMessageUtilities.forceSyncConfigurationNowIfNeeded(context) - endActionMode() - } - cancelButton(::endActionMode) - } - true - } - */ - } - - fun unbind() { binding.profilePictureView.recycle() } - } - - class HeaderViewHolder( - private val binding: ContactSectionHeaderBinding - ) : RecyclerView.ViewHolder(binding.root) { - fun bind(item: ContactListItem.Header) { - with(binding) { - label.text = item.name - } - } - } - - override fun getItemCount(): Int { return items.size } - - override fun onViewRecycled(holder: RecyclerView.ViewHolder) { - super.onViewRecycled(holder) - if (holder is ContactViewHolder) { holder.unbind() } - } - - override fun getItemViewType(position: Int): Int { - return when (items[position]) { - is ContactListItem.Header -> ViewType.Header - else -> ViewType.Contact - } - } - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { - return if (viewType == ViewType.Contact) { - ContactViewHolder(ViewContactBinding.inflate(LayoutInflater.from(context), parent, false)) - } else { - HeaderViewHolder(ContactSectionHeaderBinding.inflate(LayoutInflater.from(context), parent, false)) - } - } - - override fun onBindViewHolder(viewHolder: RecyclerView.ViewHolder, position: Int) { - val item = items[position] - if (viewHolder is ContactViewHolder) { - viewHolder.bind(item as ContactListItem.Contact, glide, listener) - } else if (viewHolder is HeaderViewHolder) { - viewHolder.bind(item as ContactListItem.Header) - } - } - -}