properly cancel avatar tasks
This commit is contained in:
parent
d5608cb4f3
commit
936006173c
|
@ -126,12 +126,12 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Bitmap doInBackground(Conversation... params) {
|
protected Bitmap doInBackground(Conversation... params) {
|
||||||
return activity.avatarService().get(params[0], activity.getPixel(56));
|
return activity.avatarService().get(params[0], activity.getPixel(56), isCancelled());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Bitmap bitmap) {
|
protected void onPostExecute(Bitmap bitmap) {
|
||||||
if (bitmap != null) {
|
if (bitmap != null && !isCancelled()) {
|
||||||
final ImageView imageView = imageViewReference.get();
|
final ImageView imageView = imageViewReference.get();
|
||||||
if (imageView != null) {
|
if (imageView != null) {
|
||||||
imageView.setImageBitmap(bitmap);
|
imageView.setImageBitmap(bitmap);
|
||||||
|
@ -145,6 +145,7 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
|
||||||
if (cancelPotentialWork(conversation, imageView)) {
|
if (cancelPotentialWork(conversation, imageView)) {
|
||||||
final Bitmap bm = activity.avatarService().get(conversation, activity.getPixel(56), true);
|
final Bitmap bm = activity.avatarService().get(conversation, activity.getPixel(56), true);
|
||||||
if (bm != null) {
|
if (bm != null) {
|
||||||
|
cancelPotentialWork(conversation, imageView);
|
||||||
imageView.setImageBitmap(bm);
|
imageView.setImageBitmap(bm);
|
||||||
imageView.setBackgroundColor(0x00000000);
|
imageView.setBackgroundColor(0x00000000);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -106,12 +106,12 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Bitmap doInBackground(ListItem... params) {
|
protected Bitmap doInBackground(ListItem... params) {
|
||||||
return activity.avatarService().get(params[0], activity.getPixel(48));
|
return activity.avatarService().get(params[0], activity.getPixel(48), isCancelled());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Bitmap bitmap) {
|
protected void onPostExecute(Bitmap bitmap) {
|
||||||
if (bitmap != null) {
|
if (bitmap != null && !isCancelled()) {
|
||||||
final ImageView imageView = imageViewReference.get();
|
final ImageView imageView = imageViewReference.get();
|
||||||
if (imageView != null) {
|
if (imageView != null) {
|
||||||
imageView.setImageBitmap(bitmap);
|
imageView.setImageBitmap(bitmap);
|
||||||
|
@ -125,6 +125,7 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
|
||||||
if (cancelPotentialWork(item, imageView)) {
|
if (cancelPotentialWork(item, imageView)) {
|
||||||
final Bitmap bm = activity.avatarService().get(item,activity.getPixel(48),true);
|
final Bitmap bm = activity.avatarService().get(item,activity.getPixel(48),true);
|
||||||
if (bm != null) {
|
if (bm != null) {
|
||||||
|
cancelPotentialWork(item, imageView);
|
||||||
imageView.setImageBitmap(bm);
|
imageView.setImageBitmap(bm);
|
||||||
imageView.setBackgroundColor(0x00000000);
|
imageView.setBackgroundColor(0x00000000);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -754,7 +754,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Bitmap bitmap) {
|
protected void onPostExecute(Bitmap bitmap) {
|
||||||
if (bitmap != null) {
|
if (bitmap != null && !isCancelled()) {
|
||||||
final ImageView imageView = imageViewReference.get();
|
final ImageView imageView = imageViewReference.get();
|
||||||
if (imageView != null) {
|
if (imageView != null) {
|
||||||
imageView.setImageBitmap(bitmap);
|
imageView.setImageBitmap(bitmap);
|
||||||
|
@ -768,6 +768,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
||||||
if (cancelPotentialWork(message, imageView)) {
|
if (cancelPotentialWork(message, imageView)) {
|
||||||
final Bitmap bm = activity.avatarService().get(message, activity.getPixel(48), true);
|
final Bitmap bm = activity.avatarService().get(message, activity.getPixel(48), true);
|
||||||
if (bm != null) {
|
if (bm != null) {
|
||||||
|
cancelPotentialWork(message, imageView);
|
||||||
imageView.setImageBitmap(bm);
|
imageView.setImageBitmap(bm);
|
||||||
imageView.setBackgroundColor(0x00000000);
|
imageView.setBackgroundColor(0x00000000);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue