use of com.codename1.rad.ui.entityviews.ProfileAvatarView in project CodeRAD by shannah.
the class ProfileAvatarsTitleComponent method initUI.
private void initUI() {
setLayout(new BorderLayout());
wrapper = new Container(new FanLayout(FanLayout.X_AXIS));
avatarWrapperViewController.setView(wrapper);
$(wrapper).selectAllStyles().setPadding(0).setMargin(0).setBorder(Border.createEmpty());
int len = getEntity().size();
for (int i = len - 1; i >= 0; i--) {
// for (Entity child : getEntity()) {
Entity child = getEntity().get(i);
ProfileAvatarView v = createAvatar(child);
wrapper.add(v);
}
add(CENTER, wrapper);
StringBuilder text = new StringBuilder();
Property nameProp = getEntity().getRowType().findProperty(Thing.name);
if (getEntity().size() > 0) {
if (nameProp != null) {
text.append(getEntity().get(0).getEntity().getText(nameProp));
}
}
if (getEntity().size() == 2) {
if (nameProp != null) {
text.append(" & ").append(getEntity().get(1).getEntity().getText(nameProp));
}
}
if (getEntity().size() > 2) {
if (text.length() == 0) {
text.append(getEntity().size()).append(" People");
} else {
text.append(" and ").append(getEntity().size() - 1).append(" others");
}
}
Label lbl = new Label(text.toString());
lbl.setUIID("AccountAvatarsTitleComponentText");
add(SOUTH, FlowLayout.encloseCenter(lbl));
}
use of com.codename1.rad.ui.entityviews.ProfileAvatarView in project CodeRAD by shannah.
the class ProfileAvatarsTitleComponent method createAvatar.
/**
* Creates individual avatar component.
* @param row
* @return
*/
private ProfileAvatarView createAvatar(Entity row) {
// We will intercept the individual avatar actions by inserting our own actions here.
// We will then handle the clicks and long presses ourselves, because
// we may need to expand the list of avatars and allow the user to
// choose an avatar from the list.
ViewNode childNode = new ViewNode(UI.actions(ProfileAvatarView.PROFILE_AVATAR_CLICKED, interceptAvatarClicked), UI.actions(ProfileAvatarView.PROFILE_AVATAR_LONG_PRESS, interceptAvatarLongPress));
childNode.setParent(getViewNode());
ProfileAvatarView v = new ProfileAvatarView(row, childNode, avatarSizeMM);
return v;
}
use of com.codename1.rad.ui.entityviews.ProfileAvatarView in project CodenameOne by codenameone.
the class ProfileAvatarViewSample method start.
public void start() {
if (current != null) {
current.show();
return;
}
Form hi = new Form("Hi World", BoxLayout.y());
Profile profile = new Profile();
profile.set(Profile.name, "Steve");
profile.set(Profile.icon, "https://www.codenameone.com/img/steve.jpg");
ProfileAvatarView avatar = new ProfileAvatarView(profile, 30f);
hi.add("Avatar with Name and Icon");
hi.add(FlowLayout.encloseCenter(avatar));
profile = new Profile();
profile.set(Profile.name, "Steve");
avatar = new ProfileAvatarView(profile, 30f);
hi.add("Avatar with only Name");
hi.add(FlowLayout.encloseCenter(avatar));
profile = new Profile();
avatar = new ProfileAvatarView(profile, 30f);
hi.add("Avatar with no name or icon");
hi.add(FlowLayout.encloseCenter(avatar));
profile = new Profile();
profile.set(Profile.name, "Steve");
profile.set(Profile.icon, "https://www.codenameone.com/img/steve.jpg");
hi.add("Avatar with view controller");
hi.add(FlowLayout.encloseCenter(new ProfileViewController(null, profile).getView()));
hi.show();
}
use of com.codename1.rad.ui.entityviews.ProfileAvatarView in project CodeRAD by shannah.
the class ProfileAvatarBuilder method build.
@Override
public ProfileAvatarView build() {
ViewNode n = new ViewNode();
n.setParent(node);
if (nameTag != null) {
n.setAttributes(UI.param(ProfileAvatarView.NAME_PROPERTY_TAGS, nameTag));
}
if (iconTag != null) {
n.setAttributes(UI.param(ProfileAvatarView.ICON_PROPERTY_TAGS, iconTag));
}
return new ProfileAvatarView(entity, n, size);
}
Aggregations