Search in sources :

Example 1 with RequestUploadImage

use of com.fanap.podchat.requestobject.RequestUploadImage in project pod-chat-android-sdk by FanapSoft.

the class ChatActivity method createThreadWithFile.

private void createThreadWithFile() {
    if (getUri() == null) {
        Toast.makeText(this, "Pick a file", Toast.LENGTH_SHORT).show();
        return;
    }
    RequestUploadImage requestUploadThreadImageImage = new RequestUploadImage.Builder(this, getUri()).setwC(140).sethC(140).build();
    RequestUploadImage requestUploadImage = new RequestUploadImage.Builder(this, getUri()).setwC(120).sethC(120).setxC(1).setyC(1).build();
    RequestUploadFile requestUploadFile = new RequestUploadFile.Builder(this, getUri()).build();
    List<Invitee> invite = new ArrayList<>();
    // f.kh sandbox
    // invite.add(new Invitee("4893", InviteType.Constants.TO_BE_USER_CONTACT_ID));
    // POURIA main
    invite.add(new Invitee(1151568, InviteType.Constants.TO_BE_USER_CONTACT_ID));
    // MASOUD
    // invite.add(new Invitee(1511971, InviteType.Constants.TO_BE_USER_CONTACT_ID));
    // ARVIN
    invite.add(new Invitee(1512305, InviteType.Constants.TO_BE_USER_CONTACT_ID));
    // MAHYAR
    // invite.add(new Invitee(1196793, InviteType.Constants.TO_BE_USER_CONTACT_ID));
    // RequestThreadInnerMessage innerMessage = new RequestThreadInnerMessage
    // .Builder(TextMessageType.Constants.PICTURE)
    // //       .message("Create thread for File Message Test " + new Date().toString())
    // //     .forwardedMessageIds(listForwardIds)
    // .build();
    RequestCreateThreadWithFile request = new RequestCreateThreadWithFile.Builder(ThreadType.Constants.OWNER_GROUP, invite, requestUploadFile, TextMessageType.Constants.POD_SPACE_FILE).title("Test File PodSpace").setUploadThreadImageRequest(requestUploadThreadImageImage).build();
    presenter.createThreadWithFile(request, new ProgressHandler.sendFileMessage() {

        @Override
        public void onProgressUpdate(String uniqueId, int progress, int totalBytesSent, int totalBytesToSend) {
            Log.e("CTF", "Upload Progress: " + progress);
        }

        @Override
        public void onFinishImage(String json, ChatResponse<ResultImageFile> chatResponse) {
            Log.e("CTF", "Upload Finish (IMAGE): ");
        }

        @Override
        public void onFinishFile(String json, ChatResponse<ResultFile> chatResponse) {
            Log.e("CTF", "Upload Finish (FILE): ");
        }

        @Override
        public void onError(String jsonError, ErrorOutPut error) {
            Log.e("CTF", "Upload Error");
        }
    });
}
Also used : RequestUploadImage(com.fanap.podchat.requestobject.RequestUploadImage) ProgressHandler(com.fanap.podchat.ProgressHandler) ArrayList(java.util.ArrayList) ResultFile(com.fanap.podchat.model.ResultFile) Invitee(com.fanap.podchat.mainmodel.Invitee) ResultImageFile(com.fanap.podchat.model.ResultImageFile) RequestUploadFile(com.fanap.podchat.requestobject.RequestUploadFile) ErrorOutPut(com.fanap.podchat.model.ErrorOutPut) RequestCreateThreadWithFile(com.fanap.podchat.requestobject.RequestCreateThreadWithFile)

Example 2 with RequestUploadImage

use of com.fanap.podchat.requestobject.RequestUploadImage in project pod-chat-android-sdk by FanapSoft.

the class ChatPresenter method uploadImageProgress.

@Override
public void uploadImageProgress(Context context, Activity activity, Uri fileUri, ProgressHandler.onProgress handler) {
    RequestUploadImage req = new RequestUploadImage.Builder(activity, fileUri).setwC(240).sethC(120).setxC(10).setyC(5).setPublic(false).build();
    // chat.uploadImageProgress(activity,fileUri,handler);
    chat.uploadImageProgress(req, handler);
}
Also used : RequestUploadImage(com.fanap.podchat.requestobject.RequestUploadImage)

Example 3 with RequestUploadImage

use of com.fanap.podchat.requestobject.RequestUploadImage in project pod-chat-android-sdk by FanapSoft.

the class ChatCore method createThreadWithFile.

