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