我正在尝试将GifTextView
用于我的动画。这AsyncTask
实际上有效,但是当我使用GifTextView
时需要很长时间。如果从此代码中删除GifTextView
,则AsyncTask
可以快速运行。
public class PDFCreate extends AsyncTask<String,String,String> {
@Override
protected String doInBackground(String... strings) {
String FILE = Environment.getExternalStorageDirectory().toString()
+"/TEST/PDF/"+Ex_date+".pdf";
try {
Document document = new Document(PageSize.A4);
String root = Environment.getExternalStorageDirectory().toString();
File myDir = new File(root + "/TEST/PDF");
myDir.mkdirs();
PdfWriter.getInstance(document, new FileOutputStream(FILE));
document.open();
addMetaData(document,"LEAKS");
addTitlePage(document,Ex_title);
document.close();
} catch (DocumentException e) {
FILE = "Error Create Document";
} catch (FileNotFoundException e) {
FILE = "Cannot Create Document Path";
}
return FILE;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
GifTextView git = (GifTextView) findViewById(R.id.loading_gift);
git.setVisibility(View.VISIBLE);
}
@Override
protected void onPostExecute(String st) {
super.onPostExecute(st);
git.setVisibility(View.GONE);
ViewDialog alert = new ViewDialog();
alert.showDialog(detail.this,"File have been saved on : \n" + st);
}
}
我的问题是,如何在不降低程序速度的情况下使用GifTextView
?
答案 0 :(得分:1)
EthicsDev ok谢谢。最后我使用Glide来加快我的AsyncTask。删除GifTextView
与
ImageView imageView = (ImageView) findViewById(R.id.loading_gift);
GlideDrawableImageViewTarget imageViewTarget = new GlideDrawableImageViewTarget(imageView);
Glide.with(leaks_detail.this).load(R.drawable.loading).override(200,200)
.into(imageViewTarget);