Mark SupportAlertFragment and AlertFragment as Public to fix crash is…

Summary:
Hi,
This changelist is for fixing a crash issue on Android devices. For detail please see, https://github.com/facebook/react-native/issues/7080

In short, the crash occurred when a RN app with a Alert dialog shown at front switches back after it is destroyed at background due to lack of phone memory.

My fix is to let those Alert fragment classes accessible from android.support.v4.app.Fragment instantiate() function, so that it won't crash. And since other UI will be reloaded whatever, mListener is set to null to avoid any callback happen.
Closes https://github.com/facebook/react-native/pull/7105

Differential Revision: D3212435

Pulled By: mkonicek

fbshipit-source-id: d900a33a4f0fd49258be94c277def55555ec8d73
This commit is contained in:
Yu Zheng(Sam) 2016-05-16 12:45:55 -07:00 committed by Facebook Github Bot 1
parent aac7f5b362
commit 67d9a7bae9
2 changed files with 10 additions and 2 deletions

View File

@ -21,7 +21,7 @@ import android.os.Bundle;
/**
* A fragment used to display the dialog.
*/
/* package */ class AlertFragment extends DialogFragment implements DialogInterface.OnClickListener {
public class AlertFragment extends DialogFragment implements DialogInterface.OnClickListener {
/* package */ static final String ARG_TITLE = "title";
/* package */ static final String ARG_MESSAGE = "message";
@ -32,6 +32,10 @@ import android.os.Bundle;
private final @Nullable DialogModule.AlertFragmentListener mListener;
public AlertFragment() {
mListener = null;
}
public AlertFragment(@Nullable DialogModule.AlertFragmentListener listener, Bundle arguments) {
mListener = listener;
setArguments(arguments);

View File

@ -21,10 +21,14 @@ import android.support.v4.app.DialogFragment;
* {@link AlertFragment} for apps that use the Support FragmentActivity and FragmentManager
* for legacy reasons.
*/
/* package */ class SupportAlertFragment extends DialogFragment implements DialogInterface.OnClickListener {
public class SupportAlertFragment extends DialogFragment implements DialogInterface.OnClickListener {
private final @Nullable DialogModule.AlertFragmentListener mListener;
public SupportAlertFragment() {
mListener = null;
}
public SupportAlertFragment(@Nullable DialogModule.AlertFragmentListener listener, Bundle arguments) {
mListener = listener;
setArguments(arguments);