mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 11:42:16 -05:00
Put long-running operation into AsyncTask
This commit is contained in:
parent
abc765e893
commit
fa7118dab3
@ -14,6 +14,7 @@ import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Environment;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
@ -149,7 +150,7 @@ public class AttachmentView extends FrameLayout implements OnClickListener, OnLo
|
||||
contentType = MimeUtility.getMimeTypeForViewing(part.getMimeType(), name);
|
||||
TextView attachmentName = (TextView) findViewById(R.id.attachment_name);
|
||||
TextView attachmentInfo = (TextView) findViewById(R.id.attachment_info);
|
||||
ImageView attachmentIcon = (ImageView) findViewById(R.id.attachment_icon);
|
||||
final ImageView attachmentIcon = (ImageView) findViewById(R.id.attachment_icon);
|
||||
viewButton = (Button) findViewById(R.id.view);
|
||||
downloadButton = (Button) findViewById(R.id.download);
|
||||
if ((!MimeUtility.mimeTypeMatches(contentType, K9.ACCEPTABLE_ATTACHMENT_VIEW_TYPES))
|
||||
@ -171,12 +172,20 @@ public class AttachmentView extends FrameLayout implements OnClickListener, OnLo
|
||||
|
||||
attachmentName.setText(name);
|
||||
attachmentInfo.setText(SizeFormatter.formatSize(mContext, size));
|
||||
new AsyncTask<Void, Void, Bitmap>() {
|
||||
protected Bitmap doInBackground(Void... asyncTaskArgs) {
|
||||
Bitmap previewIcon = getPreviewIcon();
|
||||
return previewIcon;
|
||||
}
|
||||
|
||||
protected void onPostExecute(Bitmap previewIcon) {
|
||||
if (previewIcon != null) {
|
||||
attachmentIcon.setImageBitmap(previewIcon);
|
||||
} else {
|
||||
attachmentIcon.setImageResource(R.drawable.attached_image_placeholder);
|
||||
}
|
||||
}
|
||||
}.execute();
|
||||
|
||||
return firstClassAttachment;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user