mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-12-28 22:20:59 +00:00
Added text switchers for descriptions
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
package com.topjohnwu.magisk.redesign.home
|
||||
|
||||
import com.skoumal.teanity.util.KObservableField
|
||||
import com.topjohnwu.magisk.redesign.compat.CompatViewModel
|
||||
|
||||
class HomeViewModel : CompatViewModel() {
|
||||
|
||||
val stateTextMagisk = KObservableField("is up to date")
|
||||
val stateTextManager = KObservableField("is up to date")
|
||||
|
||||
fun onDeletePressed() {}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.topjohnwu.magisk.utils
|
||||
|
||||
import android.view.View
|
||||
import android.widget.TextSwitcher
|
||||
import android.widget.TextView
|
||||
import android.widget.ViewSwitcher
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.appcompat.widget.AppCompatImageView
|
||||
@@ -245,4 +247,22 @@ fun View.setOnSelectClickListener(listener: View.OnClickListener, resetTime: Lon
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter("textCaptionVariant")
|
||||
fun TextSwitcher.setTextBinding(text: CharSequence) {
|
||||
tag as? ViewSwitcher.ViewFactory ?: ViewSwitcher.ViewFactory {
|
||||
View.inflate(context, R.layout.swicher_caption_variant, null)
|
||||
}.also {
|
||||
tag = it
|
||||
setFactory(it)
|
||||
setInAnimation(context, R.anim.switcher_bottom_up)
|
||||
setOutAnimation(context, R.anim.switcher_center_up)
|
||||
}
|
||||
|
||||
|
||||
val currentText = (currentView as? TextView)?.text
|
||||
if (currentText != text) {
|
||||
setText(text)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user