Loading presentation/src/main/java/com/moez/QKSMS/common/base/QkRealmAdapter.kt +10 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import io.realm.RealmList import io.realm.RealmModel import io.realm.RealmRecyclerViewAdapter import io.realm.RealmResults import timber.log.Timber abstract class QkRealmAdapter<T : RealmModel> : RealmRecyclerViewAdapter<T, QkViewHolder>(null, true) { Loading Loading @@ -79,6 +80,15 @@ abstract class QkRealmAdapter<T : RealmModel> : RealmRecyclerViewAdapter<T, QkVi notifyDataSetChanged() } override fun getItem(index: Int): T? { if (index < 0) { Timber.w("Only indexes >= 0 are allowed. Input was: $index") return null } return super.getItem(index) } override fun updateData(data: OrderedRealmCollection<T>?) { if (getData() === data) return Loading presentation/src/main/java/com/moez/QKSMS/feature/blocked/BlockedAdapter.kt +2 −2 Original line number Diff line number Diff line Loading @@ -36,14 +36,14 @@ class BlockedAdapter @Inject constructor() : QkRealmAdapter<Conversation>() { val view = LayoutInflater.from(parent.context).inflate(R.layout.blocked_list_item, parent, false) return QkViewHolder(view).apply { view.setOnClickListener { val conversation = getItem(adapterPosition)!! val conversation = getItem(adapterPosition) ?: return@setOnClickListener unblock.onNext(conversation.id) } } } override fun onBindViewHolder(holder: QkViewHolder, position: Int) { val conversation = getItem(position)!! val conversation = getItem(position) ?: return val view = holder.containerView view.avatars.contacts = conversation.recipients Loading presentation/src/main/java/com/moez/QKSMS/feature/compose/MessagesAdapter.kt +4 −4 Original line number Diff line number Diff line Loading @@ -151,7 +151,7 @@ class MessagesAdapter @Inject constructor( return QkViewHolder(view).apply { view.setOnClickListener { val message = getItem(adapterPosition)!! val message = getItem(adapterPosition) ?: return@setOnClickListener when (toggleSelection(message.id, false)) { true -> view.isActivated = isSelected(message.id) false -> { Loading @@ -162,7 +162,7 @@ class MessagesAdapter @Inject constructor( } } view.setOnLongClickListener { val message = getItem(adapterPosition)!! val message = getItem(adapterPosition) ?: return@setOnLongClickListener true toggleSelection(message.id) view.isActivated = isSelected(message.id) true Loading @@ -171,7 +171,7 @@ class MessagesAdapter @Inject constructor( } override fun onBindViewHolder(viewHolder: QkViewHolder, position: Int) { val message = getItem(position)!! val message = getItem(position) ?: return val previous = if (position == 0) null else getItem(position - 1) val next = if (position == itemCount - 1) null else getItem(position + 1) val view = viewHolder.containerView Loading Loading @@ -296,7 +296,7 @@ class MessagesAdapter @Inject constructor( } override fun getItemViewType(position: Int): Int { val message = getItem(position)!! val message = getItem(position) ?: return -1 return when (message.isMe()) { true -> VIEW_TYPE_MESSAGE_OUT false -> VIEW_TYPE_MESSAGE_IN Loading presentation/src/main/java/com/moez/QKSMS/feature/conversationinfo/ConversationMediaAdapter.kt +2 −2 Original line number Diff line number Diff line Loading @@ -42,14 +42,14 @@ class ConversationMediaAdapter @Inject constructor( val view = inflater.inflate(R.layout.conversation_media_list_item, parent, false) return QkViewHolder(view).apply { view.thumbnail.setOnClickListener { val part = getItem(adapterPosition)!! val part = getItem(adapterPosition) ?: return@setOnClickListener navigator.showMedia(part.id) } } } override fun onBindViewHolder(holder: QkViewHolder, position: Int) { val part = getItem(position)!! val part = getItem(position) ?: return val view = holder.containerView GlideApp.with(context) Loading presentation/src/main/java/com/moez/QKSMS/feature/conversationinfo/ConversationRecipientAdapter.kt +2 −2 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ class ConversationRecipientAdapter @Inject constructor( val view = layoutInflater.inflate(R.layout.conversation_recipient_list_item, parent, false) return QkViewHolder(view).apply { view.setOnClickListener { val recipient = getItem(adapterPosition)!! val recipient = getItem(adapterPosition) ?: return@setOnClickListener if (recipient.contact == null) { navigator.addContact(recipient.address) } else { Loading @@ -55,7 +55,7 @@ class ConversationRecipientAdapter @Inject constructor( } override fun onBindViewHolder(holder: QkViewHolder, position: Int) { val recipient = getItem(position)!! val recipient = getItem(position) ?: return val view = holder.containerView view.avatar.threadId = threadId Loading Loading
presentation/src/main/java/com/moez/QKSMS/common/base/QkRealmAdapter.kt +10 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import io.realm.RealmList import io.realm.RealmModel import io.realm.RealmRecyclerViewAdapter import io.realm.RealmResults import timber.log.Timber abstract class QkRealmAdapter<T : RealmModel> : RealmRecyclerViewAdapter<T, QkViewHolder>(null, true) { Loading Loading @@ -79,6 +80,15 @@ abstract class QkRealmAdapter<T : RealmModel> : RealmRecyclerViewAdapter<T, QkVi notifyDataSetChanged() } override fun getItem(index: Int): T? { if (index < 0) { Timber.w("Only indexes >= 0 are allowed. Input was: $index") return null } return super.getItem(index) } override fun updateData(data: OrderedRealmCollection<T>?) { if (getData() === data) return Loading
presentation/src/main/java/com/moez/QKSMS/feature/blocked/BlockedAdapter.kt +2 −2 Original line number Diff line number Diff line Loading @@ -36,14 +36,14 @@ class BlockedAdapter @Inject constructor() : QkRealmAdapter<Conversation>() { val view = LayoutInflater.from(parent.context).inflate(R.layout.blocked_list_item, parent, false) return QkViewHolder(view).apply { view.setOnClickListener { val conversation = getItem(adapterPosition)!! val conversation = getItem(adapterPosition) ?: return@setOnClickListener unblock.onNext(conversation.id) } } } override fun onBindViewHolder(holder: QkViewHolder, position: Int) { val conversation = getItem(position)!! val conversation = getItem(position) ?: return val view = holder.containerView view.avatars.contacts = conversation.recipients Loading
presentation/src/main/java/com/moez/QKSMS/feature/compose/MessagesAdapter.kt +4 −4 Original line number Diff line number Diff line Loading @@ -151,7 +151,7 @@ class MessagesAdapter @Inject constructor( return QkViewHolder(view).apply { view.setOnClickListener { val message = getItem(adapterPosition)!! val message = getItem(adapterPosition) ?: return@setOnClickListener when (toggleSelection(message.id, false)) { true -> view.isActivated = isSelected(message.id) false -> { Loading @@ -162,7 +162,7 @@ class MessagesAdapter @Inject constructor( } } view.setOnLongClickListener { val message = getItem(adapterPosition)!! val message = getItem(adapterPosition) ?: return@setOnLongClickListener true toggleSelection(message.id) view.isActivated = isSelected(message.id) true Loading @@ -171,7 +171,7 @@ class MessagesAdapter @Inject constructor( } override fun onBindViewHolder(viewHolder: QkViewHolder, position: Int) { val message = getItem(position)!! val message = getItem(position) ?: return val previous = if (position == 0) null else getItem(position - 1) val next = if (position == itemCount - 1) null else getItem(position + 1) val view = viewHolder.containerView Loading Loading @@ -296,7 +296,7 @@ class MessagesAdapter @Inject constructor( } override fun getItemViewType(position: Int): Int { val message = getItem(position)!! val message = getItem(position) ?: return -1 return when (message.isMe()) { true -> VIEW_TYPE_MESSAGE_OUT false -> VIEW_TYPE_MESSAGE_IN Loading
presentation/src/main/java/com/moez/QKSMS/feature/conversationinfo/ConversationMediaAdapter.kt +2 −2 Original line number Diff line number Diff line Loading @@ -42,14 +42,14 @@ class ConversationMediaAdapter @Inject constructor( val view = inflater.inflate(R.layout.conversation_media_list_item, parent, false) return QkViewHolder(view).apply { view.thumbnail.setOnClickListener { val part = getItem(adapterPosition)!! val part = getItem(adapterPosition) ?: return@setOnClickListener navigator.showMedia(part.id) } } } override fun onBindViewHolder(holder: QkViewHolder, position: Int) { val part = getItem(position)!! val part = getItem(position) ?: return val view = holder.containerView GlideApp.with(context) Loading
presentation/src/main/java/com/moez/QKSMS/feature/conversationinfo/ConversationRecipientAdapter.kt +2 −2 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ class ConversationRecipientAdapter @Inject constructor( val view = layoutInflater.inflate(R.layout.conversation_recipient_list_item, parent, false) return QkViewHolder(view).apply { view.setOnClickListener { val recipient = getItem(adapterPosition)!! val recipient = getItem(adapterPosition) ?: return@setOnClickListener if (recipient.contact == null) { navigator.addContact(recipient.address) } else { Loading @@ -55,7 +55,7 @@ class ConversationRecipientAdapter @Inject constructor( } override fun onBindViewHolder(holder: QkViewHolder, position: Int) { val recipient = getItem(position)!! val recipient = getItem(position) ?: return val view = holder.containerView view.avatar.threadId = threadId Loading