Added text switchers for descriptions

This commit is contained in:
Viktor De Pasquale
2019-10-04 17:56:30 +02:00
parent 1396faf433
commit cb2a1e57fe
6 changed files with 54 additions and 7 deletions
@@ -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)
}
}