mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-06-15 20:09:19 +00:00
Update: Make List Animation Optional (Closes #53)
This commit is contained in:
@ -16,8 +16,17 @@ object Preferences {
|
||||
private val subject = PublishSubject.create<Key<*>>()
|
||||
|
||||
private val keys = sequenceOf(
|
||||
Key.AutoSync, Key.IncompatibleVersions, Key.ProxyHost, Key.ProxyPort, Key.ProxyType,
|
||||
Key.RootPermission, Key.SortOrder, Key.Theme, Key.UpdateNotify, Key.UpdateUnstable
|
||||
Key.AutoSync,
|
||||
Key.IncompatibleVersions,
|
||||
Key.ListAnimation,
|
||||
Key.ProxyHost,
|
||||
Key.ProxyPort,
|
||||
Key.ProxyType,
|
||||
Key.RootPermission,
|
||||
Key.SortOrder,
|
||||
Key.Theme,
|
||||
Key.UpdateNotify,
|
||||
Key.UpdateUnstable
|
||||
).map { Pair(it.name, it) }.toMap()
|
||||
|
||||
fun init(context: Context) {
|
||||
@ -117,6 +126,9 @@ object Preferences {
|
||||
object IncompatibleVersions :
|
||||
Key<Boolean>("incompatible_versions", Value.BooleanValue(false))
|
||||
|
||||
object ListAnimation :
|
||||
Key<Boolean>("list_animation", Value.BooleanValue(true))
|
||||
|
||||
object ProxyHost : Key<String>("proxy_host", Value.StringValue("localhost"))
|
||||
object ProxyPort : Key<Int>("proxy_port", Value.IntValue(9050))
|
||||
object ProxyType : Key<Preferences.ProxyType>(
|
||||
|
@ -14,6 +14,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import coil.transform.RoundedCornersTransformation
|
||||
import com.google.android.material.imageview.ShapeableImageView
|
||||
import com.looker.droidify.R
|
||||
import com.looker.droidify.content.Preferences
|
||||
import com.looker.droidify.database.Database
|
||||
import com.looker.droidify.entity.ProductItem
|
||||
import com.looker.droidify.entity.Repository
|
||||
@ -131,7 +132,9 @@ class ProductsAdapter(private val onClick: (ProductItem) -> Unit) :
|
||||
|
||||
override fun onViewDetachedFromWindow(holder: RecyclerView.ViewHolder) {
|
||||
super.onViewDetachedFromWindow(holder)
|
||||
holder.itemView.clearAnimation()
|
||||
if (Preferences[Preferences.Key.ListAnimation]) {
|
||||
holder.itemView.clearAnimation()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
@ -197,12 +200,17 @@ class ProductsAdapter(private val onClick: (ProductItem) -> Unit) :
|
||||
holder.text.text = emptyText
|
||||
}
|
||||
}::class
|
||||
if (Preferences[Preferences.Key.ListAnimation]) {
|
||||
setAnimation(holder.itemView, holder.adapterPosition)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setAnimation(itemView: View, position: Int) {
|
||||
val animation = AnimationUtils.loadAnimation(
|
||||
holder.itemView.context,
|
||||
itemView.context,
|
||||
if (position > lastPosition) R.anim.slide_up else R.anim.slide_down
|
||||
)
|
||||
holder.itemView.startAnimation(animation)
|
||||
lastPosition = holder.adapterPosition
|
||||
itemView.startAnimation(animation)
|
||||
lastPosition = position
|
||||
}
|
||||
}
|
||||
}
|
@ -114,6 +114,10 @@ class SettingsFragment : ScreenFragment() {
|
||||
is Preferences.Theme.Amoled -> getString(R.string.amoled)
|
||||
}
|
||||
}
|
||||
addSwitch(
|
||||
Preferences.Key.ListAnimation, getString(R.string.list_animation),
|
||||
getString(R.string.list_animation_description)
|
||||
)
|
||||
}
|
||||
preferences.addCategory(getString(R.string.install_types)) {
|
||||
addSwitch(
|
||||
|
Reference in New Issue
Block a user