package se.alexanderblom.imageloader.util;

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class BitmapUtils {
    public static Bitmap decodeStream(InputStream is) {
        // Handle a bug in older versions of Android, see
        // http://android-developers.blogspot.se/2010/07/multithreading-for-performance.html
        if (!Android.isAPI(9)) {
            return BitmapFactory.decodeStream(new FlushedInputStream(is));
        } else {
            return BitmapFactory.decodeStream(is);
        }
    }

    private BitmapUtils() {}

    /**
     * A {@link FilterInputStream} that blocks until the requested number of bytes
     * have been read/skipped, or the end of the stream is reached.
     * <p>
     * This filter can be used as a work-around for <a
     * href="http://code.google.com/p/android/issues/detail?id=6066">Issue
     * #6066</a>.
     */
    private static class FlushedInputStream extends FilterInputStream {
        public FlushedInputStream(InputStream inputStream) {
            super(inputStream);
        }

        @Override
        public long skip(long n) throws IOException {
            long totalBytesSkipped = 0L;
            while (totalBytesSkipped < n) {
                long bytesSkipped = in.skip(n - totalBytesSkipped);
                if (bytesSkipped == 0L) {
                      int b = read();
                      if (b < 0) {
                          break;  // we reached EOF
                      } else {
                          bytesSkipped = 1; // we read one byte
                      }
               }
                totalBytesSkipped += bytesSkipped;
            }
            return totalBytesSkipped;
        }
        /*
        @Override
        public void write(byte[] buffer, int offset, int length) throws IOException {
            // Since we don't override "write(int oneByte)", we can write directly to "out"
            // and avoid the inefficient implementation from the FilterOutputStream.
            in.write(buffer, offset, length);
        }*/
    }
}

@@ -1804,358 +1804,8 @@
   %7D%0A
-        /*%0A        @Override%0A        public void write(byte%5B%5D buffer, int offset, int length) throws IOException %7B%0A            // Since we don't override %22write(int oneByte)%22, we can write directly to %22out%22%0A            // and avoid the inefficient implementation from the FilterOutputStream.%0A            in.write(buffer, offset, length);%0A        %7D*/%0A
     

Remove junk