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