Remove overloaded ErrorReportingRunnable class
Summary: This masks this fact that `mConnection` must be `non-null` for very little convenience in return. Let's keep this explicit. Reviewed By: danielbuechele Differential Revision: D10505205 fbshipit-source-id: d8187cc8e79d4508babe281ff88b3ba75c0baa1f
This commit is contained in:
committed by
Facebook Github Bot
parent
bc0e5b3a11
commit
f75a90bf78
@@ -8,13 +8,14 @@
|
||||
|
||||
package com.facebook.flipper.plugins.inspector;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
import com.facebook.flipper.core.ErrorReportingRunnable;
|
||||
import com.facebook.flipper.core.FlipperArray;
|
||||
import com.facebook.flipper.core.FlipperConnection;
|
||||
import com.facebook.flipper.core.FlipperDynamic;
|
||||
import com.facebook.flipper.core.FlipperObject;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A NodeDescriptor is an object which known how to expose an Object of type T to the ew Inspector.
|
||||
@@ -22,7 +23,7 @@ import javax.annotation.Nullable;
|
||||
* data can be exposed to the inspector.
|
||||
*/
|
||||
public abstract class NodeDescriptor<T> {
|
||||
protected FlipperConnection mConnection;
|
||||
@Nullable protected FlipperConnection mConnection;
|
||||
private DescriptorMapping mDescriptorMapping;
|
||||
|
||||
void setConnection(FlipperConnection connection) {
|
||||
@@ -50,7 +51,7 @@ public abstract class NodeDescriptor<T> {
|
||||
*/
|
||||
protected final void invalidate(final T node) {
|
||||
if (mConnection != null) {
|
||||
new ErrorReportingRunnable() {
|
||||
new ErrorReportingRunnable(mConnection) {
|
||||
@Override
|
||||
protected void runOrThrow() throws Exception {
|
||||
FlipperArray array =
|
||||
@@ -71,7 +72,7 @@ public abstract class NodeDescriptor<T> {
|
||||
*/
|
||||
protected final void invalidateAX(final T node) {
|
||||
if (mConnection != null) {
|
||||
new ErrorReportingRunnable() {
|
||||
new ErrorReportingRunnable(mConnection) {
|
||||
@Override
|
||||
protected void runOrThrow() throws Exception {
|
||||
FlipperArray array =
|
||||
@@ -89,13 +90,6 @@ public abstract class NodeDescriptor<T> {
|
||||
return mConnection != null;
|
||||
}
|
||||
|
||||
protected abstract class ErrorReportingRunnable
|
||||
extends com.facebook.flipper.core.ErrorReportingRunnable {
|
||||
public ErrorReportingRunnable() {
|
||||
super(mConnection);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a node. This implementation usually consists of setting up listeners to know when to
|
||||
* call {@link NodeDescriptor#invalidate(Object)}.
|
||||
|
||||
@@ -13,6 +13,7 @@ import android.support.v4.view.ViewCompat;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import com.facebook.flipper.core.ErrorReportingRunnable;
|
||||
import com.facebook.flipper.core.FlipperDynamic;
|
||||
import com.facebook.flipper.core.FlipperObject;
|
||||
import com.facebook.flipper.plugins.inspector.ApplicationWrapper;
|
||||
@@ -58,7 +59,7 @@ public class ApplicationDescriptor extends NodeDescriptor<ApplicationWrapper> {
|
||||
}
|
||||
}
|
||||
|
||||
private static List<ViewGroup> editedDelegates = new ArrayList<>();
|
||||
private static final List<ViewGroup> editedDelegates = new ArrayList<>();
|
||||
private static boolean searchActive;
|
||||
|
||||
public static void setSearchActive(boolean active) {
|
||||
@@ -143,22 +144,25 @@ public class ApplicationDescriptor extends NodeDescriptor<ApplicationWrapper> {
|
||||
});
|
||||
|
||||
final NodeKey key = new NodeKey();
|
||||
final Runnable maybeInvalidate =
|
||||
new NodeDescriptor.ErrorReportingRunnable() {
|
||||
@Override
|
||||
public void runOrThrow() throws Exception {
|
||||
if (connected()) {
|
||||
if (key.set(node)) {
|
||||
invalidate(node);
|
||||
invalidateAX(node);
|
||||
setDelegates(node);
|
||||
}
|
||||
node.postDelayed(this, 1000);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
node.postDelayed(maybeInvalidate, 1000);
|
||||
if (mConnection != null) {
|
||||
final Runnable maybeInvalidate =
|
||||
new ErrorReportingRunnable(mConnection) {
|
||||
@Override
|
||||
public void runOrThrow() {
|
||||
if (connected()) {
|
||||
if (key.set(node)) {
|
||||
invalidate(node);
|
||||
invalidateAX(node);
|
||||
setDelegates(node);
|
||||
}
|
||||
node.postDelayed(this, 1000);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
node.postDelayed(maybeInvalidate, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -172,7 +176,7 @@ public class ApplicationDescriptor extends NodeDescriptor<ApplicationWrapper> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAXName(ApplicationWrapper node) throws Exception {
|
||||
public String getAXName(ApplicationWrapper node) {
|
||||
return "Application";
|
||||
}
|
||||
|
||||
@@ -228,7 +232,7 @@ public class ApplicationDescriptor extends NodeDescriptor<ApplicationWrapper> {
|
||||
}
|
||||
}
|
||||
|
||||
private void runHitTest(ApplicationWrapper node, Touch touch, boolean ax) throws Exception {
|
||||
private void runHitTest(ApplicationWrapper node, Touch touch, boolean ax) {
|
||||
final int childCount = getChildCount(node);
|
||||
|
||||
for (int i = childCount - 1; i >= 0; i--) {
|
||||
@@ -252,8 +256,9 @@ public class ApplicationDescriptor extends NodeDescriptor<ApplicationWrapper> {
|
||||
runHitTest(node, touch, true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public @Nullable String getDecoration(ApplicationWrapper obj) {
|
||||
public String getDecoration(ApplicationWrapper obj) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import android.view.ViewGroup.MarginLayoutParams;
|
||||
import android.view.ViewParent;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
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;
|
||||
@@ -546,20 +547,22 @@ public class ViewDescriptor extends NodeDescriptor<View> {
|
||||
return tags.build();
|
||||
}
|
||||
|
||||
new ErrorReportingRunnable() {
|
||||
@Override
|
||||
protected void runOrThrow() throws Exception {
|
||||
final SparseArray keyedTags = (SparseArray) sKeyedTagsField.get(node);
|
||||
if (keyedTags != null) {
|
||||
for (int i = 0, count = keyedTags.size(); i < count; i++) {
|
||||
final String id =
|
||||
ResourcesUtil.getIdStringQuietly(
|
||||
node.getContext(), node.getResources(), keyedTags.keyAt(i));
|
||||
tags.put(id, keyedTags.valueAt(i));
|
||||
if (mConnection != null) {
|
||||
new ErrorReportingRunnable(mConnection) {
|
||||
@Override
|
||||
protected void runOrThrow() throws Exception {
|
||||
final SparseArray keyedTags = (SparseArray) sKeyedTagsField.get(node);
|
||||
if (keyedTags != null) {
|
||||
for (int i = 0, count = keyedTags.size(); i < count; i++) {
|
||||
final String id =
|
||||
ResourcesUtil.getIdStringQuietly(
|
||||
node.getContext(), node.getResources(), keyedTags.keyAt(i));
|
||||
tags.put(id, keyedTags.valueAt(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.run();
|
||||
}.run();
|
||||
}
|
||||
|
||||
return tags.build();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import com.facebook.flipper.R;
|
||||
import com.facebook.flipper.core.ErrorReportingRunnable;
|
||||
import com.facebook.flipper.core.FlipperDynamic;
|
||||
import com.facebook.flipper.core.FlipperObject;
|
||||
import com.facebook.flipper.plugins.inspector.HiddenNode;
|
||||
@@ -66,26 +67,28 @@ public class ViewGroupDescriptor extends NodeDescriptor<ViewGroup> {
|
||||
public void init(final ViewGroup node) {
|
||||
final NodeKey key = new NodeKey();
|
||||
|
||||
final Runnable maybeInvalidate =
|
||||
new ErrorReportingRunnable() {
|
||||
@Override
|
||||
public void runOrThrow() throws Exception {
|
||||
if (connected()) {
|
||||
if (key.set(node)) {
|
||||
invalidate(node);
|
||||
invalidateAX(node);
|
||||
}
|
||||
if (mConnection != null) {
|
||||
final Runnable maybeInvalidate =
|
||||
new ErrorReportingRunnable(mConnection) {
|
||||
@Override
|
||||
public void runOrThrow() throws Exception {
|
||||
if (connected()) {
|
||||
if (key.set(node)) {
|
||||
invalidate(node);
|
||||
invalidateAX(node);
|
||||
}
|
||||
|
||||
final boolean hasAttachedToWindow =
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
|
||||
if (!hasAttachedToWindow || node.isAttachedToWindow()) {
|
||||
node.postDelayed(this, 1000);
|
||||
final boolean hasAttachedToWindow =
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
|
||||
if (!hasAttachedToWindow || node.isAttachedToWindow()) {
|
||||
node.postDelayed(this, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
node.postDelayed(maybeInvalidate, 1000);
|
||||
node.postDelayed(maybeInvalidate, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user