Skip to content

Commit e3c27f5

Browse files
ayc1facebook-github-bot
authored andcommitted
Add Context to Redbox report api
Differential Revision: D6700021 fbshipit-source-id: b8ba8242a68c02e608900c93a7645d61158cc0cb
1 parent 8f358a2 commit e3c27f5

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ public void run() {
350350
// JS errors are reported here after source mapping.
351351
if (mRedBoxHandler != null) {
352352
mRedBoxHandler.handleRedbox(message, stack, RedBoxHandler.ErrorType.JS);
353-
mRedBoxDialog.resetReporting(true);
353+
mRedBoxDialog.resetReporting();
354354
}
355355
mRedBoxDialog.show();
356356
}
@@ -403,10 +403,8 @@ public void run() {
403403
// inside {@link #updateJSError} after source mapping.
404404
if (mRedBoxHandler != null && errorType == ErrorType.NATIVE) {
405405
mRedBoxHandler.handleRedbox(message, stack, RedBoxHandler.ErrorType.NATIVE);
406-
mRedBoxDialog.resetReporting(true);
407-
} else {
408-
mRedBoxDialog.resetReporting(false);
409406
}
407+
mRedBoxDialog.resetReporting();
410408
mRedBoxDialog.show();
411409
}
412410
});

ReactAndroid/src/main/java/com/facebook/react/devsupport/RedBoxDialog.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,11 @@ public void onClick(View view) {
9999
String sourceUrl = mDevSupportManager.getSourceUrl();
100100

101101
mRedBoxHandler.reportRedbox(
102-
title,
103-
stack,
104-
sourceUrl,
105-
Assertions.assertNotNull(mReportCompletedListener));
102+
view.getContext(),
103+
title,
104+
stack,
105+
sourceUrl,
106+
Assertions.assertNotNull(mReportCompletedListener));
106107
}
107108
};
108109

@@ -322,16 +323,15 @@ public void setExceptionDetails(String title, StackFrame[] stack) {
322323
/**
323324
* Show the report button, hide the report textview and the loading indicator.
324325
*/
325-
public void resetReporting(boolean enabled) {
326+
public void resetReporting() {
326327
if (mRedBoxHandler == null || !mRedBoxHandler.isReportEnabled()) {
327328
return;
328329
}
329330
isReporting = false;
330331
Assertions.assertNotNull(mReportTextView).setVisibility(View.GONE);
331332
Assertions.assertNotNull(mLoadingIndicator).setVisibility(View.GONE);
332333
Assertions.assertNotNull(mLineSeparator).setVisibility(View.GONE);
333-
Assertions.assertNotNull(mReportButton).setVisibility(
334-
enabled ? View.VISIBLE : View.GONE);
334+
Assertions.assertNotNull(mReportButton).setVisibility(View.VISIBLE);
335335
Assertions.assertNotNull(mReportButton).setEnabled(true);
336336
}
337337

ReactAndroid/src/main/java/com/facebook/react/devsupport/RedBoxHandler.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
package com.facebook.react.devsupport;
1111

12+
import android.content.Context;
1213
import android.text.SpannedString;
1314

1415
import com.facebook.react.devsupport.interfaces.StackFrame;
@@ -54,8 +55,9 @@ interface ReportCompletedListener {
5455
* Report the information from the redbox and set up a callback listener.
5556
*/
5657
void reportRedbox(
57-
String title,
58-
StackFrame[] stack,
59-
String sourceUrl,
60-
ReportCompletedListener reportCompletedListener);
58+
Context context,
59+
String title,
60+
StackFrame[] stack,
61+
String sourceUrl,
62+
ReportCompletedListener reportCompletedListener);
6163
}

0 commit comments

Comments
 (0)