Search in sources :

Example 41 with Channel

use of com.applozic.mobicommons.people.channel.Channel in project Applozic-Android-SDK by AppLozic.

the class ChannelService method processChannelFeedList.

public void processChannelFeedList(ChannelFeed[] channelFeeds, boolean isUserDetails) {
    if (channelFeeds != null && channelFeeds.length > 0) {
        for (ChannelFeed channelFeed : channelFeeds) {
            Set<String> memberUserIds = channelFeed.getMembersName();
            Set<String> userIds = new HashSet<>();
            Channel channel = getChannel(channelFeed);
            if (channelDatabaseService.isChannelPresent(channel.getKey())) {
                channelDatabaseService.updateChannel(channel);
            } else {
                channelDatabaseService.addChannel(channel);
            }
            if (channelFeed.getConversationPxy() != null) {
                channelFeed.getConversationPxy().setGroupId(channelFeed.getId());
                ConversationService.getInstance(context).addConversation(channelFeed.getConversationPxy());
            }
            if (memberUserIds != null && memberUserIds.size() > 0) {
                for (String userId : memberUserIds) {
                    ChannelUserMapper channelUserMapper = new ChannelUserMapper(channelFeed.getId(), userId);
                    if (channelDatabaseService.isChannelUserPresent(channelFeed.getId(), userId)) {
                        channelDatabaseService.updateChannelUserMapper(channelUserMapper);
                    } else {
                        channelDatabaseService.addChannelUserMapper(channelUserMapper);
                    }
                }
            }
            if (channelFeed.getGroupUsers() != null && channelFeed.getGroupUsers().size() > 0) {
                for (ChannelUsersFeed channelUsers : channelFeed.getGroupUsers()) {
                    if (channelUsers.getRole() != null) {
                        channelDatabaseService.updateRoleInChannelUserMapper(channelFeed.getId(), channelUsers.getUserId(), channelUsers.getRole());
                    }
                }
            }
            if (isUserDetails) {
                userService.processUserDetail(channelFeed.getUsers());
            }
        }
    }
}
Also used : ChannelUsersFeed(com.applozic.mobicomkit.feed.ChannelUsersFeed) Channel(com.applozic.mobicommons.people.channel.Channel) SyncChannelFeed(com.applozic.mobicomkit.sync.SyncChannelFeed) ChannelFeed(com.applozic.mobicomkit.feed.ChannelFeed) ChannelUserMapper(com.applozic.mobicommons.people.channel.ChannelUserMapper) HashSet(java.util.HashSet)

Example 42 with Channel

use of com.applozic.mobicommons.people.channel.Channel in project Applozic-Android-SDK by AppLozic.

the class NotificationIntentService method onHandleWork.

@Override
protected void onHandleWork(@NonNull Intent intent) {
    if (intent != null) {
        final String action = intent.getAction();
        if (ACTION_AL_NOTIFICATION.equals(action)) {
            String messageKey = intent.getStringExtra(MobiComKitConstants.AL_MESSAGE_KEY);
            Message message = messageDatabaseService.getMessage(messageKey);
            if (message != null) {
                int notificationId = Utils.getLauncherIcon(getApplicationContext());
                final NotificationService notificationService = new NotificationService(notificationId == 0 ? resourceArray[0] : notificationId, NotificationIntentService.this, resourceArray[1], resourceArray[2], resourceArray[3]);
                if (MobiComUserPreference.getInstance(NotificationIntentService.this).isLoggedIn()) {
                    Channel channel = ChannelService.getInstance(NotificationIntentService.this).getChannelInfo(message.getGroupId());
                    Contact contact = null;
                    if (message.getConversationId() != null) {
                        ConversationService.getInstance(NotificationIntentService.this).getConversation(message.getConversationId());
                    }
                    if (message.getGroupId() == null) {
                        contact = appContactService.getContactById(message.getContactIds());
                    }
                    if (ApplozicClient.getInstance(NotificationIntentService.this).isNotificationStacking()) {
                        notificationService.notifyUser(contact, channel, message);
                    } else {
                        notificationService.notifyUserForNormalMessage(contact, channel, message);
                    }
                }
            }
        }
    }
}
Also used : Message(com.applozic.mobicomkit.api.conversation.Message) Channel(com.applozic.mobicommons.people.channel.Channel) Contact(com.applozic.mobicommons.people.contact.Contact)

