123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- 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<>();
- }
- /* access modifiers changed from: protected */
- public Void doInBackground(Void... voidArr) {
- Bitmap bitmap;
- EPLog.d(TAG, "Enter doInBackground");
- ContentResolver resolver = getResolver();
- while (true) {
- ImageItem first = getFirst();
- if ((first != null || !this.finish) && !isCancelled()) {
- if (first == null) {
- try {
- EPLog.d(TAG, "Wait doInBackground");
- Thread.sleep(100);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- } else {
- try {
- EPLog.d(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.d(TAG, "Enter suspend");
- while (this.suspend && !isCancelled()) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException unused) {
- }
- }
- EPLog.d(TAG, "Leave suspend");
- }
- }
- }
- }
- EPLog.d(TAG, "Leave doInBackground");
- return null;
- }
- /* access modifiers changed from: protected */
- public void onProgressUpdate(ImageItem... imageItemArr) {
- ImageGridFragment imageGridFragment = (ImageGridFragment) this.mFragmentReference.get();
- if (imageGridFragment != null && imageItemArr != null && imageItemArr.length > 0) {
- imageGridFragment.updateItem(imageItemArr[0]);
- }
- }
- private synchronized ImageItem getFirst() {
- if (this.imageItems != null) {
- if (this.imageItems.size() > 0) {
- return this.imageItems.remove(0);
- }
- }
- return null;
- }
- /* access modifiers changed from: package-private */
- /* JADX WARNING: Code restructure failed: missing block: B:12:0x0037, code lost:
- return;
- */
- /* Code decompiled incorrectly, please refer to instructions dump. */
- public synchronized void moveToFirst(epson.print.ImageItem r5) {
- /*
- r4 = this;
- monitor-enter(r4)
- java.util.LinkedList<epson.print.ImageItem> r0 = r4.imageItems // Catch:{ all -> 0x0038 }
- if (r0 != 0) goto L_0x0007
- monitor-exit(r4)
- return
- L_0x0007:
- java.util.LinkedList<epson.print.ImageItem> r0 = r4.imageItems // Catch:{ all -> 0x0038 }
- int r0 = r0.indexOf(r5) // Catch:{ all -> 0x0038 }
- r1 = -1
- if (r0 != r1) goto L_0x0011
- goto L_0x0036
- L_0x0011:
- java.lang.String r1 = "ImageThumbnailTask"
- java.lang.StringBuilder r2 = new java.lang.StringBuilder // Catch:{ all -> 0x0038 }
- r2.<init>() // Catch:{ all -> 0x0038 }
- java.lang.String r3 = "moveToFirst "
- r2.append(r3) // Catch:{ all -> 0x0038 }
- java.lang.String r5 = r5.getPath() // Catch:{ all -> 0x0038 }
- r2.append(r5) // Catch:{ all -> 0x0038 }
- java.lang.String r5 = r2.toString() // Catch:{ all -> 0x0038 }
- epson.print.Util.EPLog.d(r1, r5) // Catch:{ all -> 0x0038 }
- java.util.LinkedList<epson.print.ImageItem> r5 = r4.imageItems // Catch:{ all -> 0x0038 }
- java.util.LinkedList<epson.print.ImageItem> r1 = r4.imageItems // Catch:{ all -> 0x0038 }
- java.lang.Object r0 = r1.remove(r0) // Catch:{ all -> 0x0038 }
- r5.addFirst(r0) // Catch:{ all -> 0x0038 }
- L_0x0036:
- monitor-exit(r4)
- return
- L_0x0038:
- r5 = move-exception
- monitor-exit(r4)
- throw r5
- */
- throw new UnsupportedOperationException("Method not decompiled: epson.print.imgsel.ImageThumbnailTask.moveToFirst(epson.print.ImageItem):void");
- }
- private 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();
- }
- }
|