Using AnimatedVectorDrawableCompat in all places

No idea why I trusted google with this
This commit is contained in:
Jays2Kings 2021-04-19 22:49:38 -04:00
parent 5b40f10c89
commit 196aa8aa0c
3 changed files with 13 additions and 10 deletions

View File

@ -1,7 +1,6 @@
package eu.kanade.tachiyomi.ui.library.filter package eu.kanade.tachiyomi.ui.library.filter
import android.content.Context import android.content.Context
import android.graphics.drawable.AnimatedVectorDrawable
import android.os.Parcelable import android.os.Parcelable
import android.util.AttributeSet import android.util.AttributeSet
import android.view.View import android.view.View
@ -9,6 +8,7 @@ import android.widget.ImageView
import android.widget.LinearLayout import android.widget.LinearLayout
import androidx.annotation.StringRes import androidx.annotation.StringRes
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetBehavior
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.DatabaseHelper import eu.kanade.tachiyomi.data.database.DatabaseHelper
@ -233,14 +233,15 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
} }
) )
if (animated) { if (animated) {
binding.expandCategories.setIconResource( binding.expandCategories.icon = AnimatedVectorDrawableCompat.create(
binding.expandCategories.context,
if (!allExpanded) { if (!allExpanded) {
R.drawable.anim_expand_less_to_more R.drawable.anim_expand_less_to_more
} else { } else {
R.drawable.anim_expand_more_to_less R.drawable.anim_expand_more_to_less
} }
) )
(binding.expandCategories.icon as? AnimatedVectorDrawable)?.start() (binding.expandCategories.icon as? AnimatedVectorDrawableCompat)?.start()
} else { } else {
binding.expandCategories.setIconResource( binding.expandCategories.setIconResource(
if (!allExpanded) { if (!allExpanded) {

View File

@ -2,9 +2,9 @@ package eu.kanade.tachiyomi.ui.main
import android.app.Dialog import android.app.Dialog
import android.graphics.Color import android.graphics.Color
import android.graphics.drawable.AnimatedVectorDrawable
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
import eu.kanade.tachiyomi.BuildConfig import eu.kanade.tachiyomi.BuildConfig
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
@ -49,11 +49,13 @@ class OverflowDialog(activity: MainActivity) : Dialog(activity, R.style.Overflow
incogText incogText
) )
text = newTitle.withSubtitle(context, subtitleText) text = newTitle.withSubtitle(context, subtitleText)
setIcon( val drawable = AnimatedVectorDrawableCompat.create(
context,
if (incog) R.drawable.anim_read_to_incog if (incog) R.drawable.anim_read_to_incog
else R.drawable.anim_incog_to_read else R.drawable.anim_incog_to_read
) )
(getIcon() as? AnimatedVectorDrawable)?.start() setIcon(drawable)
(getIcon() as? AnimatedVectorDrawableCompat)?.start()
} }
} }
binding.settingsItem.setOnClickListener { binding.settingsItem.setOnClickListener {

View File

@ -9,7 +9,6 @@ import android.content.res.ColorStateList
import android.content.res.Configuration import android.content.res.Configuration
import android.graphics.Bitmap import android.graphics.Bitmap
import android.graphics.Color import android.graphics.Color
import android.graphics.drawable.AnimatedVectorDrawable
import android.graphics.drawable.LayerDrawable import android.graphics.drawable.LayerDrawable
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
@ -33,6 +32,7 @@ import androidx.core.view.isVisible
import androidx.core.view.GestureDetectorCompat import androidx.core.view.GestureDetectorCompat
import androidx.core.view.ViewCompat import androidx.core.view.ViewCompat
import androidx.core.view.forEach import androidx.core.view.forEach
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetBehavior
@ -419,9 +419,9 @@ class ReaderActivity :
R.drawable.anim_crop_to_free R.drawable.anim_crop_to_free
} }
if (lastCropRes != drawableRes) { if (lastCropRes != drawableRes) {
setImageResource(drawableRes) val drawable = AnimatedVectorDrawableCompat.create(context, drawableRes)
val animDrawable = drawable as AnimatedVectorDrawable setImageDrawable(drawable)
animDrawable.start() drawable?.start()
lastCropRes = drawableRes lastCropRes = drawableRes
} }
compatToolTipText = compatToolTipText =