Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.koushikdutta.ion;
  
  import  android.graphics.Bitmap;
  import  android.os.Looper;
  import  android.util.Log;
  
 
 import java.net.URI;
 
 class LoadBitmap extends BitmapCallback implements FutureCallback<ByteBufferList> {
     int resizeWidth;
     int resizeHeight;
 
 
     public LoadBitmap(Ion ionString urlKeyboolean putint resizeWidthint resizeHeightIonRequestBuilder.EmitterTransform<ByteBufferListemitterTransform) {
         super(ionurlKeyput);
         this. = resizeWidth;
         this. = resizeHeight;
         this. = emitterTransform;
     }
 
     private boolean isGif() {
         if ( == null)
             return false;
         if (. != null) {
             URI uri = ..getUri();
             if (uri != null && uri.toString().endsWith(".gif"))
                 return true;
         }
         if (. == null)
             return false;
         return "image/gif".equals(..get("Content-Type"));
     }
 
     @Override
     public void onCompleted(Exception efinal ByteBufferList result) {
         if (e != null) {
             report(enull);
             return;
         }
 
         if (..tag() != this) {
             Log.d("IonBitmapLoader""Bitmap load cancelled (no longer needed)");
             result.recycle();
             return;
         }
 
         ExecutorService executorService = .getBitmapLoadExecutorService();
 
         executorService.execute(new Runnable() {
             @Override
             public void run() {
                 ByteBuffer bb = result.getAll();
                 try {
                     Bitmap[] bitmaps;
                     int[] delays;
                     if (!isGif()) {
                         bitmaps = new Bitmap[1];
                         bitmaps[0] = ..loadBitmap(bb.array(), bb.arrayOffset() + bb.position(), bb.remaining(), );
                         delays = null;
                     }
                     else {
                         GifDecoder decoder = new GifDecoder(bb.array(), bb.arrayOffset() + bb.position(), bb.remaining(), new GifAction() {
                             @Override
                             public void parseOk(boolean parseStatusint frameIndex) {
                             }
                         });
                         decoder.run();
                         bitmaps = new Bitmap[decoder.getFrameCount()];
                         delays = decoder.getDelays();
                         for (int i = 0; i < decoder.getFrameCount(); i++) {
                             bitmaps[i] = decoder.getFrameImage(i);
                         }
                     }
 
                     if (bitmaps[0] == null)
                         throw new Exception("bitmap failed to load");
 
                     BitmapInfo info = new BitmapInfo();
                     info.key = ;
                     info.bitmaps = bitmaps;
                     info.delays = delays;
                     if ( != null)
                         info.loadedFrom = .loadedFrom();
                     else
                         info.loadedFrom = ..;
 
                     report(nullinfo);
                 } catch (Exception e) {
                     report(enull);
                }
                finally {
                    ByteBufferList.reclaim(bb);
                }
            }
        });
    }
}

    
New to GrepCode? Check out our FAQ X