diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/url/PreviewUrlView.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/url/PreviewUrlView.kt index 9f228a46db..a36b1281ba 100755 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/url/PreviewUrlView.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/url/PreviewUrlView.kt @@ -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() } diff --git a/vector/src/main/java/im/vector/app/features/workers/signout/SignOutBottomSheetActionButton.kt b/vector/src/main/java/im/vector/app/features/workers/signout/SignOutBottomSheetActionButton.kt index aa4f1f0374..8a5b4a00ac 100644 --- a/vector/src/main/java/im/vector/app/features/workers/signout/SignOutBottomSheetActionButton.kt +++ b/vector/src/main/java/im/vector/app/features/workers/signout/SignOutBottomSheetActionButton.kt @@ -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 {