mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-26 14:09:58 +00:00
Fix NPE in spoiler renderer.
This commit is contained in:
@@ -56,7 +56,7 @@ class SpoilerRendererDelegate @JvmOverloads constructor(
|
||||
view.addOnAttachStateChangeListener(object : OnAttachStateChangeListener {
|
||||
override fun onViewDetachedFromWindow(v: View) = stopAnimating()
|
||||
override fun onViewAttachedToWindow(v: View) {
|
||||
view.getLifecycle().addObserver(object : DefaultLifecycleObserver {
|
||||
view.getLifecycle()?.addObserver(object : DefaultLifecycleObserver {
|
||||
override fun onResume(owner: LifecycleOwner) {
|
||||
canAnimate = true
|
||||
systemAnimationsEnabled = !AccessibilityUtil.areAnimationsDisabled(view.context)
|
||||
|
||||
@@ -64,10 +64,10 @@ fun TextView.setRelativeDrawables(
|
||||
* 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 {
|
||||
fun View.getLifecycle(): Lifecycle? {
|
||||
return try {
|
||||
findFragment<Fragment>().viewLifecycleOwner.lifecycle
|
||||
} catch (e: IllegalStateException) {
|
||||
ViewUtil.getActivityLifecycle(this)!!
|
||||
ViewUtil.getActivityLifecycle(this)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user