use of com.fanap.podchat.mainmodel.Thread in project pod-chat-android-sdk by FanapSoft.
the class ChatTest method sendMessageToThreadMessage.
@Test
@LargeTest
public void sendMessageToThreadMessage() {
populateThreadsListFromServerOrCache();
long threadID = 0;
for (Thread thread : new ArrayList<>(threads)) {
if (!thread.isClosed() && thread.isGroup() && thread.getAdmin()) {
threadID = thread.getId();
}
}
if (threadID > 0)
sendTestMessageOnSeen(threadID);
}
use of com.fanap.podchat.mainmodel.Thread in project pod-chat-android-sdk by FanapSoft.
the class ChatTest method getAllThreadsHistories.
@Test
@LargeTest
public // performance should be acceptable
void getAllThreadsHistories() {
// get 25 thread from server
populateThreadsListFromServerOrCache();
long startTime = System.currentTimeMillis();
for (Thread thread : new ArrayList<>(threads)) {
System.out.println("NEXT: " + thread.getTitle());
System.out.println(thread.getId());
getThreadFullHistory(thread);
}
long endTime = System.currentTimeMillis();
Assert.assertTrue(true);
System.out.println(">>> >>> >>>");
System.out.println(">>> >>> >>>");
System.out.println(">>> >>> >>>");
System.out.println("TEST IS DONE FOR ");
System.out.println(threads.size());
System.out.println("THREADS IN");
System.out.println(endTime - startTime + " MILLISECONDS");
System.out.println(">>> >>> >>>");
System.out.println(">>> >>> >>>");
System.out.println(">>> >>> >>>");
}
use of com.fanap.podchat.mainmodel.Thread in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method retrieveAndUpdateThreadOnLastMessageEdited.
public void retrieveAndUpdateThreadOnLastMessageEdited(Thread thread, ThreadManager.ILastMessageChanged callback) {
worker(() -> {
long threadId = thread.getId();
ArrayList<Integer> tIds = new ArrayList<>();
tIds.add((int) threadId);
try {
getThreadRaw(1, (long) 0, tIds, null, false, threads -> {
List<Thread> threadList = (List<Thread>) threads;
if (!Util.isNullOrEmpty(threadList) && threadList.get(0).getId() > 0) {
Thread threadFromCache = threadList.get(0);
threadFromCache.setLastMessage(thread.getLastMessage());
threadFromCache.setLastMessageVO(thread.getLastMessageVO());
callback.onThreadExistInCache(threadFromCache);
saveNewThread(threadFromCache);
} else {
callback.threadNotFoundInCache();
}
});
} catch (RoomIntegrityException e) {
e.printStackTrace();
callback.threadNotFoundInCache();
}
});
}
use of com.fanap.podchat.mainmodel.Thread in project pod-chat-android-sdk by FanapSoft.
the class ChatTestSandbox method getUserRolesInThread.
@Test
@LargeTest
public void getUserRolesInThread() {
populateThreadsListFromServerOrCache();
for (Thread t : threads) {
if (t.getAdmin()) {
System.out.println("Get roles in " + t.getId());
getCurrentUserRoles(t.getId());
break;
}
}
System.out.println("** Get roles in " + threads.get(0).getId());
getCurrentUserRoles(threads.get(0).getId());
}
use of com.fanap.podchat.mainmodel.Thread in project pod-chat-android-sdk by FanapSoft.
the class ChatTestSandbox method getThreadHistoryBeforeAndAfterLastSeenMessage.
@Test
@LargeTest
public // and greater in second case
void getThreadHistoryBeforeAndAfterLastSeenMessage() {
populateThreadsListFromServerOrCache();
System.out.println("** Get history of " + threads.get(0).getTitle());
Thread thread = threads.get(0);
final long lastSeen = thread.getLastSeenMessageTime() + thread.getLastSeenMessageNanos();
AtomicInteger numOfCacheResp = new AtomicInteger(0);
ChatListener historyListeners = new ChatListener() {
@Override
public void onGetHistory(String content, ChatResponse<ResultHistory> history) {
int invokeTimes = 0;
if (history.isCache()) {
invokeTimes = numOfCacheResp.getAndIncrement();
}
checkTimesIsValid(history, invokeTimes, lastSeen);
if (invokeTimes >= 2) {
resumeProcess();
}
}
};
chat.addListener(historyListeners);
RequestGetHistory requestGetHistoryBeforeLastSeenTime = new RequestGetHistory.Builder(thread.getId()).toTimeNanos(lastSeen).offset(0).count(25).order("desc").build();
presenter.getHistory(requestGetHistoryBeforeLastSeenTime, null);
RequestGetHistory requestGetHistoryAfterLastSeenTime = new RequestGetHistory.Builder(thread.getId()).fromTimeNanos(lastSeen).offset(0).count(25).order("asc").build();
presenter.getHistory(requestGetHistoryAfterLastSeenTime, null);
pauseProcess();
sleep(2000);
Mockito.verify(view, Mockito.atLeast(2)).onGetThreadHistory(Mockito.any());
}
Aggregations