use of com.fanap.podchat.model.ErrorOutPut in project pod-chat-android-sdk by FanapSoft.
the class ChatTestSandbox method uploadProgressImage.
@Test
@MediumTest
public void uploadProgressImage() {
sleep(3000);
Uri uri = Uri.parse("content://media/external/images/media/781");
presenter.uploadImageProgress(appContext, activity, uri, new ProgressHandler.onProgress() {
@Override
public void onProgressUpdate(int progress) {
Mockito.anyInt();
}
@Override
public void onFinish(String imageJson, ChatResponse<ResultImageFile> chatResponse) {
}
@Override
public void onError(String jsonError, ErrorOutPut error) {
}
});
}
use of com.fanap.podchat.model.ErrorOutPut in project pod-chat-android-sdk by FanapSoft.
the class TextMessagesQueueTest method banUserScenario.
@Test
public void banUserScenario() {
populateThreadsListFromServerOnly();
assert threads.size() > 0;
Thread thread = threads.get(0);
final boolean[] isBanned = { false };
ChatListener mTestListener = new ChatListener() {
@Override
public void onError(String content, ErrorOutPut error) {
if (error.getErrorCode() == 208) {
isBanned[0] = true;
}
}
};
chat.setListener(mTestListener);
int counter = 0;
while (!isBanned[0]) {
counter++;
RequestMessage request = new RequestMessage.Builder("Ban me i'm the " + counter + "th message", thread.getId()).messageType(TextMessageType.Constants.TEXT).build();
chat.sendTextMessage(request, null);
}
RequestMessage request = new RequestMessage.Builder("Ok! i'm ban now. but i'll be send after 60 000 milli second is passed", thread.getId()).messageType(TextMessageType.Constants.TEXT).build();
chat.sendTextMessage(request, null);
Assert.assertTrue(chat.getWaitingQ().size() > 0);
}
use of com.fanap.podchat.model.ErrorOutPut in project pod-chat-android-sdk by FanapSoft.
the class ThreadCacheTest method sendMessageAndDelete.
public void sendMessageAndDelete() {
populateThreadsFromServer();
Collections.shuffle(threadsInServer);
Thread thread = threadsInServer.get(0);
Assert.assertNotNull(thread);
ArrayList<Long> msgIds = new ArrayList<>();
// send new message
chatListeners = new ChatListener() {
@Override
public void onNewMessage(String content, ChatResponse<ResultNewMessage> response) {
resumeProcess();
msgIds.add(response.getResult().getMessageVO().getId());
System.out.println("new message sent -> msg : " + content);
chat.removeListener(chatListeners);
}
@Override
public void onError(String content, ErrorOutPut error) {
resumeProcess();
System.out.println("Error: " + content);
Assert.assertEquals(0, 1);
chat.removeListener(chatListeners);
}
};
chat.addListener(chatListeners);
RequestMessage request = new RequestMessage.Builder("Message for test delete :" + thread.getId(), thread.getId()).messageType(TextMessageType.Constants.TEXT).build();
chat.sendTextMessage(request, null);
pauseProcess();
// delete last message
chatListeners = new ChatListener() {
@Override
public void onDeleteMessage(String content, ChatResponse<ResultDeleteMessage> response) {
resumeProcess();
System.out.println("Deleted: " + content);
chat.removeListener(chatListeners);
}
@Override
public void onError(String content, ErrorOutPut error) {
resumeProcess();
System.out.println("Error: " + content);
Assert.assertEquals(0, 1);
chat.removeListener(chatListeners);
}
};
chat.addListener(chatListeners);
RequestDeleteMessage requestDeleteMessage = new RequestDeleteMessage.Builder().messageIds(msgIds).deleteForAll(true).build();
presenter.deleteMessage(requestDeleteMessage, null);
pauseProcess();
}
use of com.fanap.podchat.model.ErrorOutPut in project pod-chat-android-sdk by FanapSoft.
the class ThreadCacheTest method sendMessageAndEdit.
public void sendMessageAndEdit() {
populateThreadsFromServer();
Collections.shuffle(threadsInServer);
Thread thread = threadsInServer.get(0);
Assert.assertNotNull(thread);
final long[] messageId = { 0 };
// send new message
chatListeners = new ChatListener() {
@Override
public void onNewMessage(String content, ChatResponse<ResultNewMessage> response) {
messageId[0] = response.getResult().getMessageVO().getId();
resumeProcess();
System.out.println("new message sent -> msg : " + content);
chat.removeListener(chatListeners);
}
@Override
public void onError(String content, ErrorOutPut error) {
resumeProcess();
System.out.println("Error: " + content);
Assert.assertEquals(0, 1);
chat.removeListener(chatListeners);
}
};
chat.addListener(chatListeners);
RequestMessage request = new RequestMessage.Builder("Message for test edit :" + thread.getId(), thread.getId()).messageType(TextMessageType.Constants.TEXT).build();
chat.sendTextMessage(request, null);
pauseProcess();
// delete last message
chatListeners = new ChatListener() {
@Override
public void onEditedMessage(String content, ChatResponse<ResultNewMessage> response) {
resumeProcess();
System.out.println("Edited: " + content);
chat.removeListener(chatListeners);
}
@Override
public void onError(String content, ErrorOutPut error) {
resumeProcess();
System.out.println("Error: " + content);
Assert.assertEquals(0, 1);
chat.removeListener(chatListeners);
}
};
chat.addListener(chatListeners);
RequestEditMessage requestEditMessage = new RequestEditMessage.Builder("last message edited " + messageId[0], messageId[0]).build();
chat.editMessage(requestEditMessage, null);
pauseProcess();
}
use of com.fanap.podchat.model.ErrorOutPut in project pod-chat-android-sdk by FanapSoft.
the class ChatActivity method sendLocationMsg.
private void sendLocationMsg() {
String center = "35.7003510,51.3376472";
String meta = getMetaData();
RequestLocationMessage requestLocationMessage = new RequestLocationMessage.Builder().systemMetadata(meta).center(center).message("Im here now : ) ").setUserGroupHash(TEST_THREAD_HASH).activity(ChatActivity.this).threadId(TEST_THREAD_ID).build();
// presenter.sendLocationMessage(requestLocationMessage);
presenter.sendLocationMessage(requestLocationMessage, new ProgressHandler.sendFileMessage() {
@Override
public void onProgressUpdate(String uniqueId, int progress, int totalBytesSent, int totalBytesToSend) {
Log.d("MTAG", "Update progress: " + "Total Bytes sent: " + totalBytesSent + " Total Bytes left " + totalBytesToSend);
}
@Override
public void onFinishImage(String json, ChatResponse<ResultImageFile> chatResponse) {
Log.d("MTAG", "Finish upload");
}
@Override
public void onError(String jsonError, ErrorOutPut error) {
Log.d("MTAG", "Error upload");
}
});
}
Aggregations