use of com.codename1.rad.ui.image.AsyncImage in project CodeRAD by shannah.
the class ProfileAvatarView method update.
@Override
public void update() {
if (iconLoaded) {
return;
}
iconLoaded = true;
if (getEntity() != null) {
if (iconProp != null && !getEntity().isEmpty(iconProp)) {
int sizePx = CN.convertToPixels(sizeMM);
Image img = getEntity().getEntity().createImageToStorage(iconProp, EncodedImage.createFromImage(label.getIcon().fill(sizePx, sizePx), false), "@avatar" + label.getIcon().getWidth() + "x" + label.getIcon().getHeight(), URLImage.createMaskAdapter(getCircleMask()));
if (img != null) {
label.setIcon(img);
return;
}
}
if (fallbackSettings == FallbackSettings.FirstChar && nameProp != null && !getEntity().isEmpty(nameProp)) {
FirstCharEntityImageRenderer renderer = new FirstCharEntityImageRenderer(sizeMM);
AsyncImage img = renderer.createImage(this, nameProp, 0, false, false);
if (img != null) {
img.ready(im -> {
label.setIcon(im);
Form f = label.getComponentForm();
if (f != null) {
label.repaint();
}
});
return;
}
}
FontImage.setMaterialIcon(label, defaultMaterialIcon, sizeMM);
} else {
FontImage.setMaterialIcon(label, defaultMaterialIcon, sizeMM);
}
}
Aggregations