Search in sources :

Example 1 with AlAsyncTask

use of com.applozic.mobicommons.task.AlAsyncTask in project Applozic-Android-SDK by AppLozic.

the class ApplozicConversation method deleteConversation.

/**
 * Delete a group (<i>channelKey</i>) or 1-to-1 conversation (<i>contact</i>) or both. Use with caution.
 *
 * <p>Will return true for a successful delete.</p>
 */
@NonNull
private static AlAsyncTask<Void, Boolean> deleteConversation(@NonNull Context context, @Nullable Integer channelKey, @Nullable Contact contact) {
    return new AlAsyncTask<Void, Boolean>() {

        @Override
        protected Boolean doInBackground() {
            if ((channelKey == null || channelKey == 0) && contact == null) {
                return false;
            }
            Channel channel = (channelKey != null && channelKey != 0) ? new Channel(channelKey) : null;
            String response = new MobiComConversationService(context).deleteSync(contact, channel, null);
            return !TextUtils.isEmpty(response) && MobiComKitConstants.SUCCESS.equals(response);
        }
    };
}
Also used : AlAsyncTask(com.applozic.mobicommons.task.AlAsyncTask) Channel(com.applozic.mobicommons.people.channel.Channel) NonNull(androidx.annotation.NonNull)

Aggregations

NonNull (androidx.annotation.NonNull)1 Channel (com.applozic.mobicommons.people.channel.Channel)1 AlAsyncTask (com.applozic.mobicommons.task.AlAsyncTask)1