Skip to content

Commit

Permalink
Fixed some crashes caused by dialog dismissals in the FB library
Browse files Browse the repository at this point in the history
  • Loading branch information
sbosley committed Jun 5, 2012
1 parent b99454d commit dc90078
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions facebook/facebook/src/com/facebook/android/FbDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private void createCrossImage() {
@Override
public void onClick(View v) {
mListener.onCancel();
FbDialog.this.dismiss();
tryDismissDialog(FbDialog.this);
}
});
Drawable crossDrawable = getContext().getResources().getDrawable(R.drawable.close);
Expand Down Expand Up @@ -149,11 +149,11 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
mListener.onFacebookError(new FacebookError(error));
}

FbDialog.this.dismiss();
tryDismissDialog(FbDialog.this);
return true;
} else if (url.startsWith(Facebook.CANCEL_URI)) {
mListener.onCancel();
FbDialog.this.dismiss();
tryDismissDialog(FbDialog.this);
return true;
} else if (url.contains(DISPLAY_STRING)) {
return false;
Expand All @@ -170,20 +170,24 @@ public void onReceivedError(WebView view, int errorCode,
super.onReceivedError(view, errorCode, description, failingUrl);
mListener.onError(
new DialogError(description, errorCode, failingUrl));
FbDialog.this.dismiss();
tryDismissDialog(FbDialog.this);
}

@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
Util.logd("Facebook-WebView", "Webview loading URL: " + url);
super.onPageStarted(view, url, favicon);
mSpinner.show();
try {
mSpinner.show();
} catch (Exception e) {
// Activity killed or something
}
}

@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
mSpinner.dismiss();
tryDismissDialog(mSpinner);
/*
* Once webview is fully loaded, set the mContent background to be transparent
* and make visible the 'x' image.
Expand All @@ -193,4 +197,12 @@ public void onPageFinished(WebView view, String url) {
mCrossImage.setVisibility(View.VISIBLE);
}
}

private void tryDismissDialog(Dialog d) {
try {
d.dismiss();
} catch (Exception e) {
// Activity was killed or something
}
}
}

0 comments on commit dc90078

Please sign in to comment.