Search in sources :

Example 1 with UserBlockTask

use of com.applozic.mobicomkit.api.account.user.UserBlockTask 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 2 with UserBlockTask

use of com.applozic.mobicomkit.api.account.user.UserBlockTask in project Applozic-Android-SDK by AppLozic.

the class AppContactFragment method blockUserProcess.

public void blockUserProcess(final Contact contact, final boolean block) {
    final ProgressDialog progressDialog = ProgressDialog.show(getActivity(), "", getActivity().getString(R.string.please_wait_info), true);
    UserBlockTask.TaskListener listener = new UserBlockTask.TaskListener() {

        @Override
        public void onSuccess(ApiResponse apiResponse) {
            getLoaderManager().restartLoader(ContactsQuery.QUERY_ID, null, AppContactFragment.this);
        }

        @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();
            }
        }
    };
    AlTask.execute(new UserBlockTask(getActivity(), listener, contact.getUserId(), block));
}
Also used : Toast(android.widget.Toast) UserBlockTask(com.applozic.mobicomkit.api.account.user.UserBlockTask) SpannableString(android.text.SpannableString) ProgressDialog(android.app.ProgressDialog) RegisteredUsersApiResponse(com.applozic.mobicomkit.feed.RegisteredUsersApiResponse) ApiResponse(com.applozic.mobicomkit.feed.ApiResponse)

Aggregations

ProgressDialog (android.app.ProgressDialog)2 Toast (android.widget.Toast)2 UserBlockTask (com.applozic.mobicomkit.api.account.user.UserBlockTask)2 ApiResponse (com.applozic.mobicomkit.feed.ApiResponse)2 SpannableString (android.text.SpannableString)1 ApplozicException (com.applozic.mobicomkit.exception.ApplozicException)1 RegisteredUsersApiResponse (com.applozic.mobicomkit.feed.RegisteredUsersApiResponse)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1