use of net.iGap.R in project iGap-Android by KianIranian-STDG.
the class FragmentMediaPlayer method getInfoRealm.
public void getInfoRealm() {
if (MusicPlayer.mediaList.size() != 0) {
changeListener = null;
List<RealmRoomMessage> realmRoomMessages = null;
try {
realmRoomMessages = DbManager.getInstance().doRealmTask(realm -> {
return realm.where(RealmRoomMessage.class).equalTo("roomId", MusicPlayer.roomId).notEqualTo("deleted", true).contains("messageType", ProtoGlobal.RoomMessageType.AUDIO.toString()).lessThan("messageId", MusicPlayer.mediaList.get(MusicPlayer.mediaList.size() - 1).id).findAll().sort("messageId", Sort.DESCENDING);
});
} catch (IllegalStateException e) {
}
if (realmRoomMessages != null && realmRoomMessages.size() > 0) {
// mRealmList = RealmRoomMessage.filterMessage(getUiRealm(), MusicPlayer.roomId, ProtoGlobal.RoomMessageType.AUDIO);
if (realmRoomMessages.size() > MusicPlayer.limitMediaList) {
realmRoomMessages = realmRoomMessages.subList(0, MusicPlayer.limitMediaList);
} else {
realmRoomMessages = realmRoomMessages.subList(0, realmRoomMessages.size());
}
footerAdapter.clear();
for (RealmRoomMessage r : realmRoomMessages) {
MessageObject messageObject = MessageObject.create(r);
if (messageObject.attachment.isFileExistsOnLocal(messageObject)) {
MusicPlayer.mediaList.add(messageObject);
}
fastItemAdapter.add(new AdapterListMusicPlayer().setItem(messageObject).withIdentifier(r.getMessageId()));
}
} else {
if (isThereAnyMoreItemToLoad)
new RequestClientSearchRoomHistory().clientSearchRoomHistory(MusicPlayer.roomId, nextMessageId, nextDocumentId, ProtoClientSearchRoomHistory.ClientSearchRoomHistory.Filter.AUDIO);
}
}
}
use of net.iGap.R in project iGap-Android by KianIranian-STDG.
the class FragmentChat method itemAdapterBottomSheetForward.
private void itemAdapterBottomSheetForward() {
String[] fieldNames = { "isPinned", "pinId", "updatedTime" };
Sort[] sort = { Sort.DESCENDING, Sort.DESCENDING, Sort.DESCENDING };
results = DbManager.getInstance().doRealmTask(realm -> {
return realm.where(RealmRoom.class).equalTo("keepRoom", false).equalTo("isDeleted", false).equalTo("readOnly", false).findAll().sort(fieldNames, sort);
});
resultsContact = DbManager.getInstance().doRealmTask(realm -> {
return realm.where(RealmContacts.class).findAll().sort("display_name");
});
List<Long> te = new ArrayList<>();
te.add(chatPeerId);
long identifier = 100L;
for (RealmRoom r : results) {
StructBottomSheetForward item = new StructBottomSheetForward();
item.setId(r.getId());
if (r.getType() == ProtoGlobal.Room.Type.CHAT) {
te.add(r.getChatRoom().getPeerId());
}
item.setDisplayName(r.getTitle());
if (r.getChatRoom() != null)
item.setPeer_id(r.getChatRoom().getPeerId());
item.setType(r.getType());
item.setContactList(false);
item.setNotExistRoom(false);
identifier = identifier + 1;
if (r.getChatRoom() != null && r.getChatRoom().getPeerId() > 0 && r.getChatRoom().getPeerId() == userId) {
fastItemAdapterForward.add(0, new ItemBottomSheetForward(item, avatarHandler).withIdentifier(identifier));
} else {
fastItemAdapterForward.add(new ItemBottomSheetForward(item, avatarHandler).withIdentifier(identifier));
}
}
for (RealmContacts r : resultsContact) {
if (!te.contains(r.getId())) {
StructBottomSheetForward item = new StructBottomSheetForward();
item.setId(r.getId());
item.setDisplayName(r.getDisplay_name());
item.setContactList(true);
item.setNotExistRoom(true);
identifier = identifier + 1;
fastItemAdapterForward.add(new ItemBottomSheetForward(item, avatarHandler).withIdentifier(identifier));
}
}
G.handler.postDelayed(new Runnable() {
@Override
public void run() {
if (isAdded()) {
bottomSheetDialogForward.show();
}
}
}, 100);
}
Aggregations