import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
-import android.graphics.Shader;
import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.media.ThumbnailUtils;
import android.net.Uri;
public static Bitmap mDefaultImg =
BitmapFactory.decodeResource(
- MainApp.getAppContext().getResources(),
- DisplayUtils.getFileTypeIconId("image/png", "default.png")
+ MainApp.getAppContext().getResources(),
+ R.drawable.file_image
);
}
protected void onPostExecute(Bitmap bitmap){
- if (isCancelled()) {
- bitmap = null;
- }
-
if (bitmap != null) {
final ImageView imageView = mImageViewReference.get();
final ThumbnailGenerationTask bitmapWorkerTask = getBitmapWorkerTask(imageView);
GetMethod get = new GetMethod(uri);
int status = mClient.executeMethod(get);
if (status == HttpStatus.SC_OK) {
-// byte[] bytes = get.getResponseBody();
-// Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0,
-// bytes.length);
InputStream inputStream = get.getResponseBodyAsStream();
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
thumbnail = ThumbnailUtils.extractThumbnail(bitmap, px, px);
px,
Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(resultBitmap);
- Bitmap checker = BitmapFactory.decodeResource(MainApp.getAppContext().getResources(),
- R.drawable.checker_16_16);
-
- BitmapDrawable background;
- background = new BitmapDrawable(MainApp.getAppContext().getResources(), checker);
-
- background.setBounds(0, 0, px, px);
- background.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
- background.draw(c);
+ c.drawColor(MainApp.getAppContext().getResources().
+ getColor(R.color.background_color));
c.drawBitmap(bitmap, 0, 0, null);
return resultBitmap;
if (bitmapData == null || bitmapData != file) {
// Cancel previous task
bitmapWorkerTask.cancel(true);
+ Log_OC.v(TAG, "Cancelled generation of thumbnail for a reused imageView");
} else {
// The same work is already in progress
return false;