MessageView: check for null mMessageContentView on access.

Bug 2148358.

It seems that AsyncTask.onPostExecute() can be invoked even after the task
was cancelled, and after Activity.onDestroy().
This commit is contained in:
Mihai Preda 2009-09-28 16:47:25 +02:00
parent 4c8f06283f
commit 7f025a15c4

View File

@ -190,7 +190,9 @@ public class MessageView extends Activity implements OnClickListener {
break; break;
case MSG_LOAD_CONTENT_URI: case MSG_LOAD_CONTENT_URI:
String uriString = (String) msg.obj; String uriString = (String) msg.obj;
if (mMessageContentView != null) {
mMessageContentView.loadUrl(uriString); mMessageContentView.loadUrl(uriString);
}
break; break;
case MSG_SET_ATTACHMENTS_ENABLED: case MSG_SET_ATTACHMENTS_ENABLED:
for (int i = 0, count = mAttachments.getChildCount(); i < count; i++) { for (int i = 0, count = mAttachments.getChildCount(); i < count; i++) {
@ -666,7 +668,9 @@ public class MessageView extends Activity implements OnClickListener {
private void onShowPictures() { private void onShowPictures() {
if (mMessage != null) { if (mMessage != null) {
if (mMessageContentView != null) {
mMessageContentView.getSettings().setBlockNetworkImage(false); mMessageContentView.getSettings().setBlockNetworkImage(false);
}
mShowPicturesSection.setVisibility(View.GONE); mShowPicturesSection.setVisibility(View.GONE);
} }
} }
@ -763,7 +767,9 @@ public class MessageView extends Activity implements OnClickListener {
} }
cancelAllTasks(); cancelAllTasks();
setTitle(""); setTitle("");
if (mMessageContentView != null) {
mMessageContentView.loadUrl("file:///android_asset/empty.html"); mMessageContentView.loadUrl("file:///android_asset/empty.html");
}
mAttachments.removeAllViews(); mAttachments.removeAllViews();
mAttachments.setVisibility(View.GONE); mAttachments.setVisibility(View.GONE);
mAttachmentIcon.setVisibility(View.GONE); mAttachmentIcon.setVisibility(View.GONE);
@ -1172,7 +1178,7 @@ public class MessageView extends Activity implements OnClickListener {
addAttachment(attachment); addAttachment(attachment);
} }
} }
if (htmlChanged) { if (htmlChanged && mMessageContentView != null) {
mMessageContentView.loadDataWithBaseURL("email://", mHtmlText, "text/html", "utf-8", mMessageContentView.loadDataWithBaseURL("email://", mHtmlText, "text/html", "utf-8",
null); null);
} }
@ -1291,7 +1297,9 @@ public class MessageView extends Activity implements OnClickListener {
} }
mShowPicturesSection.setVisibility(hasImages ? View.VISIBLE : View.GONE); mShowPicturesSection.setVisibility(hasImages ? View.VISIBLE : View.GONE);
if (mMessageContentView != null) {
mMessageContentView.loadDataWithBaseURL("email://", text, "text/html", "utf-8", null); mMessageContentView.loadDataWithBaseURL("email://", text, "text/html", "utf-8", null);
}
// Ask for attachments after body // Ask for attachments after body
mLoadAttachmentsTask = new LoadAttachmentsTask(); mLoadAttachmentsTask = new LoadAttachmentsTask();