Removed chaining of children from chained descriptor
Summary: This chaining needed to be removed to allow for litho view to override the children to be the root debug component Reviewed By: lblasa Differential Revision: D40021839 fbshipit-source-id: 1caf30ced14cf582f9e03e87e15f9a8eda5b9c4f
This commit is contained in:
committed by
Facebook GitHub Bot
parent
8140244f0a
commit
de1eece900
@@ -17,11 +17,15 @@ object ActivityDescriptor : ChainedDescriptor<Activity>() {
|
|||||||
return node.javaClass.simpleName
|
return node.javaClass.simpleName
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onGetChildren(node: Activity, children: MutableList<Any>) {
|
override fun onGetChildren(node: Activity): List<Any> {
|
||||||
|
val children = mutableListOf<Any>()
|
||||||
|
|
||||||
node.window?.let { window -> children.add(window) }
|
node.window?.let { window -> children.add(window) }
|
||||||
|
|
||||||
val fragments = FragmentTracker.getDialogFragments(node)
|
val fragments = FragmentTracker.getDialogFragments(node)
|
||||||
fragments.forEach { fragment -> children.add(fragment) }
|
fragments.forEach { fragment -> children.add(fragment) }
|
||||||
|
|
||||||
|
return children
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onGetData(
|
override fun onGetData(
|
||||||
|
|||||||
@@ -31,7 +31,9 @@ object ApplicationRefDescriptor : ChainedDescriptor<ApplicationRef>() {
|
|||||||
else node.application.getString(stringId)
|
else node.application.getString(stringId)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onGetChildren(node: ApplicationRef, children: MutableList<Any>) {
|
override fun onGetChildren(node: ApplicationRef): List<Any> {
|
||||||
|
val children = mutableListOf<Any>()
|
||||||
|
|
||||||
val activeRoots = node.rootViews
|
val activeRoots = node.rootViews
|
||||||
|
|
||||||
val added = mutableSetOf<View>()
|
val added = mutableSetOf<View>()
|
||||||
@@ -47,5 +49,7 @@ object ApplicationRefDescriptor : ChainedDescriptor<ApplicationRef>() {
|
|||||||
added.add(root)
|
added.add(root)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return children
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,23 +65,12 @@ abstract class ChainedDescriptor<T> : NodeDescriptor<T> {
|
|||||||
|
|
||||||
open fun onGetBounds(node: T): Bounds? = null
|
open fun onGetBounds(node: T): Bounds? = null
|
||||||
|
|
||||||
/** The children this node exposes in the inspector. */
|
|
||||||
final override fun getChildren(node: T): List<Any> {
|
final override fun getChildren(node: T): List<Any> {
|
||||||
val builder = mutableListOf<Any>()
|
val children = onGetChildren(node) ?: mSuper?.getChildren(node)
|
||||||
onGetChildren(node, builder)
|
return children ?: listOf()
|
||||||
|
|
||||||
var curDescriptor: ChainedDescriptor<T>? = mSuper
|
|
||||||
while (curDescriptor != null) {
|
|
||||||
curDescriptor.onGetChildren(node, builder)
|
|
||||||
curDescriptor = curDescriptor.mSuper
|
|
||||||
}
|
|
||||||
|
|
||||||
return builder
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// this probably should not be chained as its unlikely you would want children to come from >1
|
open fun onGetChildren(node: T): List<Any>? = null
|
||||||
// descriptor
|
|
||||||
open fun onGetChildren(node: T, children: MutableList<Any>) {}
|
|
||||||
|
|
||||||
final override fun getData(node: T): Map<SectionName, InspectableObject> {
|
final override fun getData(node: T): Map<SectionName, InspectableObject> {
|
||||||
val builder = mutableMapOf<String, InspectableObject>()
|
val builder = mutableMapOf<String, InspectableObject>()
|
||||||
|
|||||||
@@ -15,9 +15,8 @@ object FragmentFrameworkDescriptor : ChainedDescriptor<android.app.Fragment>() {
|
|||||||
return node.javaClass.simpleName
|
return node.javaClass.simpleName
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onGetChildren(node: android.app.Fragment, children: MutableList<Any>) {
|
override fun onGetChildren(node: android.app.Fragment): List<Any> =
|
||||||
node.view?.let { view -> children.add(view) }
|
node.view?.let { view -> listOf(view) } ?: listOf()
|
||||||
}
|
|
||||||
|
|
||||||
override fun onGetData(
|
override fun onGetData(
|
||||||
node: android.app.Fragment,
|
node: android.app.Fragment,
|
||||||
|
|||||||
@@ -15,9 +15,8 @@ object FragmentSupportDescriptor : ChainedDescriptor<androidx.fragment.app.Fragm
|
|||||||
return node.javaClass.simpleName
|
return node.javaClass.simpleName
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onGetChildren(node: androidx.fragment.app.Fragment, children: MutableList<Any>) {
|
override fun onGetChildren(node: androidx.fragment.app.Fragment): List<Any> =
|
||||||
node.view?.let { view -> children.add(view) }
|
node.view?.let { view -> listOf(view) } ?: listOf()
|
||||||
}
|
|
||||||
|
|
||||||
override fun onGetData(
|
override fun onGetData(
|
||||||
node: androidx.fragment.app.Fragment,
|
node: androidx.fragment.app.Fragment,
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ object ViewGroupDescriptor : ChainedDescriptor<ViewGroup>() {
|
|||||||
return node.javaClass.simpleName
|
return node.javaClass.simpleName
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onGetChildren(node: ViewGroup, children: MutableList<Any>) {
|
override fun onGetChildren(node: ViewGroup): List<Any> {
|
||||||
|
val children = mutableListOf<Any>()
|
||||||
|
|
||||||
val count = node.childCount - 1
|
val count = node.childCount - 1
|
||||||
for (i in 0..count) {
|
for (i in 0..count) {
|
||||||
val child: View = node.getChildAt(i)
|
val child: View = node.getChildAt(i)
|
||||||
@@ -29,6 +31,8 @@ object ViewGroupDescriptor : ChainedDescriptor<ViewGroup>() {
|
|||||||
children.add(fragment)
|
children.add(fragment)
|
||||||
} else children.add(child)
|
} else children.add(child)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return children
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onGetData(
|
override fun onGetData(
|
||||||
|
|||||||
@@ -15,7 +15,5 @@ object WindowDescriptor : ChainedDescriptor<Window>() {
|
|||||||
return node.javaClass.simpleName
|
return node.javaClass.simpleName
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onGetChildren(node: Window, children: MutableList<Any>) {
|
override fun onGetChildren(node: Window): List<Any> = listOf(node.decorView)
|
||||||
children.add(node.decorView)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user