Skip to content

Commit

Permalink
Add Context to Redbox report api
Browse files Browse the repository at this point in the history
Differential Revision: D6700021

fbshipit-source-id: b8ba8242a68c02e608900c93a7645d61158cc0cb
  • Loading branch information
ayc1 authored and facebook-github-bot committed Jan 11, 2018
1 parent 8f358a2 commit e3c27f5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public void run() {
// JS errors are reported here after source mapping.
if (mRedBoxHandler != null) {
mRedBoxHandler.handleRedbox(message, stack, RedBoxHandler.ErrorType.JS);
mRedBoxDialog.resetReporting(true);
mRedBoxDialog.resetReporting();
}
mRedBoxDialog.show();
}
Expand Down Expand Up @@ -403,10 +403,8 @@ public void run() {
// inside {@link #updateJSError} after source mapping.
if (mRedBoxHandler != null && errorType == ErrorType.NATIVE) {
mRedBoxHandler.handleRedbox(message, stack, RedBoxHandler.ErrorType.NATIVE);
mRedBoxDialog.resetReporting(true);
} else {
mRedBoxDialog.resetReporting(false);
}
mRedBoxDialog.resetReporting();
mRedBoxDialog.show();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,11 @@ public void onClick(View view) {
String sourceUrl = mDevSupportManager.getSourceUrl();

mRedBoxHandler.reportRedbox(
title,
stack,
sourceUrl,
Assertions.assertNotNull(mReportCompletedListener));
view.getContext(),
title,
stack,
sourceUrl,
Assertions.assertNotNull(mReportCompletedListener));
}
};

Expand Down Expand Up @@ -322,16 +323,15 @@ public void setExceptionDetails(String title, StackFrame[] stack) {
/**
* Show the report button, hide the report textview and the loading indicator.
*/
public void resetReporting(boolean enabled) {
public void resetReporting() {
if (mRedBoxHandler == null || !mRedBoxHandler.isReportEnabled()) {
return;
}
isReporting = false;
Assertions.assertNotNull(mReportTextView).setVisibility(View.GONE);
Assertions.assertNotNull(mLoadingIndicator).setVisibility(View.GONE);
Assertions.assertNotNull(mLineSeparator).setVisibility(View.GONE);
Assertions.assertNotNull(mReportButton).setVisibility(
enabled ? View.VISIBLE : View.GONE);
Assertions.assertNotNull(mReportButton).setVisibility(View.VISIBLE);
Assertions.assertNotNull(mReportButton).setEnabled(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

package com.facebook.react.devsupport;

import android.content.Context;
import android.text.SpannedString;

import com.facebook.react.devsupport.interfaces.StackFrame;
Expand Down Expand Up @@ -54,8 +55,9 @@ interface ReportCompletedListener {
* Report the information from the redbox and set up a callback listener.
*/
void reportRedbox(
String title,
StackFrame[] stack,
String sourceUrl,
ReportCompletedListener reportCompletedListener);
Context context,
String title,
StackFrame[] stack,
String sourceUrl,
ReportCompletedListener reportCompletedListener);
}

0 comments on commit e3c27f5

Please sign in to comment.