1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 19:52:17 -05:00

Moving a few more things to UI thread as message are not displayed reliably

This commit is contained in:
Bao-Long Nguyen-Trong 2009-10-07 18:19:56 +00:00
parent 791d99fc7a
commit b3616e379d

View File

@ -155,7 +155,7 @@ public class MessageView extends K9Activity
private Listener mListener = new Listener(); private Listener mListener = new Listener();
private MessageViewHandler mHandler = new MessageViewHandler(); private MessageViewHandler mHandler = new MessageViewHandler();
public boolean onKeyDown(int keyCode, KeyEvent event) { public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) { switch (keyCode) {
case KeyEvent.KEYCODE_DEL: { onDelete(); return true;} case KeyEvent.KEYCODE_DEL: { onDelete(); return true;}
case KeyEvent.KEYCODE_D: { onDelete(); return true;} case KeyEvent.KEYCODE_D: { onDelete(); return true;}
@ -171,20 +171,30 @@ public class MessageView extends K9Activity
{ onPrevious(); return true; } { onPrevious(); return true; }
case KeyEvent.KEYCODE_N: case KeyEvent.KEYCODE_N:
case KeyEvent.KEYCODE_K: { onNext(); return true; } case KeyEvent.KEYCODE_K: { onNext(); return true; }
case KeyEvent.KEYCODE_Z: { if (event.isShiftPressed()) { case KeyEvent.KEYCODE_Z: {
mMessageContentView.zoomIn(); if (event.isShiftPressed()) {
} else { mHandler.post(new Runnable() {
mMessageContentView.zoomOut(); public void run() {
} mMessageContentView.zoomIn();
return true; } }
});
case KeyEvent.KEYCODE_H: { } else {
mHandler.post(new Runnable() {
public void run() {
mMessageContentView.zoomOut();
}
});
}
return true;
}
case KeyEvent.KEYCODE_H: {
Toast toast = Toast.makeText(this, R.string.message_help_key, Toast.LENGTH_LONG); Toast toast = Toast.makeText(this, R.string.message_help_key, Toast.LENGTH_LONG);
toast.show(); toast.show();
return true; } return true;
} }
return super.onKeyDown(keyCode, event);
} }
return super.onKeyDown(keyCode, event);
}
class MessageViewHandler extends Handler { class MessageViewHandler extends Handler {
private static final int MSG_PROGRESS = 2; private static final int MSG_PROGRESS = 2;
@ -1162,11 +1172,20 @@ public class MessageView extends K9Activity
* TODO this should be smarter, change to regex for img, but consider how to * TODO this should be smarter, change to regex for img, but consider how to
* get background images and a million other things that HTML allows. * get background images and a million other things that HTML allows.
*/ */
mMessageContentView.loadDataWithBaseURL("email://", text, "text/html", "utf-8", null); final String emailText = text;
mHandler.post(new Runnable() {
public void run() {
mMessageContentView.loadDataWithBaseURL("email://", emailText, "text/html", "utf-8", null);
}
});
mHandler.showShowPictures(text.contains("<img")); mHandler.showShowPictures(text.contains("<img"));
} }
else { else {
mMessageContentView.loadUrl("file:///android_asset/empty.html"); mHandler.post(new Runnable() {
public void run() {
mMessageContentView.loadUrl("file:///android_asset/empty.html");
}
});
} }
renderAttachments(mMessage, 0); renderAttachments(mMessage, 0);
@ -1218,7 +1237,7 @@ public class MessageView extends K9Activity
mHandler.post(new Runnable() { mHandler.post(new Runnable() {
public void run() { public void run() {
mMessageContentView.loadUrl("file:///android_asset/loading.html"); mMessageContentView.loadUrl("file:///android_asset/loading.html");
setProgressBarIndeterminateVisibility(true); setProgressBarIndeterminateVisibility(true);
} }
}); });
} }