import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
public static class ThumbnailGenerationTask extends AsyncTask<Object, Void, Bitmap> {
private final WeakReference<ImageView> mImageViewReference;
public static class ThumbnailGenerationTask extends AsyncTask<Object, Void, Bitmap> {
private final WeakReference<ImageView> mImageViewReference;
public ThumbnailGenerationTask(ImageView imageView, FileDataStorageManager storageManager,
Account account) {
// Use a WeakReference to ensure the ImageView can be garbage collected
public ThumbnailGenerationTask(ImageView imageView, FileDataStorageManager storageManager,
Account account) {
// Use a WeakReference to ensure the ImageView can be garbage collected
+ public ThumbnailGenerationTask(ImageView imageView, FileDataStorageManager storageManager,
+ Account account, ProgressBar progressWheel) {
+ this(imageView, storageManager, account);
+ mProgressWheelRef = new WeakReference<ProgressBar>(progressWheel);
+ }
+
public ThumbnailGenerationTask(ImageView imageView) {
// Use a WeakReference to ensure the ImageView can be garbage collected
mImageViewReference = new WeakReference<ImageView>(imageView);
public ThumbnailGenerationTask(ImageView imageView) {
// Use a WeakReference to ensure the ImageView can be garbage collected
mImageViewReference = new WeakReference<ImageView>(imageView);
* @param imageKey: thumb key
* @param bitmap: image for extracting thumbnail
* @param path: image path
* @param imageKey: thumb key
* @param bitmap: image for extracting thumbnail
* @param path: image path
- private Bitmap addThumbnailToCache(String imageKey, Bitmap bitmap, String path, int px){
+ private Bitmap addThumbnailToCache(String imageKey, Bitmap bitmap, String path, int pxW, int pxH){
// Rotate image, obeying exif tag
thumbnail = BitmapUtils.rotateImage(thumbnail,path);
// Rotate image, obeying exif tag
thumbnail = BitmapUtils.rotateImage(thumbnail,path);
- private Bitmap doOCFileInBackground() {
+ private Point getScreenDimension(){
+ WindowManager wm = (WindowManager) MainApp.getAppContext().getSystemService(Context.WINDOW_SERVICE);
+ Display display = wm.getDefaultDisplay();
+ Point test = new Point();
+ display.getSize(test);
+ return test;
+ }
+
+ private Bitmap doOCFileInBackground(Boolean isThumbnail) {
+ Bitmap thumbnail = null;
- Bitmap temp = BitmapUtils.decodeSampledBitmapFromFile(
- file.getStoragePath(), px, px);
- Bitmap bitmap = ThumbnailUtils.extractThumbnail(temp, px, px);
+ Bitmap bitmap = BitmapUtils.decodeSampledBitmapFromFile(
+ file.getStoragePath(), pxW, pxH);
- thumbnail = addThumbnailToCache(imageKey, bitmap, file.getStoragePath(), px);
+ thumbnail = addThumbnailToCache(imageKey, bitmap, file.getStoragePath(), pxW, pxH);
Log_OC.d("Thumbnail", "URI: " + uri);
GetMethod get = new GetMethod(uri);
int status = mClient.executeMethod(get);
if (status == HttpStatus.SC_OK) {
InputStream inputStream = get.getResponseBodyAsStream();
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
Log_OC.d("Thumbnail", "URI: " + uri);
GetMethod get = new GetMethod(uri);
int status = mClient.executeMethod(get);
if (status == HttpStatus.SC_OK) {
InputStream inputStream = get.getResponseBodyAsStream();
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
- thumbnail = ThumbnailUtils.extractThumbnail(bitmap, px, px);
+ thumbnail = ThumbnailUtils.extractThumbnail(bitmap, pxW, pxH);
+ byte[] bytes = get.getResponseBody();
+
+ if (mIsThumbnail) {
+ thumbnail = ThumbnailUtils.extractThumbnail(bitmap, pxW, pxH);
+ } else {
+ thumbnail = bitmap;
+ }
// Check disk cache in background thread
Bitmap thumbnail = getBitmapFromDiskCache(imageKey);
// Not found in disk cache
if (thumbnail == null) {
// Check disk cache in background thread
Bitmap thumbnail = getBitmapFromDiskCache(imageKey);
// Not found in disk cache
if (thumbnail == null) {
- thumbnail = addThumbnailToCache(imageKey, bitmap, file.getPath(), px);
+ thumbnail = addThumbnailToCache(imageKey, bitmap, file.getPath(), pxW, pxH);