mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-24 02:01:51 +01:00
Adding Animation when expanding/collapsing sections in source filter sheet
This commit is contained in:
parent
41f3d1ea2a
commit
6c581dd0fc
@ -11,7 +11,7 @@ import eu.davidea.flexibleadapter.items.ISectionable
|
||||
import eu.davidea.viewholders.ExpandableViewHolder
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.source.model.Filter
|
||||
import eu.kanade.tachiyomi.util.view.setVectorCompat
|
||||
import eu.kanade.tachiyomi.util.view.setAnimVectorCompat
|
||||
|
||||
class GroupItem(val filter: Filter.Group<*>) : AbstractExpandableHeaderItem<GroupItem.Holder, ISectionable<*, *>>() {
|
||||
|
||||
@ -34,11 +34,11 @@ class GroupItem(val filter: Filter.Group<*>) : AbstractExpandableHeaderItem<Grou
|
||||
override fun bindViewHolder(adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>, holder: Holder, position: Int, payloads: MutableList<Any?>?) {
|
||||
holder.title.text = filter.name
|
||||
|
||||
holder.icon.setVectorCompat(
|
||||
holder.icon.setAnimVectorCompat(
|
||||
if (isExpanded) {
|
||||
R.drawable.ic_expand_less_24dp
|
||||
R.drawable.expand_more_to_less
|
||||
} else {
|
||||
R.drawable.ic_expand_more_24dp
|
||||
R.drawable.expand_less_to_more
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -8,7 +8,7 @@ import eu.davidea.flexibleadapter.items.IFlexible
|
||||
import eu.davidea.flexibleadapter.items.ISectionable
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.source.model.Filter
|
||||
import eu.kanade.tachiyomi.util.view.setVectorCompat
|
||||
import eu.kanade.tachiyomi.util.view.setAnimVectorCompat
|
||||
|
||||
class SortGroup(val filter: Filter.Sort) : AbstractExpandableHeaderItem<SortGroup.Holder, ISectionable<*, *>>() {
|
||||
|
||||
@ -31,11 +31,11 @@ class SortGroup(val filter: Filter.Sort) : AbstractExpandableHeaderItem<SortGrou
|
||||
override fun bindViewHolder(adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>, holder: Holder, position: Int, payloads: MutableList<Any?>?) {
|
||||
holder.title.text = filter.name
|
||||
|
||||
holder.icon.setVectorCompat(
|
||||
holder.icon.setAnimVectorCompat(
|
||||
if (isExpanded) {
|
||||
R.drawable.ic_expand_less_24dp
|
||||
R.drawable.expand_more_to_less
|
||||
} else {
|
||||
R.drawable.ic_expand_more_24dp
|
||||
R.drawable.expand_less_to_more
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.util.view
|
||||
|
||||
import android.widget.ImageView
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
|
||||
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat
|
||||
|
||||
/**
|
||||
@ -17,3 +18,13 @@ fun ImageView.setVectorCompat(@DrawableRes drawable: Int, tint: Int? = null) {
|
||||
}
|
||||
setImageDrawable(vector)
|
||||
}
|
||||
|
||||
fun ImageView.setAnimVectorCompat(@DrawableRes drawable: Int, tint: Int? = null) {
|
||||
val vector = AnimatedVectorDrawableCompat.create(context, drawable)
|
||||
if (tint != null) {
|
||||
vector?.mutate()
|
||||
vector?.setTint(tint)
|
||||
}
|
||||
setImageDrawable(vector)
|
||||
vector?.start()
|
||||
}
|
||||
|
28
app/src/main/res/drawable/expand_less_to_more.xml
Normal file
28
app/src/main/res/drawable/expand_less_to_more.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<animated-vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt">
|
||||
<aapt:attr name="android:drawable">
|
||||
<vector
|
||||
android:name="vector"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:name="path"
|
||||
android:pathData="M 18 14 L 12 8 L 6 14 L 7.41 15.41 L 12 10.83 L 16.59 15.41 L 18 14"
|
||||
android:fillColor="#000000"/>
|
||||
</vector>
|
||||
</aapt:attr>
|
||||
<target android:name="path">
|
||||
<aapt:attr name="android:animation">
|
||||
<objectAnimator
|
||||
android:propertyName="pathData"
|
||||
android:duration="250"
|
||||
android:valueFrom="M 18 14 L 12 8 L 6 14 L 7.41 15.41 L 12 10.83 L 16.59 15.41 L 18 14"
|
||||
android:valueTo="M 16.59 8.59 L 12 13.17 L 7.41 8.59 L 6 10 L 12 16 L 18 10 L 16.59 8.59"
|
||||
android:valueType="pathType"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"/>
|
||||
</aapt:attr>
|
||||
</target>
|
||||
</animated-vector>
|
28
app/src/main/res/drawable/expand_more_to_less.xml
Normal file
28
app/src/main/res/drawable/expand_more_to_less.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<animated-vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt">
|
||||
<aapt:attr name="android:drawable">
|
||||
<vector
|
||||
android:name="vector"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:name="path"
|
||||
android:pathData="M 16.59 8.59 L 12 13.17 L 7.41 8.59 L 6 10 L 12 16 L 18 10 L 16.59 8.59"
|
||||
android:fillColor="#000000"/>
|
||||
</vector>
|
||||
</aapt:attr>
|
||||
<target android:name="path">
|
||||
<aapt:attr name="android:animation">
|
||||
<objectAnimator
|
||||
android:propertyName="pathData"
|
||||
android:duration="250"
|
||||
android:valueFrom="M 16.59 8.59 L 12 13.17 L 7.41 8.59 L 6 10 L 12 16 L 18 10 L 16.59 8.59"
|
||||
android:valueTo="M 18 14 L 12 8 L 6 14 L 7.41 15.41 L 12 10.83 L 16.59 15.41 L 18 14"
|
||||
android:valueType="pathType"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"/>
|
||||
</aapt:attr>
|
||||
</target>
|
||||
</animated-vector>
|
@ -5,7 +5,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/listPreferredItemHeightSmall"
|
||||
android:gravity="center_vertical"
|
||||
android:background="?android:attr/colorBackground"
|
||||
android:background="@drawable/rect_ripple"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="?attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?attr/listPreferredItemPaddingEnd">
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
|
||||
android:id="@+id/nav_view_item"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:entries="@array/viewers_selector"
|
||||
|
Loading…
Reference in New Issue
Block a user