android: Clear error only when the user explicitly dismisses the dialog
The previous code worked fine on rotation changes as the fragment is destroyed and recreated causing onCreate to be called, which restores the saved error state. But if the user switches to a different application and then back this is not the case. The dialog still gets dismissed (as we have to do so to avoid nasty exceptions on rotation changes) but since that implicitly cleared the error state the UI was never fully restored.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2012 Tobias Brunner
|
||||
* Copyright (C) 2012-2013 Tobias Brunner
|
||||
* Copyright (C) 2012 Giuliano Grassi
|
||||
* Copyright (C) 2012 Ralf Sager
|
||||
* Hochschule fuer Technik Rapperswil
|
||||
@@ -305,6 +305,12 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
|
||||
}
|
||||
}
|
||||
|
||||
private void clearError()
|
||||
{
|
||||
mError = ErrorState.NO_ERROR;
|
||||
updateView();
|
||||
}
|
||||
|
||||
private void showConnectDialog(String profile, String gateway)
|
||||
{
|
||||
mProgressDialog = new ProgressDialog(getActivity());
|
||||
@@ -345,6 +351,7 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
clearError();
|
||||
dialog.dismiss();
|
||||
Intent logIntent = new Intent(getActivity(), LogActivity.class);
|
||||
startActivity(logIntent);
|
||||
@@ -354,16 +361,15 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id)
|
||||
{
|
||||
clearError();
|
||||
dialog.dismiss();
|
||||
}
|
||||
}).create();
|
||||
mErrorDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog)
|
||||
{ /* clear the error */
|
||||
mError = ErrorState.NO_ERROR;
|
||||
{
|
||||
mErrorDialog = null;
|
||||
updateView();
|
||||
}
|
||||
});
|
||||
mErrorDialog.show();
|
||||
|
||||
Reference in New Issue
Block a user