use of chat.rocket.persistence.realm.models.ddp.RealmUser in project Rocket.Chat.Android by RocketChat.
the class DefaultCookieProvider method getCookie.
@Override
public String getCookie() {
final String hostname = getHostnameFromCache();
if (hostname == null) {
return "";
}
final RealmHelper realmHelper = RealmStore.get(getHostnameFromCache());
if (realmHelper == null) {
return "";
}
final RealmUser user = realmHelper.executeTransactionForRead(realm -> RealmUser.queryCurrentUser(realm).findFirst());
final RealmSession session = realmHelper.executeTransactionForRead(realm -> RealmSession.queryDefaultSession(realm).findFirst());
if (user == null || session == null) {
return "";
}
return "rc_uid=" + user.getId() + ";rc_token=" + session.getToken();
}
use of chat.rocket.persistence.realm.models.ddp.RealmUser in project Rocket.Chat.Android by RocketChat.
the class SuggestUserAdapter method filterList.
@Override
protected void filterList(List<RealmUser> users, String text) {
Iterator<RealmUser> itUsers = users.iterator();
final String prefix = text.toLowerCase();
while (itUsers.hasNext()) {
RealmUser user = itUsers.next();
if (!user.getUsername().toLowerCase().startsWith(prefix)) {
itUsers.remove();
}
}
}
use of chat.rocket.persistence.realm.models.ddp.RealmUser in project Rocket.Chat.Android by RocketChat.
the class RoomUserAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RoomUserViewHolder holder, int position) {
String username = usernames.get(position);
if (TextUtils.isEmpty(username)) {
return;
}
RealmUser realmUser = realmHelper.executeTransactionForRead(realm -> realm.where(RealmUser.class).equalTo(RealmUser.USERNAME, username).findFirst());
if (realmUser == null) {
User user = User.builder().setId("some-local-is").setUsername(username).setUtcOffset(0).build();
new UserRenderer(context, user).avatarInto(holder.avatar, absoluteUrl).usernameInto(holder.username);
} else {
new UserRenderer(context, realmUser.asUser()).statusColorInto(holder.status).avatarInto(holder.avatar, absoluteUrl).usernameInto(holder.username);
}
}
Aggregations