mirror of
https://github.com/moparisthebest/k-9
synced 2025-02-25 15:11:52 -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.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -149,7 +150,7 @@ public class AttachmentView extends FrameLayout implements OnClickListener, OnLo
|
|||||||
contentType = MimeUtility.getMimeTypeForViewing(part.getMimeType(), name);
|
contentType = MimeUtility.getMimeTypeForViewing(part.getMimeType(), name);
|
||||||
TextView attachmentName = (TextView) findViewById(R.id.attachment_name);
|
TextView attachmentName = (TextView) findViewById(R.id.attachment_name);
|
||||||
TextView attachmentInfo = (TextView) findViewById(R.id.attachment_info);
|
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);
|
viewButton = (Button) findViewById(R.id.view);
|
||||||
downloadButton = (Button) findViewById(R.id.download);
|
downloadButton = (Button) findViewById(R.id.download);
|
||||||
if ((!MimeUtility.mimeTypeMatches(contentType, K9.ACCEPTABLE_ATTACHMENT_VIEW_TYPES))
|
if ((!MimeUtility.mimeTypeMatches(contentType, K9.ACCEPTABLE_ATTACHMENT_VIEW_TYPES))
|
||||||
@ -171,12 +172,20 @@ public class AttachmentView extends FrameLayout implements OnClickListener, OnLo
|
|||||||
|
|
||||||
attachmentName.setText(name);
|
attachmentName.setText(name);
|
||||||
attachmentInfo.setText(SizeFormatter.formatSize(mContext, size));
|
attachmentInfo.setText(SizeFormatter.formatSize(mContext, size));
|
||||||
|
new AsyncTask<Void, Void, Bitmap>() {
|
||||||
|
protected Bitmap doInBackground(Void... asyncTaskArgs) {
|
||||||
Bitmap previewIcon = getPreviewIcon();
|
Bitmap previewIcon = getPreviewIcon();
|
||||||
|
return previewIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onPostExecute(Bitmap previewIcon) {
|
||||||
if (previewIcon != null) {
|
if (previewIcon != null) {
|
||||||
attachmentIcon.setImageBitmap(previewIcon);
|
attachmentIcon.setImageBitmap(previewIcon);
|
||||||
} else {
|
} else {
|
||||||
attachmentIcon.setImageResource(R.drawable.attached_image_placeholder);
|
attachmentIcon.setImageResource(R.drawable.attached_image_placeholder);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}.execute();
|
||||||
|
|
||||||
return firstClassAttachment;
|
return firstClassAttachment;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user