123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- package epson.print.imgsel;
- import android.content.ContentResolver;
- import android.graphics.Bitmap;
- import android.os.AsyncTask;
- import epson.print.ImageItem;
- import epson.print.Util.EPLog;
- import epson.print.imgsel.ImageFinder;
- import java.io.IOException;
- import java.lang.ref.WeakReference;
- import java.util.LinkedList;
- public class ImageThumbnailTask extends AsyncTask<Void, ImageItem, Void> implements ImageFinder.Canceller {
- private static final int RETRY_CHECKLIST = 100;
- private static final int RETRY_SUSPEND = 1000;
- private static final String TAG = "ImageThumbnailTask";
- private volatile boolean finish = false;
- private volatile LinkedList<ImageItem> imageItems;
- WeakReference<ImageGridFragment> mFragmentReference;
- private volatile boolean suspend = false;
- public ImageThumbnailTask(ImageGridFragment imageGridFragment) {
- this.mFragmentReference = new WeakReference<>(imageGridFragment);
- this.imageItems = new LinkedList<>();
- }
-
- public Void doInBackground(Void... voidArr) {
- Bitmap bitmap;
- EPLog.m305d(TAG, "Enter doInBackground");
- ContentResolver resolver = getResolver();
- while (true) {
- ImageItem first = getFirst();
- if ((first != null || !this.finish) && !isCancelled()) {
- if (first == null) {
- try {
- EPLog.m305d(TAG, "Wait doInBackground");
- Thread.sleep(100);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- } else {
- try {
- EPLog.m305d(TAG, "createThumbnail " + first.getPath());
- bitmap = AltThumbnailCache.createThumbnail(first.getPath(), resolver, first.getDatabaseId());
- } catch (IOException e2) {
- e2.printStackTrace();
- bitmap = null;
- }
- publishProgress(new ImageItem[]{new ImageItem(bitmap, 0, first.getPath(), first.getDatabaseId())});
- if (this.suspend) {
- EPLog.m305d(TAG, "Enter suspend");
- while (this.suspend && !isCancelled()) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException unused) {
- }
- }
- EPLog.m305d(TAG, "Leave suspend");
- }
- }
- }
- }
- EPLog.m305d(TAG, "Leave doInBackground");
- return null;
- }
-
- public void onProgressUpdate(ImageItem... imageItemArr) {
- ImageGridFragment imageGridFragment = (ImageGridFragment) this.mFragmentReference.get();
- if (imageGridFragment != null && imageItemArr != null && imageItemArr.length > 0) {
- imageGridFragment.updateItem(imageItemArr[0]);
- }
- }
-
- public synchronized ImageItem getFirst() {
- if (this.imageItems != null) {
- if (this.imageItems.size() > 0) {
- return this.imageItems.remove(0);
- }
- }
- return null;
- }
-
-
-
- public synchronized void moveToFirst(epson.print.ImageItem r5) {
-
- throw new UnsupportedOperationException("Method not decompiled: epson.print.imgsel.ImageThumbnailTask.moveToFirst(epson.print.ImageItem):void");
- }
-
- public synchronized void addLast(ImageItem imageItem) {
- if (this.imageItems != null) {
- this.imageItems.addLast(imageItem);
- }
- }
- public void setFinish(boolean z) {
- this.finish = z;
- }
- public void setSuspend(boolean z) {
- this.suspend = z;
- }
- private ContentResolver getResolver() {
- FragmentActivity activity;
- ImageGridFragment imageGridFragment = (ImageGridFragment) this.mFragmentReference.get();
- if (imageGridFragment == null || (activity = imageGridFragment.getActivity()) == null) {
- return null;
- }
- return activity.getContentResolver();
- }
- public boolean checkCanceled() {
- return isCancelled();
- }
- }
|