Search in sources :

Example 21 with ApiResponse

use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.

the class ConversationClientService method closeConversation.

public String closeConversation(Integer conversationId) {
    String response;
    try {
        if (conversationId != null) {
            response = httpRequestUtils.getResponse(getConversationCloseUrl() + "?id=" + String.valueOf(conversationId), "application/json", "application/json");
            if (TextUtils.isEmpty(response)) {
                return null;
            }
            ApiResponse apiResponse = (ApiResponse) GsonUtils.getObjectFromJson(response, ApiResponse.class);
            Utils.printLog(context, TAG, "Conversation close  API Response :" + response);
            if (apiResponse != null && apiResponse.isSuccess()) {
                return apiResponse.getResponse().toString();
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : ChannelFeedApiResponse(com.applozic.mobicomkit.feed.ChannelFeedApiResponse) ApiResponse(com.applozic.mobicomkit.feed.ApiResponse)

Example 22 with ApiResponse

use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.

the class MobiComConversationFragment method blockUserProcess.

public void blockUserProcess(final String userId, final boolean block, final boolean isFromChannel) {
    final ProgressDialog progressDialog = ProgressDialog.show(getActivity(), "", ApplozicService.getContext(getContext()).getString(R.string.please_wait_info), true);
    UserBlockTask.TaskListener listener = new UserBlockTask.TaskListener() {

        @Override
        public void onSuccess(ApiResponse apiResponse) {
            if (block && typingStarted) {
                if (getActivity() != null) {
                    setToolbarSubtitle("");
                }
                Applozic.publishTypingStatus(getActivity(), null, contact, false);
            }
            menu.findItem(R.id.userBlock).setVisible(!block);
            menu.findItem(R.id.userUnBlock).setVisible(block);
        }

        @Override
        public void onFailure(ApiResponse apiResponse, Exception exception) {
            String error = getString(Utils.isInternetAvailable(getActivity()) ? R.string.applozic_server_error : R.string.you_need_network_access_for_block_or_unblock);
            Toast toast = Toast.makeText(getActivity(), error, Toast.LENGTH_LONG);
            toast.setGravity(Gravity.CENTER, 0, 0);
            toast.show();
        }

        @Override
        public void onCompletion() {
            if (progressDialog != null && progressDialog.isShowing()) {
                progressDialog.dismiss();
            }
            if (!isFromChannel) {
                contact = appContactService.getContactById(userId);
            }
        }
    };
    AlTask.execute(new UserBlockTask(getActivity(), listener, userId, block));
}
Also used : Toast(android.widget.Toast) UserBlockTask(com.applozic.mobicomkit.api.account.user.UserBlockTask) ProgressDialog(android.app.ProgressDialog) ApiResponse(com.applozic.mobicomkit.feed.ApiResponse) ApplozicException(com.applozic.mobicomkit.exception.ApplozicException) PatternSyntaxException(java.util.regex.PatternSyntaxException)

Example 23 with ApiResponse

use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.

the class MobiComConversationFragment method umuteGroupChat.

public void umuteGroupChat() {
    Date date = Calendar.getInstance(TimeZone.getTimeZone("UTC")).getTime();
    millisecond = date.getTime();
    final MuteNotificationAsync.TaskListener taskListener = new MuteNotificationAsync.TaskListener() {

        @Override
        public void onSuccess(ApiResponse apiResponse) {
            if (menu != null) {
                menu.findItem(R.id.unmuteGroup).setVisible(false);
                menu.findItem(R.id.muteGroup).setVisible(true);
            }
        }

        @Override
        public void onFailure(ApiResponse apiResponse, Exception exception) {
        }

        @Override
        public void onCompletion() {
        }
    };
    muteNotificationRequest = new MuteNotificationRequest(channel.getKey(), millisecond);
    MuteNotificationAsync muteNotificationAsync = new MuteNotificationAsync(getContext(), taskListener, muteNotificationRequest);
    AlTask.execute(muteNotificationAsync);
}
Also used : MuteNotificationRequest(com.applozic.mobicomkit.api.notification.MuteNotificationRequest) Date(java.util.Date) MuteNotificationAsync(com.applozic.mobicomkit.api.notification.MuteNotificationAsync) ApiResponse(com.applozic.mobicomkit.feed.ApiResponse) ApplozicException(com.applozic.mobicomkit.exception.ApplozicException) PatternSyntaxException(java.util.regex.PatternSyntaxException)

Example 24 with ApiResponse

use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.

the class UserService method updateDisplayNameORImageLink.

public String updateDisplayNameORImageLink(String displayName, String profileImageLink, String localURL, String status, String contactNumber) {
    ApiResponse response = userClientService.updateDisplayNameORImageLink(displayName, profileImageLink, status, contactNumber);
    if (response == null) {
        return null;
    }
    if (response != null && response.isSuccess()) {
        Contact contact = baseContactService.getContactById(MobiComUserPreference.getInstance(context).getUserId());
        if (!TextUtils.isEmpty(displayName)) {
            contact.setFullName(displayName);
        }
        if (!TextUtils.isEmpty(profileImageLink)) {
            contact.setImageURL(profileImageLink);
        }
        contact.setLocalImageUrl(localURL);
        if (!TextUtils.isEmpty(status)) {
            contact.setStatus(status);
        }
        if (!TextUtils.isEmpty(contactNumber)) {
            contact.setContactNumber(contactNumber);
        }
        baseContactService.upsert(contact);
        Contact contact1 = baseContactService.getContactById(MobiComUserPreference.getInstance(context).getUserId());
        Utils.printLog(context, "UserService", contact1.getImageURL() + ", " + contact1.getDisplayName() + "," + contact1.getStatus() + "," + contact1.getStatus());
    }
    return response.getStatus();
}
Also used : ApiResponse(com.applozic.mobicomkit.feed.ApiResponse) RegisteredUsersApiResponse(com.applozic.mobicomkit.feed.RegisteredUsersApiResponse) SyncBlockUserApiResponse(com.applozic.mobicomkit.feed.SyncBlockUserApiResponse) Contact(com.applozic.mobicommons.people.contact.Contact)

Example 25 with ApiResponse

use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.

the class ChannelClientService method deleteChannel.

public synchronized ApiResponse deleteChannel(Integer channelKey) {
    try {
        if (channelKey != null) {
            String url = getChannelDeleteUrl() + "?" + GROUP_ID + "=" + URLEncoder.encode(String.valueOf(channelKey), "UTF-8");
            String response = httpRequestUtils.getResponse(url, "application/json", "application/json");
            ApiResponse apiResponse = (ApiResponse) GsonUtils.getObjectFromJson(response, ApiResponse.class);
            if (apiResponse != null) {
                Utils.printLog(context, TAG, "Channel delete call response: " + apiResponse.getStatus());
            }
            return apiResponse;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : MultipleChannelFeedApiResponse(com.applozic.mobicomkit.MultipleChannelFeedApiResponse) ChannelFeedApiResponse(com.applozic.mobicomkit.feed.ChannelFeedApiResponse) ApiResponse(com.applozic.mobicomkit.feed.ApiResponse)

Aggregations

ApiResponse (com.applozic.mobicomkit.feed.ApiResponse)54 SyncBlockUserApiResponse (com.applozic.mobicomkit.feed.SyncBlockUserApiResponse)23 ChannelFeedApiResponse (com.applozic.mobicomkit.feed.ChannelFeedApiResponse)22 JSONException (org.json.JSONException)19 ApplozicException (com.applozic.mobicomkit.exception.ApplozicException)16 RegisteredUsersApiResponse (com.applozic.mobicomkit.feed.RegisteredUsersApiResponse)16 Test (org.junit.Test)14 MultipleChannelFeedApiResponse (com.applozic.mobicomkit.MultipleChannelFeedApiResponse)12 MockedConstants.userDetailsApiResponse (com.applozic.mobicomkit.MockedConstants.userDetailsApiResponse)10 UnsupportedEncodingException (java.io.UnsupportedEncodingException)9 Nullable (androidx.annotation.Nullable)8 Contact (com.applozic.mobicommons.people.contact.Contact)8 ChannelUserMapper (com.applozic.mobicommons.people.channel.ChannelUserMapper)3 ArrayList (java.util.ArrayList)3 PatternSyntaxException (java.util.regex.PatternSyntaxException)3 ProgressDialog (android.app.ProgressDialog)2 Toast (android.widget.Toast)2 UserBlockTask (com.applozic.mobicomkit.api.account.user.UserBlockTask)2 MuteNotificationAsync (com.applozic.mobicomkit.api.notification.MuteNotificationAsync)2 MuteNotificationRequest (com.applozic.mobicomkit.api.notification.MuteNotificationRequest)2