Unsubscribe from updates and tidy up
Summary: Remove listener on unsubscribe and tidy up comments. Reviewed By: LukeDefeo Differential Revision: D39575287 fbshipit-source-id: 2b4ac0bc07cfe86f5ad0e602bbba4b596230cd52
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ddc5554673
commit
2051359490
@@ -39,15 +39,19 @@ class ApplicationTreeObserver(val context: Context) : TreeObserver<ApplicationRe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
context.applicationRef.rootsResolver.attachListener(rootViewListener)
|
context.applicationRef.rootsResolver.attachListener(rootViewListener)
|
||||||
// trigger a traversal on whatever roots we have now
|
// On subscribe, trigger a traversal on whatever roots we have
|
||||||
rootViewListener.onRootViewsChanged(applicationRef.rootViews)
|
rootViewListener.onRootViewsChanged(applicationRef.rootViews)
|
||||||
|
|
||||||
|
// TODO: Subscribing to root view changes but not to activity changes.
|
||||||
|
// Obviously changes in activities have an effect on root views, but
|
||||||
|
// then it may make sense to unsubscribe the root views listener instead
|
||||||
|
// of activities.
|
||||||
|
|
||||||
Log.i(LogTag, "${context.applicationRef.rootViews.size} root views")
|
Log.i(LogTag, "${context.applicationRef.rootViews.size} root views")
|
||||||
Log.i(LogTag, "${context.applicationRef.activitiesStack.size} activities")
|
Log.i(LogTag, "${context.applicationRef.activitiesStack.size} activities")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun unsubscribe() {
|
override fun unsubscribe() {
|
||||||
// Not entirely sure this will ever happen or be needed.
|
context.applicationRef.rootsResolver.attachListener(null)
|
||||||
// context.applicationRef.setActivityStackChangedListener(null)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user