Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.koushikdutta.ion;
  
 
 import java.io.File;
 import java.net.URI;
 
     String decodeKey;
     String bitmapKey;
     BitmapInfo info;
     boolean hasTransforms;
     int sampleWidth;
     int sampleHeight;
     boolean animateGif;
     boolean deepZoom;
 
     public void recomputeDecodeKey() {
          = IonBitmapRequestBuilder.computeDecodeKey(,
         );
          = IonBitmapRequestBuilder.computeBitmapKey();
     }
 
     private boolean fastLoad(String uri) {
         Ion ion = .;
         if () {
             if (uri == null || !uri.startsWith("file:/"))
                 return false;
             File file = new File(URI.create(uri));
             if (!file.exists())
                 return false;
             MediaFile.MediaFileType type = MediaFile.getFileType(file.getAbsolutePath());
             if (type == null || !MediaFile.isVideoFileType(type.fileType)) {
                 LoadDeepZoom loadDeepZoom = new LoadDeepZoom(ionnullnull);
                 loadDeepZoom.onCompleted(nullfile);
 //                System.out.println("fastloading deepZoom");
                 return true;
             }
             // fall through to allow some other loader to open this, cause this is a video file
         }
 
         boolean put = !;
 
         for (Loader loaderion.configure().getLoaders()) {
             Future<BitmapInfofuture = loader.loadBitmap(..getContext(), ionuri);
             if (future != null) {
                 final BitmapCallback callback = new LoadBitmapBase(ionput);
                 future.setCallback(new FutureCallback<BitmapInfo>() {
                     @Override
                     public void onCompleted(Exception eBitmapInfo result) {
                         callback.report(eresult);
                     }
                 });
 //                System.out.println("fastloading");
                 return true;
             }
         }
         return false;
     }
 
     public static final int MAX_IMAGEVIEW_LOAD = 5;
 
     public static boolean shouldDeferImageView(Ion ion) {
         if (ion.bitmapsPending.keySet().size() <= )
             return false;
         int loadCount = 0;
         for (String keyion.bitmapsPending.keySet()) {
             Object owner = ion.bitmapsPending.tag(key);
             if (owner instanceof LoadBitmapBase) {
                 loadCount++;
                 if (loadCount > )
                     return true;
             }
         }
         return false;
     }
 
     public DeferredLoadBitmap defer() {
         DeferredLoadBitmap ret = new DeferredLoadBitmap(.this);
         executeTransforms(.);
         return ret;
     }
 
     private void executeTransforms(Ion ion) {
         // if there's a transform, do it
        if (!)
            return;
        // verify this transform isn't already pending
        // make sure that the parent download isn't cancelled (empty list)
        // and also make sure there are waiters for this transformed bitmap
        if (ion.bitmapsPending.tag() == null) {
            ion.bitmapsPending.add(new TransformBitmap(ion));
        }
    }
    @Override
    public boolean loadRequest(AsyncHttpRequest request) {
        return !fastLoad(request.getUri().toString());
    }
    public void execute() {
        final Ion ion = .;
        // bitmaps that were transformed are put into the FileCache to prevent
        // subsequent retransformation. See if we can retrieve the bitmap from the disk cache.
        // See TransformBitmap for where the cache is populated.
        FileCache fileCache = ion.responseCache.getFileCache();
        if (!. && fileCache.exists() && !) {
            BitmapCallback.getBitmapSnapshot(ion);
            return;
        }
        // Perform a download as necessary.
        if (ion.bitmapsPending.tag() == null && !fastLoad(.)) {
            .setHandler(null);
            . = this;
            if (!) {
                IonRequestBuilder.EmitterTransform<ByteBufferListemitterTransform = .execute(new ByteBufferListParser(), new Runnable() {
                    @Override
                    public void run() {
                        AsyncServer.post(.new Runnable() {
                            @Override
                            public void run() {
                                ion.bitmapsPending.remove();
                            }
                        });
                    }
                });
                emitterTransform.setCallback(new LoadBitmap(ion, !emitterTransform));
            }
            else {
//                System.out.println("downloading file for deepZoom");
                File file = fileCache.getTempFile();
                IonRequestBuilder.EmitterTransform<FileemitterTransform = .write(file);
                LoadDeepZoom loadDeepZoom = new LoadDeepZoom(ionemitterTransformfileCache) {
                    @Override
                    public void onCompleted(Exception eFile file) {
                        super.onCompleted(efile);
                    }
                };
                emitterTransform.setCallback(loadDeepZoom);
            }
        }
        executeTransforms(ion);
    }
New to GrepCode? Check out our FAQ X