aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2019-01-27 10:16:18 +0100
committerChristian Schneppe <christian@pix-art.de>2019-01-27 10:19:46 +0100
commite859e69674cd13e82fb6363e219b80853e87ef15 (patch)
tree2114545b2f68e4e9dd882f45df60d5255756fd08 /src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java
parent7b9ced9fb752ee485b657daf6d827f311ed6e8bc (diff)
make bitmap worker task static
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java')
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java
index a60631523..e97a8d407 100644
--- a/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java
+++ b/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java
@@ -390,33 +390,38 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapte
static class AsyncDrawable extends BitmapDrawable {
private final WeakReference<BitmapWorkerTask> bitmapWorkerTaskReference;
- public AsyncDrawable(Resources res, Bitmap bitmap, BitmapWorkerTask bitmapWorkerTask) {
+ AsyncDrawable(Resources res, Bitmap bitmap, BitmapWorkerTask bitmapWorkerTask) {
super(res, bitmap);
bitmapWorkerTaskReference = new WeakReference<>(bitmapWorkerTask);
}
- public BitmapWorkerTask getBitmapWorkerTask() {
+ BitmapWorkerTask getBitmapWorkerTask() {
return bitmapWorkerTaskReference.get();
}
}
- class BitmapWorkerTask extends AsyncTask<Conversation, Void, Bitmap> {
+ static class BitmapWorkerTask extends AsyncTask<Conversation, Void, Bitmap> {
private final WeakReference<ImageView> imageViewReference;
private Conversation conversation = null;
- public BitmapWorkerTask(ImageView imageView) {
+ BitmapWorkerTask(ImageView imageView) {
imageViewReference = new WeakReference<>(imageView);
}
+
@Override
protected Bitmap doInBackground(Conversation... params) {
this.conversation = params[0];
+ final XmppActivity activity = XmppActivity.find(imageViewReference);
+ if (activity == null) {
+ return null;
+ }
return activity.avatarService().get(this.conversation, activity.getPixel(56), isCancelled());
}
@Override
protected void onPostExecute(Bitmap bitmap) {
- if (bitmap != null) {
+ if (bitmap != null && !isCancelled()) {
final ImageView imageView = imageViewReference.get();
if (imageView != null) {
imageView.setImageBitmap(bitmap);