1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- package epson.print.imgsel;
- import android.content.ContentResolver;
- import android.graphics.Bitmap;
- import android.os.AsyncTask;
- import epson.print.ImageItem;
- import epson.print.imgsel.ImageFinder;
- import java.lang.ref.WeakReference;
- import java.util.ArrayList;
- import java.util.List;
- class ImageFindTask extends AsyncTask<ImageFinder, List<ImageItem>, Void> implements ImageFinder.Canceller {
- private static int IMAGE_QUERY_LIMIT = 32;
- String mFolderPath;
- WeakReference<ImageGridFragment> mFragmentReference;
- public ImageFindTask(ImageGridFragment imageGridFragment, String str) {
- this.mFragmentReference = new WeakReference<>(imageGridFragment);
- this.mFolderPath = str;
- }
- /* access modifiers changed from: protected */
- public Void doInBackground(ImageFinder... imageFinderArr) {
- ImageGridFragment imageGridFragment;
- List<ImageFileInfo> findImageInDirectory;
- if (imageFinderArr == null || imageFinderArr.length <= 0) {
- return null;
- }
- ImageFinder imageFinder = imageFinderArr[0];
- if (!(isCancelled() || imageFinder == null || (imageGridFragment = (ImageGridFragment) this.mFragmentReference.get()) == null || imageGridFragment.getActivity() == null || isCancelled() || (findImageInDirectory = imageFinder.findImageInDirectory(this.mFolderPath, getResolver(), this)) == null)) {
- ArrayList arrayList = new ArrayList();
- for (ImageFileInfo next : findImageInDirectory) {
- if (isCancelled()) {
- return null;
- }
- boolean isImageSelected = isImageSelected(next.mCanonicalPath);
- arrayList.add(new ImageItem((Bitmap) null, isImageSelected ? 1 : 0, next.mCanonicalPath, next.mMediaInfoId));
- if (arrayList.size() % IMAGE_QUERY_LIMIT == 0) {
- publishProgress(new List[]{arrayList});
- arrayList = new ArrayList();
- }
- }
- if (arrayList.size() > 0) {
- publishProgress(new List[]{arrayList});
- }
- }
- return null;
- }
- private ContentResolver getResolver() {
- FragmentActivity activity;
- ImageGridFragment imageGridFragment = (ImageGridFragment) this.mFragmentReference.get();
- if (imageGridFragment == null || (activity = imageGridFragment.getActivity()) == null) {
- return null;
- }
- return activity.getContentResolver();
- }
- private boolean isImageSelected(String str) {
- ImageGridFragment imageGridFragment = (ImageGridFragment) this.mFragmentReference.get();
- if (imageGridFragment == null) {
- return false;
- }
- return imageGridFragment.isImageSelected(str);
- }
- public boolean checkCanceled() {
- return isCancelled();
- }
- /* access modifiers changed from: protected */
- public void onPreExecute() {
- ImageGridFragment imageGridFragment = (ImageGridFragment) this.mFragmentReference.get();
- if (imageGridFragment != null) {
- imageGridFragment.clearItem();
- }
- }
- /* access modifiers changed from: protected */
- public void onProgressUpdate(List<ImageItem>... listArr) {
- ImageGridFragment imageGridFragment = (ImageGridFragment) this.mFragmentReference.get();
- if (imageGridFragment != null && listArr != null && listArr.length > 0) {
- imageGridFragment.addItem(listArr[0]);
- }
- }
- /* access modifiers changed from: protected */
- public void onPostExecute(Void voidR) {
- ImageGridFragment imageGridFragment = (ImageGridFragment) this.mFragmentReference.get();
- if (imageGridFragment != null) {
- imageGridFragment.updateData();
- }
- }
- }
|