Add GuardedRunnable in more places
Summary: Depends on D4537287 Use new GuardedRunnable abstraction Reviewed By: achen1 Differential Revision: D4537370 fbshipit-source-id: ad56eaa23c21624008d8ed48837a2d1020cfd2d9
This commit is contained in:
parent
08db896321
commit
a99f6f51a9
|
@ -21,6 +21,7 @@ import android.view.WindowInsets;
|
|||
import android.view.WindowManager;
|
||||
|
||||
import com.facebook.common.logging.FLog;
|
||||
import com.facebook.react.bridge.GuardedRunnable;
|
||||
import com.facebook.react.bridge.NativeModule;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
|
@ -75,10 +76,10 @@ public class StatusBarModule extends ReactContextBaseJavaModule {
|
|||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
UiThreadUtil.runOnUiThread(
|
||||
new Runnable() {
|
||||
new GuardedRunnable(getReactApplicationContext()) {
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public void run() {
|
||||
public void runGuarded() {
|
||||
if (animated) {
|
||||
int curColor = activity.getWindow().getStatusBarColor();
|
||||
ValueAnimator colorAnimation = ValueAnimator.ofObject(
|
||||
|
@ -112,10 +113,10 @@ public class StatusBarModule extends ReactContextBaseJavaModule {
|
|||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
UiThreadUtil.runOnUiThread(
|
||||
new Runnable() {
|
||||
new GuardedRunnable(getReactApplicationContext()) {
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public void run() {
|
||||
public void runGuarded() {
|
||||
// If the status bar is translucent hook into the window insets calculations
|
||||
// and consume all the top insets so no padding will be added under the status bar.
|
||||
View decorView = activity.getWindow().getDecorView();
|
||||
|
|
|
@ -21,6 +21,7 @@ import android.content.res.Configuration;
|
|||
import com.facebook.common.logging.FLog;
|
||||
import com.facebook.react.animation.Animation;
|
||||
import com.facebook.react.bridge.Callback;
|
||||
import com.facebook.react.bridge.GuardedRunnable;
|
||||
import com.facebook.react.bridge.LifecycleEventListener;
|
||||
import com.facebook.react.bridge.NativeModuleLogger;
|
||||
import com.facebook.react.bridge.OnBatchCompleteListener;
|
||||
|
@ -202,8 +203,9 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
|
|||
height = rootView.getHeight();
|
||||
}
|
||||
|
||||
final ReactApplicationContext reactApplicationContext = getReactApplicationContext();
|
||||
final ThemedReactContext themedRootContext =
|
||||
new ThemedReactContext(getReactApplicationContext(), rootView.getContext());
|
||||
new ThemedReactContext(reactApplicationContext, rootView.getContext());
|
||||
|
||||
mUIImplementation.registerRootView(rootView, tag, width, height, themedRootContext);
|
||||
|
||||
|
@ -211,10 +213,10 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
|
|||
new SizeMonitoringFrameLayout.OnSizeChangedListener() {
|
||||
@Override
|
||||
public void onSizeChanged(final int width, final int height, int oldW, int oldH) {
|
||||
getReactApplicationContext().runOnNativeModulesQueueThread(
|
||||
new Runnable() {
|
||||
reactApplicationContext.runOnNativeModulesQueueThread(
|
||||
new GuardedRunnable(reactApplicationContext) {
|
||||
@Override
|
||||
public void run() {
|
||||
public void runGuarded() {
|
||||
updateNodeSize(tag, width, height);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -27,6 +27,7 @@ import android.widget.FrameLayout;
|
|||
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.react.R;
|
||||
import com.facebook.react.bridge.GuardedRunnable;
|
||||
import com.facebook.react.bridge.LifecycleEventListener;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.common.annotations.VisibleForTesting;
|
||||
|
@ -303,10 +304,11 @@ public class ReactModalHostView extends ViewGroup implements LifecycleEventListe
|
|||
protected void onSizeChanged(final int w, final int h, int oldw, int oldh) {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
if (getChildCount() > 0) {
|
||||
((ReactContext) getContext()).runOnNativeModulesQueueThread(
|
||||
new Runnable() {
|
||||
ReactContext reactContext = (ReactContext) getContext();
|
||||
reactContext.runOnNativeModulesQueueThread(
|
||||
new GuardedRunnable(reactContext) {
|
||||
@Override
|
||||
public void run() {
|
||||
public void runGuarded() {
|
||||
((ReactContext) getContext()).getNativeModule(UIManagerModule.class)
|
||||
.updateNodeSize(getChildAt(0).getId(), w, h);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue