Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0b0a8d5d authored by narinder Rana's avatar narinder Rana
Browse files

check on bindView function

parent 561821d4
Loading
Loading
Loading
Loading
Loading
+20 −10
Original line number Diff line number Diff line
@@ -47,10 +47,13 @@ class MessageListAdapter internal constructor(
    private val forwardedIcon: Drawable = theme.resolveDrawableAttribute(R.attr.messageListForwarded)
    private val answeredIcon: Drawable = theme.resolveDrawableAttribute(R.attr.messageListAnswered)
    private val forwardedAnsweredIcon: Drawable = theme.resolveDrawableAttribute(R.attr.messageListAnsweredForwarded)
    private val activeItemBackgroundColor: Int = theme.resolveColorAttribute(R.attr.messageListActiveItemBackgroundColor)
    private val selectedItemBackgroundColor: Int = theme.resolveColorAttribute(R.attr.messageListSelectedBackgroundColor)
    private val activeItemBackgroundColor: Int =
        theme.resolveColorAttribute(R.attr.messageListActiveItemBackgroundColor)
    private val selectedItemBackgroundColor: Int =
        theme.resolveColorAttribute(R.attr.messageListSelectedBackgroundColor)
    private val readItemBackgroundColor: Int = theme.resolveColorAttribute(R.attr.messageListReadItemBackgroundColor)
    private val unreadItemBackgroundColor: Int = theme.resolveColorAttribute(R.attr.messageListUnreadItemBackgroundColor)
    private val unreadItemBackgroundColor: Int =
        theme.resolveColorAttribute(R.attr.messageListUnreadItemBackgroundColor)

    var messages: List<MessageListItem> = emptyList()
        set(value) {
@@ -96,19 +99,15 @@ class MessageListAdapter internal constructor(

    override fun getItem(position: Int): MessageListItem = messages[position]



    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        val message = getItem(position)
        val view: View = convertView ?: newView(parent)



        if(!message.displayName.trim().toString().equals(res.getString(R.string.general_no_subject))
            && !message.subject?.trim().toString().equals(res.getString(R.string.general_no_subject))){

        bindView(view, context, message)
        }


        return view
    }
@@ -130,7 +129,10 @@ class MessageListAdapter internal constructor(
        holder.preview.setLines(max(appearance.previewLines, 0))
        appearance.fontSizes.setViewTextSize(holder.displayName, appearance.fontSizes.messageListSender)
        appearance.fontSizes.setViewTextSize(holder.preview, appearance.fontSizes.messageListPreview)
        appearance.fontSizes.setViewTextSize(holder.threadCount, appearance.fontSizes.messageListSubject) // thread count is next to subject
        appearance.fontSizes.setViewTextSize(
            holder.threadCount,
            appearance.fontSizes.messageListSubject
        ) // thread count is next to subject

        holder.flagged.isVisible = false
        holder.flagged.tag = holder
@@ -142,6 +144,14 @@ class MessageListAdapter internal constructor(
    }

    private fun bindView(view: View, context: Context, message: MessageListItem) {

        if (message.displayName.trim().toString().equals(res.getString(R.string.general_no_subject))
            && message.subject?.trim().toString().equals(res.getString(R.string.general_no_subject))
        ) {
            view.setVisibility(View.GONE)
            return
        }

        val isSelected = selected.contains(message.uniqueId)
        val isActive = isActiveMessage(message)