All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nostra13.universalimageloader.core.assist.FlushedInputStream Maven / Gradle / Ivy

Go to download

Powerful and flexible instrument for asynchronous image loading, caching and displaying on Android

There is a newer version: 1.9.5
Show newest version
package com.nostra13.universalimageloader.core.assist;

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

/**
 * Many streams obtained over slow connection show this
 * problem.
 */
public 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 by_te = read();
				if (by_te < 0) {
					break; // we reached EOF
				} else {
					bytesSkipped = 1; // we read one byte
				}
			}
			totalBytesSkipped += bytesSkipped;
		}
		return totalBytesSkipped;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy