Fix settings tracking crash

This commit is contained in:
Jays2Kings 2021-04-02 21:44:01 -04:00
parent c43d5f01fa
commit 1f707141a6
2 changed files with 10 additions and 11 deletions

View File

@ -4,10 +4,10 @@ import android.content.Context
import android.content.res.ColorStateList import android.content.res.ColorStateList
import android.graphics.Color import android.graphics.Color
import android.util.AttributeSet import android.util.AttributeSet
import android.widget.ImageView
import androidx.preference.Preference import androidx.preference.Preference
import androidx.preference.PreferenceViewHolder import androidx.preference.PreferenceViewHolder
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.databinding.PrefWidgetImageviewBinding
class LoginPreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : class LoginPreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
Preference(context, attrs) { Preference(context, attrs) {
@ -18,15 +18,16 @@ class LoginPreference @JvmOverloads constructor(context: Context, attrs: Attribu
override fun onBindViewHolder(holder: PreferenceViewHolder) { override fun onBindViewHolder(holder: PreferenceViewHolder) {
super.onBindViewHolder(holder) super.onBindViewHolder(holder)
val binding = PrefWidgetImageviewBinding.bind(holder.itemView)
binding.imageView.setImageResource( (holder.findViewById(R.id.image_view) as? ImageView)?.let { imageView ->
imageView.setImageResource(
if (getPersistedString("").isNullOrEmpty()) android.R.color.transparent if (getPersistedString("").isNullOrEmpty()) android.R.color.transparent
else R.drawable.ic_done_24dp else R.drawable.ic_done_24dp
) )
binding.imageView.imageTintList = imageView.imageTintList =
ColorStateList.valueOf(Color.parseColor("#FF4CAF50")) ColorStateList.valueOf(Color.parseColor("#FF4CAF50"))
} }
}
public override fun notifyChanged() { public override fun notifyChanged() {
super.notifyChanged() super.notifyChanged()

View File

@ -2,6 +2,4 @@
<ImageView android:id="@+id/image_view" <ImageView android:id="@+id/image_view"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"> android:layout_height="wrap_content"/>
</ImageView>