always call to cancel before loading new avatars
This commit is contained in:
parent
b128b33e56
commit
9c2e6392ec
|
@ -135,11 +135,12 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
|
|||
}
|
||||
|
||||
public void loadAvatar(Conversation conversation, ImageView imageView) {
|
||||
Bitmap bm = activity.avatarService().get(conversation,activity.getPixel(56),true);
|
||||
if (cancelPotentialWork(conversation, imageView)) {
|
||||
final Bitmap bm = activity.avatarService().get(conversation, activity.getPixel(56), true);
|
||||
if (bm != null) {
|
||||
imageView.setImageBitmap(bm);
|
||||
imageView.setBackgroundColor(0x00000000);
|
||||
} else if (cancelPotentialWork(conversation, imageView)) {
|
||||
} else {
|
||||
imageView.setBackgroundColor(UIHelper.getColorForName(conversation.getName()));
|
||||
final BitmapWorkerTask task = new BitmapWorkerTask(imageView);
|
||||
final AsyncDrawable asyncDrawable = new AsyncDrawable(activity.getResources(), null, task);
|
||||
|
@ -150,6 +151,7 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean cancelPotentialWork(Conversation conversation, ImageView imageView) {
|
||||
final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);
|
||||
|
|
|
@ -121,11 +121,12 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
|
|||
}
|
||||
|
||||
public void loadAvatar(ListItem item, ImageView imageView) {
|
||||
Bitmap bm = activity.avatarService().get(item,activity.getPixel(48),true);
|
||||
if (cancelPotentialWork(item, imageView)) {
|
||||
final Bitmap bm = activity.avatarService().get(item,activity.getPixel(48),true);
|
||||
if (bm != null) {
|
||||
imageView.setImageBitmap(bm);
|
||||
imageView.setBackgroundColor(0x00000000);
|
||||
} else if (cancelPotentialWork(item, imageView)) {
|
||||
} else {
|
||||
imageView.setBackgroundColor(UIHelper.getColorForName(item.getDisplayName()));
|
||||
final BitmapWorkerTask task = new BitmapWorkerTask(imageView);
|
||||
final AsyncDrawable asyncDrawable = new AsyncDrawable(activity.getResources(), null, task);
|
||||
|
@ -136,6 +137,7 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean cancelPotentialWork(ListItem item, ImageView imageView) {
|
||||
final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);
|
||||
|
|
Loading…
Reference in a new issue