override fun setCellData()

in azure-communication-ui/calling/src/main/java/com/azure/android/communication/ui/calling/utilities/BottomCellActionViewHolder.kt [29:114]


    override fun setCellData(bottomCellItem: BottomCellItem) {
        super.setCellData(bottomCellItem)
        itemView.isEnabled = bottomCellItem.isEnabled
        itemView.alpha = if (bottomCellItem.isEnabled) 1.0f else 0.5f

        topDivider.isVisible = bottomCellItem.showTopDivider

        if (bottomCellItem.itemType == BottomCellItemType.BottomMenuActionNoIcon) {
            accessoryImageView.contentDescription = bottomCellItem.accessoryImageDescription
            accessoryImageView.visibility =
                if (bottomCellItem.isChecked == true) View.VISIBLE else View.INVISIBLE
            avatarView.visibility = View.GONE
            avatarViewForImage.visibility = View.GONE
            showMoreImageView.visibility = View.GONE
            additionalText.visibility = View.GONE
            switchCompat.visibility = View.GONE
            return
        }

        if (bottomCellItem.itemType == BottomCellItemType.BottomMenuTitle) {
            // Exit with early return because setting the title is the only thing we need to do
            return
        }
        if (bottomCellItem.icon == null) {
            ViewCompat.setAccessibilityDelegate(
                itemView,
                object : AccessibilityDelegateCompat() {
                    override fun onInitializeAccessibilityNodeInfo(
                        host: View,
                        info: AccessibilityNodeInfoCompat,
                    ) {
                        super.onInitializeAccessibilityNodeInfo(host, info)
                        info.removeAction(AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_CLICK)
                        info.isClickable = false
                    }
                }
            )

            if (bottomCellItem.title == itemView.context.getString(R.string.azure_communication_ui_calling_view_participant_drawer_unnamed)) {
                avatarView.name = ""
            } else {
                avatarView.name = bottomCellItem.title ?: ""
            }

            // Hide icon and avatarViewForImage. Show avatar for initials.
            avatarView.visibility = View.VISIBLE
            avatarViewForImage.visibility = View.GONE
            bottomCellItem.participantViewData?.let { participantViewData ->
                participantViewData.avatarBitmap?.let {
                    // Use avatarViewForImage to display image.
                    // Due to avatarView.setImageResource(0) is not removing the previous image,
                    // if ViewHolder is re-used for another item, the previous image will be shown.
                    avatarViewForImage.setImageBitmap(it)
                    avatarViewForImage.adjustViewBounds = true
                    avatarViewForImage.scaleType = participantViewData.scaleType
                    avatarViewForImage.visibility = View.VISIBLE
                    avatarView.visibility = View.GONE
                }
            }
        } else {
            avatarView.visibility = View.GONE
            avatarViewForImage.visibility = View.GONE
        }
        if (bottomCellItem.accessoryImage != null) {
            accessoryImageView.setImageDrawable(bottomCellItem.accessoryImage)
        }
        if (bottomCellItem.accessoryColor != null) {
            accessoryImageView.setColorFilter(
                ContextCompat.getColor(
                    itemView.context,
                    bottomCellItem.accessoryColor!!
                )
            )
        }
        accessoryImageView.contentDescription = bottomCellItem.accessoryImageDescription
        accessoryImageView.visibility =
            if (isAccessoryImageViewable(bottomCellItem)) View.VISIBLE else View.INVISIBLE
        additionalText.visibility = if (bottomCellItem.isOnHold == true) View.VISIBLE else View.INVISIBLE
        showMoreImageView.visibility = if (bottomCellItem.showRightArrow) View.VISIBLE else View.INVISIBLE
        switchCompat.visibility = if (bottomCellItem.showToggleButton) View.VISIBLE else View.GONE
        switchCompat.isEnabled = bottomCellItem.isEnabled
        switchCompat.isChecked = bottomCellItem.isToggleButtonOn
        switchCompat.setOnClickListener {
            bottomCellItem.toggleButtonAction?.invoke(switchCompat, switchCompat.isChecked)
        }
    }