Search in sources :

Example 6 with RealmUser

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();
}
Also used : RealmHelper(chat.rocket.persistence.realm.RealmHelper) RealmUser(chat.rocket.persistence.realm.models.ddp.RealmUser) RealmSession(chat.rocket.persistence.realm.models.internal.RealmSession)

Example 7 with RealmUser

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();
        }
    }
}
Also used : RealmUser(chat.rocket.persistence.realm.models.ddp.RealmUser)

Example 8 with RealmUser

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);
    }
}
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

RealmUser (chat.rocket.persistence.realm.models.ddp.RealmUser)8 RealmHelper (chat.rocket.persistence.realm.RealmHelper)3 Realm (io.realm.Realm)3 RealmResults (io.realm.RealmResults)3 List (java.util.List)3 Context (android.content.Context)2 LogIfError (chat.rocket.android.helper.LogIfError)2 DDPClientRef (chat.rocket.android.service.DDPClientRef)2 User (chat.rocket.core.models.User)2 RealmSession (chat.rocket.persistence.realm.models.internal.RealmSession)2 ArrayList (java.util.ArrayList)2 Uri (android.net.Uri)1 Looper (android.os.Looper)1 Pair (android.support.v4.util.Pair)1 AutoCompleteTextView (android.widget.AutoCompleteTextView)1 Task (bolts.Task)1 RocketChatCache (chat.rocket.android.RocketChatCache)1 FileUploadingHelper (chat.rocket.android.api.FileUploadingHelper)1 MethodCallHelper (chat.rocket.android.api.MethodCallHelper)1 RaixPushHelper (chat.rocket.android.api.RaixPushHelper)1