Remove node Id from descriptor

Summary: It was always the system hash code and in many places it was inconvient to get the descriptor to just end up calling the same function

Reviewed By: lblasa

Differential Revision: D39700215

fbshipit-source-id: b1439d56cd8f39ba8735f933662ad79b87ffbdbe
This commit is contained in:
Luke De Feo
2022-09-22 04:26:18 -07:00
committed by Facebook GitHub Bot
parent 32b7a5589f
commit 9bc2f6fec5
20 changed files with 30 additions and 82 deletions

View File

@@ -17,7 +17,6 @@ import com.facebook.litho.DebugComponent
import com.facebook.litho.LithoView
object LithoViewDescriptor : NodeDescriptor<LithoView> {
override fun getId(node: LithoView): String = System.identityHashCode(node).toString()
override fun getName(node: LithoView): String = "LithoView"
@@ -45,7 +44,6 @@ const val LithoTag = "Litho"
class MountedObject(val obj: Any, val descriptor: NodeDescriptor<Any>)
object MountedObjectDescriptor : NodeDescriptor<MountedObject> {
override fun getId(node: MountedObject): String = node.descriptor.getId(node.obj)
override fun getBounds(node: MountedObject): Bounds? {
val bounds = node.descriptor.getBounds(node.obj)
@@ -72,7 +70,6 @@ object MountedObjectDescriptor : NodeDescriptor<MountedObject> {
}
class DebugComponentDescriptor(val register: DescriptorRegister) : NodeDescriptor<DebugComponent> {
override fun getId(node: DebugComponent): String = System.identityHashCode(node).toString()
override fun getName(node: DebugComponent): String {
return node.component.simpleName

View File

@@ -10,6 +10,7 @@ package com.facebook.flipper.plugins.uidebugger.litho
import android.util.Log
import com.facebook.flipper.plugins.uidebugger.LogTag
import com.facebook.flipper.plugins.uidebugger.core.Context
import com.facebook.flipper.plugins.uidebugger.descriptors.nodeId
import com.facebook.flipper.plugins.uidebugger.observers.TreeObserver
import com.facebook.flipper.plugins.uidebugger.observers.TreeObserverBuilder
import com.facebook.litho.LithoView
@@ -22,6 +23,8 @@ class LithoViewTreeObserver(val context: Context) : TreeObserver<LithoView>() {
override fun subscribe(node: Any) {
Log.i(LogTag, "Subscribing to litho view ${node.nodeId()}")
nodeRef = node as LithoView
val listener: (view: LithoView) -> Unit = { traverseAndSend(context, node) }