Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.koushikdutta.ion;
 
 import  android.annotation.TargetApi;
 import  android.graphics.Bitmap;
 import  android.graphics.BitmapFactory;
 import  android.graphics.BitmapRegionDecoder;
 import  android.graphics.Point;
 import  android.graphics.Rect;
 import  android.os.Build;
import  android.text.TextUtils;
Created by koush on 1/5/14.
@TargetApi(Build.VERSION_CODES.GINGERBREAD_MR1)
public class LoadDeepZoom extends LoadBitmapEmitter implements FutureCallback<File> {
    public LoadDeepZoom(Ion ionString urlKeyboolean animateGifIonRequestBuilder.EmitterTransform<FileemitterTransformFileCache fileCache) {
        super(ionurlKeytrueanimateGifemitterTransform);
        this. = fileCache;
    }
    @Override
    public void onCompleted(Exception efinal File tempFile) {
        if (e != null) {
            report(enull);
            return;
        }
        if (..tag() != this) {
//            Log.d("IonBitmapLoader", "Bitmap load cancelled (no longer needed)");
            return;
        }
        Ion.getBitmapLoadExecutorService().execute(new Runnable() {
            @Override
            public void run() {
                FileInputStream fin = null;
                try {
                    File file;
                    // file cache will be null if the file is on the local file system already
                    if ( != null) {
                        .commitTempFiles(tempFile);
                        file = .getFile();
                    }
                    else {
                        // local file system, use the "temp" file as the source.
                        file = tempFile;
                    }
                    BitmapFactory.Options options = .getBitmapCache().prepareBitmapOptions(file, 0, 0);
                    final Point size = new Point(options.outWidthoptions.outHeight);
                    if ( && TextUtils.equals("image/gif"options.outMimeType)) {
                        fin = .get();
                        GifDecoder gifDecoder = new GifDecoder(ByteBuffer.wrap(StreamUtility.readToEndAsArray(fin)));
                        GifFrame frame = gifDecoder.nextFrame();
                        BitmapInfo info = new BitmapInfo(options.outMimeTypeframe.imagesize);
                        info.gifDecoder = gifDecoder;
                        report(nullinfo);
                        return;
                    }
                    BitmapRegionDecoder decoder = BitmapRegionDecoder.newInstance(file.toString(), false);
                    Bitmap bitmap = decoder.decodeRegion(new Rect(0, 0, size.x, size.y), options);
                    if (bitmap == null)
                        throw new Exception("unable to load decoder");
                    BitmapInfo info = new BitmapInfo(options.outMimeTypebitmapsize);
                    info.decoder = decoder;
                    info.decoderFile = file;
                    info.loadedFrom = ..;
                    report(nullinfo);
                } catch (Exception e) {
                    report(enull);
                }
                finally {
                    StreamUtility.closeQuietly(fin);
                }
            }
        });
    }
New to GrepCode? Check out our FAQ X