Update Section hierarchy when child views change

Summary:
we only include in the inspector hierarchy the sections which are visible on screen. If as a result of a UI change the hierarchy of visible sections changes (for example when scrolling to a section that wasn't previously visible) this forces the section hierarchy to be recreated.
passy not sure if there's an easier way of making the children of a node invalidate, let me know if you have any suggestions
Depends on D14300298

Reviewed By: passy

Differential Revision: D14301404

fbshipit-source-id: 551e1910d0a80238027e32417aab8d42ed1c00b3
This commit is contained in:
Mihaela Ogrezeanu
2019-03-06 07:49:06 -08:00
committed by Facebook Github Bot
parent de43fd29c6
commit 410b6a6043
4 changed files with 45 additions and 3 deletions

View File

@@ -49,7 +49,7 @@ public abstract class NodeDescriptor<T> {
* and/or children have changed. This will trigger Flipper to re-query this node getting any new
* data.
*/
protected final void invalidate(final T node) {
public void invalidate(final T node) {
if (mConnection != null) {
new ErrorReportingRunnable(mConnection) {
@Override

View File

@@ -74,7 +74,8 @@ public class ViewGroupDescriptor extends NodeDescriptor<ViewGroup> {
public void runOrThrow() throws Exception {
if (connected()) {
if (key.set(node)) {
invalidate(node);
NodeDescriptor descriptor = descriptorForClass(node.getClass());
descriptor.invalidate(node);
invalidateAX(node);
}

View File

@@ -11,6 +11,7 @@ import android.view.View;
import android.view.ViewGroup;
import androidx.core.view.MarginLayoutParamsCompat;
import androidx.core.view.ViewCompat;
import com.facebook.flipper.core.ErrorReportingRunnable;
import com.facebook.flipper.core.FlipperDynamic;
import com.facebook.flipper.core.FlipperObject;
import com.facebook.flipper.plugins.inspector.HighlightedOverlay;
@@ -22,6 +23,24 @@ import java.util.ArrayList;
import java.util.List;
public class DebugSectionDescriptor extends NodeDescriptor<DebugSection> {
@Override
public void invalidate(final DebugSection debugSection) {
super.invalidate(debugSection);
new ErrorReportingRunnable(mConnection) {
@Override
protected void runOrThrow() throws Exception {
for (int i = 0; i < getChildCount(debugSection); i++) {
Object child = getChildAt(debugSection, i);
if (child instanceof DebugSection) {
invalidate((DebugSection) child);
}
}
}
}.run();
}
@Override
public void init(DebugSection node) throws Exception {}

View File

@@ -19,8 +19,30 @@ import java.util.ArrayList;
import java.util.List;
public class LithoRecyclerViewDescriptor extends NodeDescriptor<LithoRecylerView> {
@Override
public void init(LithoRecylerView node) throws Exception {}
public void invalidate(final LithoRecylerView node) {
super.invalidate(node);
new com.facebook.flipper.core.ErrorReportingRunnable(mConnection) {
@Override
protected void runOrThrow() throws Exception {
final Object child;
child = getChildAt(node, 0);
if (child instanceof DebugSection) {
DebugSection childSection = (DebugSection) child;
final NodeDescriptor descriptor = descriptorForClass(DebugSection.class);
descriptor.invalidate(childSection);
}
}
}.run();
}
@Override
public void init(final LithoRecylerView node) throws Exception {
final NodeDescriptor descriptor = descriptorForClass(ViewGroup.class);
descriptor.init(node);
}
@Override
public String getId(LithoRecylerView node) throws Exception {