Example 43 with Channel

use of com.applozic.mobicommons.people.channel.Channel in project Applozic-Android-SDK by AppLozic.

the class UserIntentService method onHandleWork.

@Override
protected void onHandleWork(@NonNull Intent intent) {
    Integer unreadCount = intent.getIntExtra(UNREAD_COUNT, 0);
    boolean singleMessageRead = intent.getBooleanExtra(SINGLE_MESSAGE_READ, false);
    Contact contact = (Contact) intent.getSerializableExtra(CONTACT);
    Channel channel = (Channel) intent.getSerializableExtra(CHANNEL);
    if (unreadCount != 0 || singleMessageRead) {
        messageClientService.updateReadStatus(contact, channel);
    } else {
        String userId = intent.getStringExtra(USER_ID);
        if (!TextUtils.isEmpty(userId)) {
            SyncCallService.getInstance(UserIntentService.this).processUserStatus(userId);
        } else if (intent.getBooleanExtra(USER_LAST_SEEN_AT_STATUS, false)) {
            mobiComConversationService.processLastSeenAtStatus();
        }
    }
}
Also used : Channel(com.applozic.mobicommons.people.channel.Channel) Contact(com.applozic.mobicommons.people.contact.Contact)

Example 44 with Channel

use of com.applozic.mobicommons.people.channel.Channel in project Applozic-Android-SDK by AppLozic.

the class MobiComConversationFragment method updateTitleForOpenGroup.

public void updateTitleForOpenGroup() {
    try {
        if (channel != null) {
            Channel newChannel = ChannelService.getInstance(getActivity()).getChannelByChannelKey(channel.getKey());
            ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(newChannel.getName());
        }
        updateChannelSubTitle();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Channel(com.applozic.mobicommons.people.channel.Channel)

Example 45 with Channel

use of com.applozic.mobicommons.people.channel.Channel in project Applozic-Android-SDK by AppLozic.

the class MobiComConversationFragment method updateChannelTitle.

public void updateChannelTitle() {
    if (!Channel.GroupType.GROUPOFTWO.getValue().equals(channel.getType())) {
        Channel newChannel = ChannelService.getInstance(getActivity()).getChannelByChannelKey(channel.getKey());
        if (newChannel != null && !TextUtils.isEmpty(channel.getName()) && !channel.getName().equals(newChannel.getName())) {
            title = ChannelUtils.getChannelTitleName(newChannel, MobiComUserPreference.getInstance(getActivity()).getUserId());
            channel = newChannel;
            ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(title);
        }
    }
}
Also used : Channel(com.applozic.mobicommons.people.channel.Channel)

Aggregations

Channel (com.applozic.mobicommons.people.channel.Channel)70 Contact (com.applozic.mobicommons.people.contact.Contact)26 Intent (android.content.Intent)12 ChannelFeed (com.applozic.mobicomkit.feed.ChannelFeed)10 ArrayList (java.util.ArrayList)10 Message (com.applozic.mobicomkit.api.conversation.Message)8 MobiComUserPreference (com.applozic.mobicomkit.api.account.user.MobiComUserPreference)7 ApplozicException (com.applozic.mobicomkit.exception.ApplozicException)7 SyncChannelFeed (com.applozic.mobicomkit.sync.SyncChannelFeed)7 ChannelUserMapper (com.applozic.mobicommons.people.channel.ChannelUserMapper)7 NonNull (androidx.annotation.NonNull)6 FileClientService (com.applozic.mobicomkit.api.attachment.FileClientService)6 Context (android.content.Context)4 Cursor (android.database.Cursor)4 Bitmap (android.graphics.Bitmap)4 FileMeta (com.applozic.mobicomkit.api.attachment.FileMeta)4 ChannelFeedApiResponse (com.applozic.mobicomkit.feed.ChannelFeedApiResponse)4 ChannelUsersFeed (com.applozic.mobicomkit.feed.ChannelUsersFeed)4 Conversation (com.applozic.mobicommons.people.channel.Conversation)4 JSONException (org.json.JSONException)4