import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
-import java.util.List;
+import java.util.LinkedList;
import java.util.Locale;
import java.util.Vector;
import java.util.regex.Matcher;
.show();
}
+ // Container class for the next error dialog that needs to be
+ // displayed.
+ class ErrorDialog {
+ public final int mTitle;
+ public final String mDescription;
+ public final int mError;
+ ErrorDialog(int title, String desc, int error) {
+ mTitle = title;
+ mDescription = desc;
+ mError = error;
+ }
+ };
+
+ private void processNextError() {
+ if (mQueuedErrors == null) {
+ return;
+ }
+ // The first one is currently displayed so just remove it.
+ mQueuedErrors.removeFirst();
+ if (mQueuedErrors.size() == 0) {
+ mQueuedErrors = null;
+ return;
+ }
+ showError(mQueuedErrors.getFirst());
+ }
+
+ private DialogInterface.OnDismissListener mDialogListener =
+ new DialogInterface.OnDismissListener() {
+ public void onDismiss(DialogInterface d) {
+ processNextError();
+ }
+ };
+ private LinkedList<ErrorDialog> mQueuedErrors;
+
+ private void queueError(int err, String desc) {
+ if (mQueuedErrors == null) {
+ mQueuedErrors = new LinkedList<ErrorDialog>();
+ }
+ for (ErrorDialog d : mQueuedErrors) {
+ if (d.mError == err) {
+ // Already saw a similar error, ignore the new one.
+ return;
+ }
+ }
+ ErrorDialog errDialog = new ErrorDialog(
+ err == EventHandler.FILE_NOT_FOUND_ERROR ?
+ R.string.browserFrameFileErrorLabel :
+ R.string.browserFrameNetworkErrorLabel,
+ desc, err);
+ mQueuedErrors.addLast(errDialog);
+
+ // Show the dialog now if the queue was empty.
+ if (mQueuedErrors.size() == 1) {
+ showError(errDialog);
+ }
+ }
+
+ private void showError(ErrorDialog errDialog) {
+ AlertDialog d = new AlertDialog.Builder(BrowserActivity.this)
+ .setTitle(errDialog.mTitle)
+ .setMessage(errDialog.mDescription)
+ .setPositiveButton(R.string.ok, null)
+ .create();
+ d.setOnDismissListener(mDialogListener);
+ d.show();
+ }
+
/**
* Show a dialog informing the user of the network error reported by
* WebCore.
errorCode != EventHandler.ERROR_BAD_URL &&
errorCode != EventHandler.ERROR_UNSUPPORTED_SCHEME &&
errorCode != EventHandler.FILE_ERROR) {
- new AlertDialog.Builder(BrowserActivity.this)
- .setTitle((errorCode == EventHandler.FILE_NOT_FOUND_ERROR) ?
- R.string.browserFrameFileErrorLabel :
- R.string.browserFrameNetworkErrorLabel)
- .setMessage(description)
- .setPositiveButton(R.string.ok, null)
- .show();
+ queueError(errorCode, description);
}
- Log.e(LOGTAG, "onReceivedError code:"+errorCode+" "+description);
+ Log.e(LOGTAG, "onReceivedError " + errorCode + " " + failingUrl
+ + " " + description);
// We need to reset the title after an error.
resetTitleAndRevertLockIcon();