Skip to content

Commit 729dcf6

Browse files
javachefacebook-github-bot
authored andcommitted
Fix more warnings on bridge invalidation
Summary: Looked at the top soft exceptions firing from this codepath. Most of these should use `getReactApplicationContext` instead of `getReactApplicationContextIfActiveOrWarn` to do their cleanup on invalidation. Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D43661307 fbshipit-source-id: 27094a6e8dfcf4748eb916531c4998f1c9ee8713
1 parent 848ac0c commit 729dcf6

File tree

3 files changed

+8
-20
lines changed

3 files changed

+8
-20
lines changed

ReactAndroid/src/main/java/com/facebook/react/modules/accessibilityinfo/AccessibilityInfoModule.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,8 @@ public void initialize() {
194194

195195
@Override
196196
public void invalidate() {
197+
getReactApplicationContext().removeLifecycleEventListener(this);
197198
super.invalidate();
198-
199-
ReactApplicationContext applicationContext = getReactApplicationContextIfActiveOrWarn();
200-
if (applicationContext != null) {
201-
applicationContext.removeLifecycleEventListener(this);
202-
}
203199
}
204200

205201
@Override

ReactAndroid/src/main/java/com/facebook/react/modules/dialog/DialogModule.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,7 @@ public void run() {
234234

235235
@Override
236236
public void invalidate() {
237+
getReactApplicationContext().removeLifecycleEventListener(this);
237238
super.invalidate();
238-
239-
ReactApplicationContext applicationContext = getReactApplicationContextIfActiveOrWarn();
240-
if (applicationContext != null) {
241-
applicationContext.removeLifecycleEventListener(this);
242-
}
243239
}
244240
}

ReactAndroid/src/main/java/com/facebook/react/modules/fresco/FrescoModule.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
package com.facebook.react.modules.fresco;
99

10-
import android.content.Context;
1110
import androidx.annotation.Nullable;
1211
import com.facebook.common.logging.FLog;
1312
import com.facebook.drawee.backends.pipeline.Fresco;
@@ -127,13 +126,14 @@ public FrescoModule(
127126
@Override
128127
public void initialize() {
129128
super.initialize();
130-
getReactApplicationContext().addLifecycleEventListener(this);
129+
130+
ReactApplicationContext reactContext = getReactApplicationContext();
131+
reactContext.addLifecycleEventListener(this);
131132
if (!hasBeenInitialized()) {
132133
if (mConfig == null) {
133-
mConfig = getDefaultConfig(getReactApplicationContext());
134+
mConfig = getDefaultConfig(reactContext);
134135
}
135-
Context context = getReactApplicationContext().getApplicationContext();
136-
Fresco.initialize(context, mConfig);
136+
Fresco.initialize(reactContext.getApplicationContext(), mConfig);
137137
sHasBeenInitialized = true;
138138
} else if (mConfig != null) {
139139
FLog.w(
@@ -219,11 +219,7 @@ private ImagePipeline getImagePipeline() {
219219

220220
@Override
221221
public void invalidate() {
222+
getReactApplicationContext().removeLifecycleEventListener(this);
222223
super.invalidate();
223-
224-
ReactApplicationContext applicationContext = getReactApplicationContextIfActiveOrWarn();
225-
if (applicationContext != null) {
226-
applicationContext.removeLifecycleEventListener(this);
227-
}
228224
}
229225
}

0 commit comments

Comments
 (0)