Search in sources :

Example 1 with ProgressByteProcessor

use of com.octo.android.robospice.request.ProgressByteProcessor in project robospice by stephanenicolas.

the class OkHttpBigBinaryRequest method processStream.

@Override
public InputStream processStream(final int contentLength, final InputStream inputStream) throws IOException {
    OutputStream fileOutputStream = null;
    try {
        // touch
        boolean isTouchedNow = cacheFile.setLastModified(System.currentTimeMillis());
        if (!isTouchedNow) {
            Ln.d("Modification time of file %s could not be changed normally ", cacheFile.getAbsolutePath());
        }
        fileOutputStream = new FileOutputStream(cacheFile);
        readBytes(inputStream, new ProgressByteProcessor(this, fileOutputStream, contentLength));
        return new FileInputStream(cacheFile);
    } finally {
        IOUtils.closeQuietly(fileOutputStream);
    }
}
Also used : ProgressByteProcessor(com.octo.android.robospice.request.ProgressByteProcessor) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) FileInputStream(java.io.FileInputStream)

Example 2 with ProgressByteProcessor

use of com.octo.android.robospice.request.ProgressByteProcessor in project robospice by stephanenicolas.

the class OkHttpSmallBinaryRequest method processStream.

@Override
public InputStream processStream(final int contentLength, final InputStream inputStream) throws IOException {
    final ByteArrayOutputStream bos = new ByteArrayOutputStream();
    readBytes(inputStream, new ProgressByteProcessor(this, bos, contentLength));
    final byte[] bytes = bos.toByteArray();
    return new ByteArrayInputStream(bytes);
}
Also used : ProgressByteProcessor(com.octo.android.robospice.request.ProgressByteProcessor) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 3 with ProgressByteProcessor

use of com.octo.android.robospice.request.ProgressByteProcessor in project robospice by stephanenicolas.

the class BitmapRequest method processStream.

public void processStream(int contentLength, final InputStream inputStream) throws IOException {
    OutputStream fileOutputStream = null;
    try {
        // touch
        boolean isTouchedNow = cacheFile.setLastModified(System.currentTimeMillis());
        if (!isTouchedNow) {
            Ln.d("Modification time of file %s could not be changed normally ", cacheFile.getAbsolutePath());
        }
        fileOutputStream = new FileOutputStream(cacheFile);
        readBytes(inputStream, new ProgressByteProcessor(this, fileOutputStream, contentLength));
    } finally {
        IOUtils.closeQuietly(fileOutputStream);
    }
}
Also used : ProgressByteProcessor(com.octo.android.robospice.request.ProgressByteProcessor) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream)

Example 4 with ProgressByteProcessor

use of com.octo.android.robospice.request.ProgressByteProcessor in project robospice by stephanenicolas.

the class OkHttpBitmapRequest method processStream.

public void processStream(int contentLength, final InputStream inputStream) throws IOException {
    OutputStream fileOutputStream = null;
    try {
        // touch
        boolean isTouchedNow = cacheFile.setLastModified(System.currentTimeMillis());
        if (!isTouchedNow) {
            Ln.d("Modification time of file %s could not be changed normally ", cacheFile.getAbsolutePath());
        }
        fileOutputStream = new FileOutputStream(cacheFile);
        readBytes(inputStream, new ProgressByteProcessor(this, fileOutputStream, contentLength));
    } finally {
        IOUtils.closeQuietly(fileOutputStream);
    }
}
Also used : ProgressByteProcessor(com.octo.android.robospice.request.ProgressByteProcessor) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream)

Example 5 with ProgressByteProcessor

use of com.octo.android.robospice.request.ProgressByteProcessor in project robospice by stephanenicolas.

the class BigBinaryRequest method processStream.

@Override
public InputStream processStream(final int contentLength, final InputStream inputStream) throws IOException {
    OutputStream fileOutputStream = null;
    try {
        // touch
        boolean isTouchedNow = cacheFile.setLastModified(System.currentTimeMillis());
        if (!isTouchedNow) {
            Ln.d("Modification time of file %s could not be changed normally ", cacheFile.getAbsolutePath());
        }
        fileOutputStream = new FileOutputStream(cacheFile);
        readBytes(inputStream, new ProgressByteProcessor(this, fileOutputStream, contentLength));
        return new FileInputStream(cacheFile);
    } finally {
        IOUtils.closeQuietly(fileOutputStream);
    }
}
Also used : ProgressByteProcessor(com.octo.android.robospice.request.ProgressByteProcessor) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) FileInputStream(java.io.FileInputStream)

Aggregations

ProgressByteProcessor (com.octo.android.robospice.request.ProgressByteProcessor)6 FileOutputStream (java.io.FileOutputStream)4 OutputStream (java.io.OutputStream)4 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 FileInputStream (java.io.FileInputStream)2