Search in sources :

Example 26 with NotificationManagerCompat

use of androidx.core.app.NotificationManagerCompat in project Applozic-Android-SDK by AppLozic.

the class MobiComConversationFragment method onResume.

@Override
public void onResume() {
    super.onResume();
    if (MobiComUserPreference.getInstance(getActivity()).isChannelDeleted()) {
        MobiComUserPreference.getInstance(getActivity()).setDeleteChannel(false);
        if (getActivity().getSupportFragmentManager() != null) {
            getActivity().getSupportFragmentManager().popBackStack();
        }
        return;
    }
    ((ConversationActivity) getActivity()).setChildFragmentLayoutBGToTransparent();
    if (contact != null || channel != null) {
        BroadcastService.currentUserId = contact != null ? contact.getContactIds() : String.valueOf(channel.getKey());
        BroadcastService.currentConversationId = currentConversationId;
        if (BroadcastService.currentUserId != null) {
            NotificationManagerCompat nMgr = NotificationManagerCompat.from(getActivity());
            if (ApplozicClient.getInstance(getActivity()).isNotificationStacking()) {
                nMgr.cancel(NotificationService.NOTIFICATION_ID);
            } else {
                if (contact != null && !TextUtils.isEmpty(contact.getContactIds())) {
                    nMgr.cancel(contact.getContactIds().hashCode());
                }
                if (channel != null) {
                    nMgr.cancel(String.valueOf(channel.getKey()).hashCode());
                }
            }
        }
        if (downloadConversation != null) {
            downloadConversation.cancel(true);
        }
        if (channel != null) {
            Channel newChannel = ChannelService.getInstance(getActivity()).getChannelByChannelKey(channel.getKey());
            if (newChannel != null && newChannel.getType() != null && Channel.GroupType.OPEN.getValue().equals(newChannel.getType())) {
                MobiComUserPreference.getInstance(getActivity()).setNewMessageFlag(true);
            }
            enableOrDisableChannel(newChannel);
            if (ChannelService.isUpdateTitle) {
                updateChannelSubTitle(newChannel);
                ChannelService.isUpdateTitle = false;
            }
        }
        if (messageList.isEmpty()) {
            loadConversation(contact, channel, currentConversationId, null);
        } else if (MobiComUserPreference.getInstance(getContext()).getNewMessageFlag()) {
            MobiComUserPreference.getInstance(getContext()).setNewMessageFlag(false);
            loadNewMessageOnResume(contact, channel, currentConversationId);
        } else {
            Applozic.subscribeToTyping(getContext(), channel, contact);
        }
        if (SyncCallService.refreshView) {
            SyncCallService.refreshView = false;
        }
    }
    swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        public void onRefresh() {
            downloadConversation = new DownloadConversation(recyclerView, false, 1, 1, 1, contact, channel, currentConversationId);
            AlTask.execute(downloadConversation);
        }
    });
    activateOrDeactivateChat();
}
Also used : ConversationActivity(com.applozic.mobicomkit.uiwidgets.conversation.activity.ConversationActivity) Channel(com.applozic.mobicommons.people.channel.Channel) NotificationManagerCompat(androidx.core.app.NotificationManagerCompat) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout)

Aggregations

NotificationManagerCompat (androidx.core.app.NotificationManagerCompat)26 PendingIntent (android.app.PendingIntent)6 Notification (android.app.Notification)5 Intent (android.content.Intent)5 NotificationCompat (androidx.core.app.NotificationCompat)5 NotificationChannel (android.app.NotificationChannel)2 NotificationManager (android.app.NotificationManager)2 Bundle (android.os.Bundle)2 NotificationChannelCompat (androidx.core.app.NotificationChannelCompat)2 TaskStackBuilder (android.app.TaskStackBuilder)1 Bitmap (android.graphics.Bitmap)1 RequiresApi (androidx.annotation.RequiresApi)1 NotificationChannelGroupCompat (androidx.core.app.NotificationChannelGroupCompat)1 WearableExtender (androidx.core.app.NotificationCompat.WearableExtender)1 RemoteInput (androidx.core.app.RemoteInput)1 TaskStackBuilder (androidx.core.app.TaskStackBuilder)1 MediaStyle (androidx.media.app.NotificationCompat.MediaStyle)1 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)1 MobiComConversationService (com.applozic.mobicomkit.api.conversation.MobiComConversationService)1 ApplozicException (com.applozic.mobicomkit.exception.ApplozicException)1