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