// 
// 1. Create thread.
// 2.1. Upload thread image and update thread info if RequestUploadImage is set.
// 2.2. Upload file to server with thread userGroupHash and send uploaded file as message by sendFileMessage.
// 
public ArrayList<String> createThreadWithFile(RequestCreateThreadWithFile request, @Nullable ProgressHandler.sendFileMessage progressHandler) {
    ArrayList<String> uniqueIds = new ArrayList<>();
    String requestUniqueId = generateUniqueId();
    uniqueIds.add(requestUniqueId);
    if (needReadStoragePermission(request.getFile().getActivity()))
        return uniqueIds;
    if (chatReady) {
        handlerSend.put(requestUniqueId, new ChatHandler() {

            @Override
            public void onThreadCreated(ResultThread thread) {
                super.onThreadCreated(thread);
                if (request.getUploadThreadImageRequest() != null)
                    new PodThreadManager().doThisAndGo(() -> updateThreadImage(thread, request.getUploadThreadImageRequest()));
                RequestFileMessage.Builder requestFileBuilder = new RequestFileMessage.Builder(request.getMessage() != null ? request.getMessage().getText() : null, request.getFile().getActivity(), thread.getThread().getId(), request.getFile().getFileUri(), request.getMessage() != null ? request.getMessage().getSystemMetadata() : null, request.getMessageType(), thread.getThread().getUserGroupHash());
                if (request.getFile() instanceof RequestUploadImage) {
                    requestFileBuilder.setImageHc(String.valueOf(((RequestUploadImage) request.getFile()).gethC()));
                    requestFileBuilder.setImageWc(String.valueOf(((RequestUploadImage) request.getFile()).getwC()));
                    requestFileBuilder.setImageXc(String.valueOf(((RequestUploadImage) request.getFile()).getxC()));
                    requestFileBuilder.setImageYc(String.valueOf(((RequestUploadImage) request.getFile()).getyC()));
                }
                RequestFileMessage requestFile = requestFileBuilder.build();
                sendFileMessage(requestFile, requestUniqueId, progressHandler);
            }
        });
        RequestCreateThread requestCreateThread = new RequestCreateThread.Builder(request.getType(), request.getInvitees()).title(request.getTitle()).withDescription(request.getDescription()).withImage(request.getImage()).withMetadata(request.getMessage() != null ? request.getMessage().getSystemMetadata() : null).build();
        createThread(requestCreateThread, requestUniqueId);
    // prepareCreateThreadWithFile(request, requestUniqueId, innerMessageUniqueId, forwardUniqueIds, "");
    } else {
        captureError(ChatConstant.ERROR_CHAT_READY, ChatConstant.ERROR_CODE_CHAT_READY, requestUniqueId);
    }
    return uniqueIds;
}
Also used : PodThreadManager(com.fanap.podchat.util.PodThreadManager) RequestUploadImage(com.fanap.podchat.requestobject.RequestUploadImage) GsonBuilder(com.google.gson.GsonBuilder) ArrayList(java.util.ArrayList) RequestCreateThread(com.fanap.podchat.requestobject.RequestCreateThread) ResultThread(com.fanap.podchat.model.ResultThread) RequestFileMessage(com.fanap.podchat.requestobject.RequestFileMessage)

Example 4 with RequestUploadImage

use of com.fanap.podchat.requestobject.RequestUploadImage in project pod-chat-android-sdk by FanapSoft.

the class ChatPresenter method uploadImage.

@Override
public void uploadImage(Activity activity, Uri fileUri) {
    RequestUploadImage req = new RequestUploadImage.Builder(activity, fileUri).build();
    chat.uploadImage(req);
}
Also used : RequestUploadImage(com.fanap.podchat.requestobject.RequestUploadImage)

Example 5 with RequestUploadImage

use of com.fanap.podchat.requestobject.RequestUploadImage in project pod-chat-android-sdk by FanapSoft.

the class ChatActivity method createThread.

