use of im.actor.core.js.entity.JsOnlineGroup in project actor-platform by actorapp.
the class JsBindingModule method getGroupOnline.
public JsBindedValue<JsOnlineGroup> getGroupOnline(int gid) {
if (!groupOnlines.containsKey(gid)) {
final JsBindedValue<JsOnlineGroup> value = new JsBindedValue<>();
final GroupVM groupVM = context().getGroupsModule().getGroupsCollection().get(gid);
groupVM.getPresence().subscribe(new ValueChangedListener<Integer>() {
@Override
public void onChanged(Integer val, Value<Integer> valueModel) {
if (groupVM.isMember().get()) {
if (val == null) {
value.changeValue(null);
return;
}
String presence = messenger.getFormatter().formatGroupMembers(groupVM.getMembersCount().get());
if (val > 0) {
presence += ", " + messenger.getFormatter().formatGroupOnline(val);
}
value.changeValue(JsOnlineGroup.create(groupVM.getMembersCount().get(), val, presence, false));
} else {
value.changeValue(JsOnlineGroup.create(0, 0, "Not member", false));
}
}
});
groupOnlines.put(gid, value);
}
return groupOnlines.get(gid);
}
Aggregations