Search in sources :

Example 1 with UserRenderer

use of chat.rocket.android.renderer.UserRenderer 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);
    }
}
Also used : User(chat.rocket.core.models.User) RealmUser(chat.rocket.persistence.realm.models.ddp.RealmUser) RealmUser(chat.rocket.persistence.realm.models.ddp.RealmUser) UserRenderer(chat.rocket.android.renderer.UserRenderer)

Aggregations

UserRenderer (chat.rocket.android.renderer.UserRenderer)1 User (chat.rocket.core.models.User)1 RealmUser (chat.rocket.persistence.realm.models.ddp.RealmUser)1