Added animated progressbar
This commit is contained in:
parent
f1427e9279
commit
016e28383b
@ -14,10 +14,12 @@ import com.topjohnwu.magisk.model.entity.ProcessHideApp
|
||||
import com.topjohnwu.magisk.model.entity.StatefulProcess
|
||||
import com.topjohnwu.magisk.model.entity.state.IndeterminateState
|
||||
import com.topjohnwu.magisk.model.events.HideProcessEvent
|
||||
import com.topjohnwu.magisk.model.observer.Observer
|
||||
import com.topjohnwu.magisk.redesign.hide.HideViewModel
|
||||
import com.topjohnwu.magisk.utils.DiffObservableList
|
||||
import com.topjohnwu.magisk.utils.KObservableField
|
||||
import com.topjohnwu.magisk.utils.RxBus
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
class HideItem(val item: ProcessHideApp) : ComparableRvItem<HideItem>() {
|
||||
|
||||
@ -28,6 +30,9 @@ class HideItem(val item: ProcessHideApp) : ComparableRvItem<HideItem>() {
|
||||
|
||||
val isExpanded = KObservableField(false)
|
||||
val itemsChecked = KObservableField(0)
|
||||
val itemsCheckedPercent = Observer(itemsChecked) {
|
||||
(itemsChecked.value.toFloat() / items.size * 100).roundToInt()
|
||||
}
|
||||
|
||||
/** [toggle] depends on this functionality */
|
||||
private val isHidden get() = itemsChecked.value == items.size
|
||||
|
@ -1,11 +1,13 @@
|
||||
package com.topjohnwu.magisk.utils
|
||||
|
||||
import android.animation.Animator
|
||||
import android.animation.ValueAnimator
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.Build
|
||||
import android.view.View
|
||||
import android.view.ViewAnimationUtils
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.TextSwitcher
|
||||
import android.widget.TextView
|
||||
import android.widget.ViewSwitcher
|
||||
@ -429,4 +431,16 @@ fun NestedScrollView.setOnScrollStateChangeListener(listener: Runnable) {
|
||||
}
|
||||
handler.postDelayed(listener, 1000)
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter("progressAnimated")
|
||||
fun ProgressBar.setProgressAnimated(newProgress: Int) {
|
||||
val animator = tag as? ValueAnimator
|
||||
animator?.cancel()
|
||||
|
||||
ValueAnimator.ofInt(progress, newProgress).apply {
|
||||
interpolator = FastOutSlowInInterpolator()
|
||||
addUpdateListener { progress = it.animatedValue as Int }
|
||||
tag = this
|
||||
}.start()
|
||||
}
|
@ -124,8 +124,7 @@
|
||||
style="?styleProgressDeterminate"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_gravity="top"
|
||||
android:max="@{item.items.size()}"
|
||||
android:progress="@{item.itemsChecked}" />
|
||||
progressAnimated="@{item.itemsCheckedPercent}" />
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user