use of com.codename1.rad.ui.image.FirstCharEntityImageRenderer 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);
}
}
use of com.codename1.rad.ui.image.FirstCharEntityImageRenderer in project CodeRAD by shannah.
the class ContactListDecorator method decorate.
@Override
public void decorate(Node node) {
if (!(node instanceof ListNode)) {
return;
}
ListNode listNode = (ListNode) node;
Node rowTemplate = listNode.getRowTemplate();
rowTemplate.setAttributes(UI.param(MultiButtonEntityView.LINE1_UIID, "ContactListLine1"));
rowTemplate.setAttributes(UI.param(MultiButtonEntityView.LINE2_UIID, "ContactListLine2"));
for (ActionNode n : rowTemplate.getActions(ActionCategories.LEFT_SWIPE_MENU)) {
n.setAttributes(UI.actionStyle(ActionStyle.IconOnly));
n.setAttributes(new UIID("SwipeableContainerButton"));
}
ActionNode removeAction = listNode.getAction(ActionCategories.LIST_REMOVE_ACTION);
if (removeAction != null) {
removeAction.setAttributes(UI.actionStyle(ActionStyle.IconOnly));
removeAction.setAttributes(new UIID("SwipeableContainerButton"));
}
// swipeLeftNode.setAttributes(LEFT_SWIPE_MENU);
// listNode.getRowTemplate().setAttributes(swipeLeftNode);
node.setAttributes(iconRenderer(new FirstCharEntityImageRenderer(10)));
node.setAttributes(UI.param(MultiButtonEntityView.ICON, Thing.name));
}
Aggregations