private void createThread() {
    /**
     * int TO_BE_USER_SSO_ID = 1;
     * int TO_BE_USER_CONTACT_ID = 2;
     * int TO_BE_USER_CELLPHONE_NUMBER = 3;
     * int TO_BE_USER_USERNAME = 4;
     * int TO_BE_USER_ID = 5; // just for p2p
     */
    /**
     *"create thread"
     * This is Invitee object
     * ---->private int id;
     * ---->private int idType;
     *
     * createThreadTypes = {
     *NORMAL: 0,
     *OWNER_GROUP: 1,
     *PUBLIC_GROUP: 2,
     *CHANNEL_GROUP: 4,
     *CHANNEL: 8
     *       }
     */
    // Invitee[] invite = new Invitee[]{
    // new Invitee(2951, 2)
    // , new Invitee(1967, 2)
    // ,new Invitee(123, 5)
    // , new Invitee(824, 2)
    // };
    /**
     * CHANNEL_GROUP: 4,
     */
    // Invitee[] invite = new Invitee[]{
    // //       new Invitee(3361, 2)
    // //       , new Invitee(3102, 2)
    // //       new Invitee(091, 1),
    // //       new Invitee("22835", InviteType.Constants.TO_BE_USER_CONTACT_ID),
    // new Invitee("29782", InviteType.Constants.TO_BE_USER_CONTACT_ID),
    // //       new Invitee("27774", InviteType.Constants.TO_BE_USER_CONTACT_ID),
    // //       new Invitee("22835", InviteType.Constants.TO_BE_USER_CONTACT_ID),
    // //       new Invitee(5638, 2),
    // //       new Invitee("z.mohammadi", InviteType.Constants.TO_BE_USER_USERNAME),
    // //      new Invitee("p.khoshghadam", InviteType.Constants.TO_BE_USER_USERNAME),
    // //      new Invitee("m.hasanpour", InviteType.Constants.TO_BE_USER_USERNAME),
    // //      new Invitee("z.ershad", InviteType.Constants.TO_BE_USER_USERNAME),
    // //      new Invitee("samira.amiri", InviteType.Constants.TO_BE_USER_USERNAME),
    // //      new Invitee("s.heydarizadeh", InviteType.Constants.TO_BE_USER_USERNAME),
    // //      new Invitee("p.pahlavani", InviteType.Constants.TO_BE_USER_USERNAME),
    // //      new Invitee("ma.amjadi", InviteType.Constants.TO_BE_USER_USERNAME),
    // //       new Invitee(5638, 2),
    // };
    Inviter inviterw = new Inviter();
    inviterw.setName("this is sample metadata");
    String metac = gson.toJson(inviterw);
    List<Invitee> invite = new ArrayList<>();
    // add by user SSO_ID
    // invite.add(new Invitee(122, 1));  //user jiji
    // invite.add(new Invitee("121", 1)); // user zizi
    // invite.add(new Invitee("63270", InviteType.Constants.TO_BE_USER_CONTACT_ID));
    // invite.add(new Invitee("63271", InviteType.Constants.TO_BE_USER_CONTACT_ID));
    // integration users
    // invite.add(new Invitee("63256", InviteType.Constants.TO_BE_USER_CONTACT_ID));
    // invite.add(new Invitee("63255", InviteType.Constants.TO_BE_USER_CONTACT_ID));
    // invite.add(new Invitee("63253", InviteType.Constants.TO_BE_USER_CONTACT_ID));
    // sand box users
    // 52620 farhad
    // 52979 masoud
    // 52987 khodam
    // invite.add(new Invitee("52620", InviteType.Constants.TO_BE_USER_CONTACT_ID));
    invite.add(new Invitee("63254", InviteType.Constants.TO_BE_USER_CONTACT_ID));
    // invite.add(new Invitee("52987", InviteType.Constants.TO_BE_USER_CONTACT_ID));
    // invite.add(new Invitee("1", InviteType.Constants.TO_BE_USER_ID)); //amjadi
    // invite.add(new Invitee("80618", InviteType.Constants.TO_BE_USER_CONTACT_ID));
    // invite.add(new Invitee(9981084527L, 3)); zizi cellphone
    // invite.add(new Invitee(123, 5)); //user fifi
    // invite.add(new Invitee(121, 5)); // user zizi
    // invite.add(new Invitee(122, 1));  //user jiji
    RequestUploadImage requestUploadImage = new RequestUploadImage.Builder(ChatActivity.this, getUri()).sethC(140).setwC(140).build();
    RequestCreateThread requestCreateThread = new RequestCreateThread.Builder(ThreadType.Constants.NORMAL, invite).title("Test Thread ByAhmad" + (new Date().getTime() / 1000)).build();
    presenter.createThread(requestCreateThread);
}
Also used : Invitee(com.fanap.podchat.mainmodel.Invitee) RequestUploadImage(com.fanap.podchat.requestobject.RequestUploadImage) Inviter(com.fanap.podchat.mainmodel.Inviter) GsonBuilder(com.google.gson.GsonBuilder) ArrayList(java.util.ArrayList) RequestCreateThread(com.fanap.podchat.requestobject.RequestCreateThread) Date(java.util.Date)

Aggregations

RequestUploadImage (com.fanap.podchat.requestobject.RequestUploadImage)6 ArrayList (java.util.ArrayList)4 Invitee (com.fanap.podchat.mainmodel.Invitee)3 RequestCreateThread (com.fanap.podchat.requestobject.RequestCreateThread)3 GsonBuilder (com.google.gson.GsonBuilder)2 Date (java.util.Date)2 ProgressHandler (com.fanap.podchat.ProgressHandler)1 Inviter (com.fanap.podchat.mainmodel.Inviter)1 RequestThreadInnerMessage (com.fanap.podchat.mainmodel.RequestThreadInnerMessage)1 ErrorOutPut (com.fanap.podchat.model.ErrorOutPut)1 ResultFile (com.fanap.podchat.model.ResultFile)1 ResultImageFile (com.fanap.podchat.model.ResultImageFile)1 ResultThread (com.fanap.podchat.model.ResultThread)1 RequestCreateThreadWithFile (com.fanap.podchat.requestobject.RequestCreateThreadWithFile)1 RequestFileMessage (com.fanap.podchat.requestobject.RequestFileMessage)1 RequestUploadFile (com.fanap.podchat.requestobject.RequestUploadFile)1 PodThreadManager (com.fanap.podchat.util.PodThreadManager)1