blob: 0e1c3bd69e64e07a986dd6f2dbf285391a66e765 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/*
* Copyright (C) 2014 Cyanogen, Inc.
*/
package com.cyngn.eleven.cache;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.TransitionDrawable;
import android.widget.ImageView;
import com.cyngn.eleven.cache.ImageWorker.ImageType;
/**
* The actual {@link android.os.AsyncTask} that will process the image.
*/
public class SimpleBitmapWorkerTask extends BitmapWorkerTask<String, Void, TransitionDrawable> {
/**
* Constructor of <code>BitmapWorkerTask</code>
*
* @param key the key of the image to store to
* @param imageView The {@link ImageView} to use.
* @param imageType The type of image URL to fetch for.
* @param fromDrawable what drawable to transition from
*/
public SimpleBitmapWorkerTask(final String key, final ImageView imageView, final ImageType imageType,
final Drawable fromDrawable, final Context context) {
super(key, imageView, imageType, fromDrawable, context);
}
/**
* {@inheritDoc}
*/
@Override
protected TransitionDrawable doInBackground(final String... params) {
if (isCancelled()) {
return null;
}
final Bitmap bitmap = getBitmapInBackground(params);
return createImageTransitionDrawable(bitmap);
}
/**
* {@inheritDoc}
*/
@Override
protected void onPostExecute(TransitionDrawable transitionDrawable) {
final ImageView imageView = getAttachedImageView();
if (transitionDrawable != null && imageView != null) {
imageView.setImageDrawable(transitionDrawable);
}
}
}
|