Fix some crashes
This commit is contained in:
parent
18bf9856fe
commit
2e70808bbd
|
@ -39,13 +39,12 @@ class PreviewUrlView @JvmOverloads constructor(
|
|||
defStyleAttr: Int = 0
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr), View.OnClickListener {
|
||||
|
||||
private val views: UrlPreviewBinding
|
||||
private lateinit var views: UrlPreviewBinding
|
||||
|
||||
var delegate: TimelineEventController.PreviewUrlCallback? = null
|
||||
|
||||
init {
|
||||
setupView()
|
||||
views = UrlPreviewBinding.bind(this)
|
||||
}
|
||||
|
||||
private var state: PreviewUrlUiState = PreviewUrlUiState.Unknown
|
||||
|
@ -92,6 +91,7 @@ class PreviewUrlView @JvmOverloads constructor(
|
|||
|
||||
private fun setupView() {
|
||||
inflate(context, R.layout.url_preview, this)
|
||||
views = UrlPreviewBinding.bind(this)
|
||||
|
||||
setOnClickListener(this)
|
||||
views.urlPreviewClose.setOnClickListener { onCloseClick() }
|
||||
|
|
|
@ -20,55 +20,54 @@ import android.content.Context
|
|||
import android.content.res.ColorStateList
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.util.AttributeSet
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.view.isVisible
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.extensions.setTextOrHide
|
||||
import im.vector.app.databinding.ItemSignoutActionBinding
|
||||
import im.vector.app.features.themes.ThemeUtils
|
||||
|
||||
class SignOutBottomSheetActionButton @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
||||
) : LinearLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
private val actionIconImageView: ImageView
|
||||
private val actionTitleText: TextView
|
||||
private val views: ItemSignoutActionBinding
|
||||
|
||||
var action: (() -> Unit)? = null
|
||||
|
||||
var title: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
actionTitleText.setTextOrHide(value)
|
||||
views.actionTitleText.setTextOrHide(value)
|
||||
}
|
||||
|
||||
var leftIcon: Drawable? = null
|
||||
set(value) {
|
||||
field = value
|
||||
if (value == null) {
|
||||
actionIconImageView.isVisible = false
|
||||
actionIconImageView.setImageDrawable(null)
|
||||
views.actionIconImageView.isVisible = false
|
||||
views.actionIconImageView.setImageDrawable(null)
|
||||
} else {
|
||||
actionIconImageView.isVisible = true
|
||||
actionIconImageView.setImageDrawable(value)
|
||||
views.actionIconImageView.isVisible = true
|
||||
views.actionIconImageView.setImageDrawable(value)
|
||||
}
|
||||
}
|
||||
|
||||
var tint: Int? = null
|
||||
set(value) {
|
||||
field = value
|
||||
actionIconImageView.imageTintList = value?.let { ColorStateList.valueOf(value) }
|
||||
views.actionIconImageView.imageTintList = value?.let { ColorStateList.valueOf(value) }
|
||||
}
|
||||
|
||||
var textColor: Int? = null
|
||||
set(value) {
|
||||
field = value
|
||||
textColor?.let { actionTitleText.setTextColor(it) }
|
||||
textColor?.let { views.actionTitleText.setTextColor(it) }
|
||||
}
|
||||
|
||||
init {
|
||||
inflate(context, R.layout.item_signout_action, this)
|
||||
views = ItemSignoutActionBinding.bind(this)
|
||||
|
||||
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.SignOutBottomSheetActionButton, 0, 0)
|
||||
title = typedArray.getString(R.styleable.SignOutBottomSheetActionButton_actionTitle) ?: ""
|
||||
|
@ -76,9 +75,6 @@ class SignOutBottomSheetActionButton @JvmOverloads constructor(
|
|||
tint = typedArray.getColor(R.styleable.SignOutBottomSheetActionButton_iconTint, ThemeUtils.getColor(context, android.R.attr.textColor))
|
||||
textColor = typedArray.getColor(R.styleable.SignOutBottomSheetActionButton_textColor, ThemeUtils.getColor(context, android.R.attr.textColor))
|
||||
|
||||
actionIconImageView = findViewById(R.id.actionIconImageView)
|
||||
actionTitleText = findViewById(R.id.actionTitleText)
|
||||
|
||||
typedArray.recycle()
|
||||
|
||||
setOnClickListener {
|
||||
|
|
Loading…
Reference in New Issue