From 1f707141a698982b755db574c86a2d7d6ab3563c Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Fri, 2 Apr 2021 21:44:01 -0400 Subject: [PATCH] Fix settings tracking crash --- .../widget/preference/LoginPreference.kt | 17 +++++++++-------- .../main/res/layout/pref_widget_imageview.xml | 4 +--- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginPreference.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginPreference.kt index e6c7578704..a7050f5633 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginPreference.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginPreference.kt @@ -4,10 +4,10 @@ import android.content.Context import android.content.res.ColorStateList import android.graphics.Color import android.util.AttributeSet +import android.widget.ImageView import androidx.preference.Preference import androidx.preference.PreferenceViewHolder import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.databinding.PrefWidgetImageviewBinding class LoginPreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : Preference(context, attrs) { @@ -18,14 +18,15 @@ class LoginPreference @JvmOverloads constructor(context: Context, attrs: Attribu override fun onBindViewHolder(holder: PreferenceViewHolder) { super.onBindViewHolder(holder) - val binding = PrefWidgetImageviewBinding.bind(holder.itemView) - binding.imageView.setImageResource( - if (getPersistedString("").isNullOrEmpty()) android.R.color.transparent - else R.drawable.ic_done_24dp - ) - binding.imageView.imageTintList = - ColorStateList.valueOf(Color.parseColor("#FF4CAF50")) + (holder.findViewById(R.id.image_view) as? ImageView)?.let { imageView -> + imageView.setImageResource( + if (getPersistedString("").isNullOrEmpty()) android.R.color.transparent + else R.drawable.ic_done_24dp + ) + imageView.imageTintList = + ColorStateList.valueOf(Color.parseColor("#FF4CAF50")) + } } public override fun notifyChanged() { diff --git a/app/src/main/res/layout/pref_widget_imageview.xml b/app/src/main/res/layout/pref_widget_imageview.xml index 78381c96cc..fd62a09c2d 100644 --- a/app/src/main/res/layout/pref_widget_imageview.xml +++ b/app/src/main/res/layout/pref_widget_imageview.xml @@ -2,6 +2,4 @@ - - \ No newline at end of file + android:layout_height="wrap_content"/> \ No newline at end of file