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.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() {

View File

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