Search in sources :

Example 1 with FirstCharEntityImageRenderer

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);
    }
}
Also used : FirstCharEntityImageRenderer(com.codename1.rad.ui.image.FirstCharEntityImageRenderer) Form(com.codename1.ui.Form) AsyncImage(com.codename1.rad.ui.image.AsyncImage) WrappedImage(com.codename1.rad.ui.image.WrappedImage) FontImage(com.codename1.ui.FontImage) EncodedImage(com.codename1.ui.EncodedImage) AsyncImage(com.codename1.rad.ui.image.AsyncImage) Image(com.codename1.ui.Image) ComponentImage(ca.weblite.shared.components.ComponentImage) URLImage(com.codename1.ui.URLImage)

Example 2 with FirstCharEntityImageRenderer

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));
}
Also used : FirstCharEntityImageRenderer(com.codename1.rad.ui.image.FirstCharEntityImageRenderer) ActionNode(com.codename1.rad.nodes.ActionNode) ListNode(com.codename1.rad.nodes.ListNode) Node(com.codename1.rad.nodes.Node) ActionsNode(com.codename1.rad.nodes.ActionsNode) ActionNode(com.codename1.rad.nodes.ActionNode) UIID(com.codename1.rad.attributes.UIID) ListNode(com.codename1.rad.nodes.ListNode)

Aggregations

FirstCharEntityImageRenderer (com.codename1.rad.ui.image.FirstCharEntityImageRenderer)2 ComponentImage (ca.weblite.shared.components.ComponentImage)1 UIID (com.codename1.rad.attributes.UIID)1 ActionNode (com.codename1.rad.nodes.ActionNode)1 ActionsNode (com.codename1.rad.nodes.ActionsNode)1 ListNode (com.codename1.rad.nodes.ListNode)1 Node (com.codename1.rad.nodes.Node)1 AsyncImage (com.codename1.rad.ui.image.AsyncImage)1 WrappedImage (com.codename1.rad.ui.image.WrappedImage)1 EncodedImage (com.codename1.ui.EncodedImage)1 FontImage (com.codename1.ui.FontImage)1 Form (com.codename1.ui.Form)1 Image (com.codename1.ui.Image)1 URLImage (com.codename1.ui.URLImage)1