Add transparency options to subtitle (#281)

* feat: add state llistener to Xpandable

* feat: improve app restart process

* feat: support subtitle transparency
This commit is contained in:
TwistedUmbrellaX 2024-03-23 20:12:22 -04:00 committed by GitHub
parent 89e18b0e2f
commit 85ef4b3c12
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 259 additions and 129 deletions

View file

@ -13,6 +13,7 @@ class Xpandable @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null
) : LinearLayout(context, attrs) {
var expanded: Boolean = false
private var listener: OnChangeListener? = null
init {
context.withStyledAttributes(attrs, R.styleable.Xpandable) {
@ -37,7 +38,6 @@ class Xpandable @JvmOverloads constructor(
super.onAttachedToWindow()
}
private fun hideAll() {
children.forEach {
if (it != getChildAt(0)) {
@ -48,8 +48,10 @@ class Xpandable @JvmOverloads constructor(
it.visibility = GONE
}, 300)
}
}
postDelayed({
listener?.onRetract()
}, 300)
}
private fun showAll() {
@ -61,6 +63,19 @@ class Xpandable @JvmOverloads constructor(
ObjectAnimator.ofFloat(it, "alpha", 0f, 1f).setDuration(200).start()
}
}
postDelayed({
listener?.onExpand()
}, 300)
}
@Suppress("unused")
fun setOnChangeListener(listener: OnChangeListener) {
this.listener = listener
}
interface OnChangeListener {
fun onExpand()
fun onRetract()
}
}