mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-19 08:09:12 +01:00
Improve spoiler performance by stopping animation when backgrounded.
This commit is contained in:
@@ -6,6 +6,9 @@ import androidx.annotation.DrawableRes
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.constraintlayout.widget.ConstraintSet
|
||||
import androidx.core.view.doOnNextLayout
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.findFragment
|
||||
import androidx.lifecycle.Lifecycle
|
||||
|
||||
var View.visible: Boolean
|
||||
get() {
|
||||
@@ -56,3 +59,15 @@ fun TextView.setRelativeDrawables(
|
||||
bottom
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a lifecycle associated with this view. Care must be taken to ensure
|
||||
* if activity fallback occurs that the context of the view is correct.
|
||||
*/
|
||||
fun View.getLifecycle(): Lifecycle {
|
||||
return try {
|
||||
findFragment<Fragment>().viewLifecycleOwner.lifecycle
|
||||
} catch (e: IllegalStateException) {
|
||||
ViewUtil.getActivityLifecycle(this)!!
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user