Search in sources :

Example 56 with RealmRoomMessage

use of net.iGap.realm.RealmRoomMessage in project iGap-Android by KianIranian-STDG.

the class SearchFragment method fillHashtag.

private void fillHashtag(String tt) {
    DbManager.getInstance().doRealmTask(realm -> {
        String text = tt;
        if (!text.startsWith("#")) {
            text = "#" + text;
        }
        RealmResults<RealmRoomMessage> results;
        if (roomId != 0) {
            results = realm.where(RealmRoomMessage.class).equalTo("roomId", roomId).equalTo("hasMessageLink", true).contains("message", text, Case.INSENSITIVE).equalTo("edited", false).isNotEmpty("message").findAll();
        } else {
            results = realm.where(RealmRoomMessage.class).equalTo("hasMessageLink", true).contains("message", text, Case.INSENSITIVE).equalTo("edited", false).isNotEmpty("message").findAll();
        }
        if (results != null && results.size() > 0) {
            addHeader(G.fragmentActivity.getResources().getString(R.string.hashtag));
            for (RealmRoomMessage roomMessage : results) {
                StructSearch item = new StructSearch();
                item.time = roomMessage.getUpdateTime();
                item.comment = roomMessage.getMessage();
                item.id = roomMessage.getRoomId();
                item.type = SearchType.message;
                item.messageId = roomMessage.getMessageId();
                RealmRoom realmRoom = realm.where(RealmRoom.class).equalTo("id", roomMessage.getRoomId()).findFirst();
                if (realmRoom != null) {
                    // room exist
                    item.name = realmRoom.getTitle();
                    if (realmRoom.getType() == ProtoGlobal.Room.Type.CHANNEL && realmRoom.getChannelRoom().isVerified() || realmRoom.getType() == CHAT && realmRoom.getChatRoom().isVerified()) {
                        item.isVerified = true;
                    }
                    item.initials = realmRoom.getInitials();
                    item.color = realmRoom.getColor();
                    item.roomType = realmRoom.getType();
                    item.avatar = realmRoom.getAvatar();
                    if (realmRoom.getType() == ProtoGlobal.Room.Type.CHAT && realmRoom.getChatRoom() != null) {
                        item.idDetectAvatar = realmRoom.getChatRoom().getPeerId();
                    } else {
                        item.idDetectAvatar = realmRoom.getId();
                    }
                    list.add(item);
                }
            }
        }
    });
}
Also used : RealmRoomMessage(net.iGap.realm.RealmRoomMessage) RealmRoom(net.iGap.realm.RealmRoom)

Aggregations

RealmRoomMessage (net.iGap.realm.RealmRoomMessage)56 RealmRoom (net.iGap.realm.RealmRoom)20 MessageObject (net.iGap.structs.MessageObject)20 ArrayList (java.util.ArrayList)19 File (java.io.File)14 SuppressLint (android.annotation.SuppressLint)11 DbManager (net.iGap.module.accountManager.DbManager)11 NonNull (androidx.annotation.NonNull)10 HelperString (net.iGap.helper.HelperString)10 StructMessageInfo (net.iGap.module.structs.StructMessageInfo)10 RealmString (net.iGap.realm.RealmString)10 View (android.view.View)9 TextView (android.widget.TextView)9 Realm (io.realm.Realm)9 AttachmentObject (net.iGap.structs.AttachmentObject)9 Intent (android.content.Intent)8 Nullable (androidx.annotation.Nullable)8 Configuration (android.content.res.Configuration)7 Bundle (android.os.Bundle)7 LayoutInflater (android.view.LayoutInflater)7