Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix for force closes where user rotates phone immediately after

submitting status update.

There is a common case where a user rotates the phone immediately
after submitting a status update. This causes the dialog and spinner
to be detached from the window manager. Any subsequent calls to
dismiss() on either the dialog or the spinner will cause the whole
app to force close.

This is easily resolved by implementing the onDetachedFromWindow
callback, and then stopping the dismiss calls.
  • Loading branch information...
commit 838d2c000d8f06a2758eb1545d14b0b8a55c031a 1 parent c58af0b
@martinlong1978 martinlong1978 authored
Showing with 20 additions and 2 deletions.
  1. +20 −2 facebook/src/com/facebook/android/FbDialog.java
View
22 facebook/src/com/facebook/android/FbDialog.java
@@ -58,6 +58,8 @@
private WebView mWebView;
private FrameLayout mContent;
+ private boolean detached = false;
+
public FbDialog(Context context, String url, DialogListener listener) {
super(context, android.R.style.Theme_Translucent_NoTitleBar);
mUrl = url;
@@ -65,6 +67,18 @@ public FbDialog(Context context, String url, DialogListener listener) {
}
@Override
+ public void onDetachedFromWindow() {
+ detached = true;
+ super.onDetachedFromWindow();
+ }
+
+ @Override
+ public void dismiss() {
+ if (!detached) {
+ super.dismiss();
+ }
+ }
+
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mSpinner = new ProgressDialog(getContext());
@@ -177,13 +191,17 @@ public void onReceivedError(WebView view, int errorCode,
public void onPageStarted(WebView view, String url, Bitmap favicon) {
Log.d("Facebook-WebView", "Webview loading URL: " + url);
super.onPageStarted(view, url, favicon);
- mSpinner.show();
+ if (!detached) {
+ mSpinner.show();
+ }
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
- mSpinner.dismiss();
+ if (!detached) {
+ mSpinner.dismiss();
+ }
/*
* Once webview is fully loaded, set the mContent background to be transparent
* and make visible the 'x' image.
Please sign in to comment.
Something went wrong with that request. Please try again.