Search in sources :

Example 61 with Channel

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

the class ChannelDatabaseService method prepareChannelValues.

// Cleanup: private
public ContentValues prepareChannelValues(Channel channel) {
    ContentValues contentValues = new ContentValues();
    contentValues.put(MobiComDatabaseHelper.CHANNEL_DISPLAY_NAME, channel.getName());
    contentValues.put(MobiComDatabaseHelper.CHANNEL_KEY, channel.getKey());
    contentValues.put(MobiComDatabaseHelper.CLIENT_GROUP_ID, channel.getClientGroupId());
    contentValues.put(MobiComDatabaseHelper.TYPE, channel.getType());
    contentValues.put(MobiComDatabaseHelper.NOTIFICATION_AFTER_TIME, channel.getNotificationAfterTime());
    contentValues.put(MobiComDatabaseHelper.DELETED_AT, channel.getDeletedAtTime());
    contentValues.put(MobiComDatabaseHelper.ADMIN_ID, channel.getAdminKey());
    Channel oldChannel = null;
    contentValues.put(MobiComDatabaseHelper.CHANNEL_IMAGE_URL, channel.getImageUrl());
    oldChannel = ChannelDatabaseService.getInstance(context).getChannelByChannelKey(channel.getKey());
    if (channel.getKmStatus() != 0) {
        contentValues.put(MobiComDatabaseHelper.CONVERSATION_STATUS, channel.getKmStatus());
    }
    if (oldChannel != null && !TextUtils.isEmpty(oldChannel.getImageUrl()) && !channel.getImageUrl().equals(oldChannel.getImageUrl())) {
        updateChannelLocalImageURI(channel.getKey(), null);
    }
    if (!TextUtils.isEmpty(channel.getLocalImageUri())) {
        contentValues.put(MobiComDatabaseHelper.CHANNEL_IMAGE_LOCAL_URI, channel.getLocalImageUri());
    }
    if (channel.getUserCount() != 0) {
        contentValues.put(MobiComDatabaseHelper.USER_COUNT, channel.getUserCount());
    }
    if (channel.getUnreadCount() != 0) {
        contentValues.put(MobiComDatabaseHelper.UNREAD_COUNT, channel.getUnreadCount());
    }
    if (channel.getMetadata() != null) {
        contentValues.put(MobiComDatabaseHelper.CHANNEL_META_DATA, GsonUtils.getJsonFromObject(channel.getMetadata(), Map.class));
        if (channel.getMetadata().containsKey(Channel.AL_CATEGORY)) {
            contentValues.put(MobiComDatabaseHelper.AL_CATEGORY, channel.getMetadata().get(Channel.AL_CATEGORY));
        }
    }
    contentValues.put(MobiComDatabaseHelper.PARENT_GROUP_KEY, channel.getParentKey());
    contentValues.put(MobiComDatabaseHelper.PARENT_CLIENT_GROUP_ID, channel.getParentClientGroupId());
    return contentValues;
}
Also used : ContentValues(android.content.ContentValues) Channel(com.applozic.mobicommons.people.channel.Channel) HashMap(java.util.HashMap) Map(java.util.Map)

Example 62 with Channel

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

the class BroadcastService method sendNotificationBroadcast.

public static void sendNotificationBroadcast(Context context, Message message, int index) {
    if (message != null) {
        if (ALSpecificSettings.getInstance(context).isAllNotificationMuted() || message.getMetadata() != null && message.getMetadata().containsKey("NO_ALERT") && "true".equals(message.getMetadata().get("NO_ALERT"))) {
            return;
        }
        int notificationId = Utils.getLauncherIcon(context.getApplicationContext());
        final NotificationService notificationService = new NotificationService(notificationId, context, 0, 0, 0);
        if (MobiComUserPreference.getInstance(context).isLoggedIn()) {
            Channel channel = ChannelService.getInstance(context).getChannelInfo(message.getGroupId());
            Contact contact = null;
            if (message.getConversationId() != null) {
                ConversationService.getInstance(context).getConversation(message.getConversationId());
            }
            if (message.getGroupId() == null) {
                contact = new AppContactService(context).getContactById(message.getContactIds());
            }
            if (ApplozicClient.getInstance(context).isNotificationStacking()) {
                notificationService.notifyUser(contact, channel, message, index);
            } else {
                notificationService.notifyUserForNormalMessage(contact, channel, message, index);
            }
        }
    }
}
Also used : AppContactService(com.applozic.mobicomkit.contact.AppContactService) Channel(com.applozic.mobicommons.people.channel.Channel) NotificationService(com.applozic.mobicomkit.api.notification.NotificationService) Contact(com.applozic.mobicommons.people.contact.Contact)

Example 63 with Channel

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

the class ChannelService method getAllChannelList.

/**
 * Gets a updated list of all channels for the user.
 */
@Nullable
public List<Channel> getAllChannelList() {
    List<Channel> channelList = null;
    SyncChannelFeed syncChannelFeed = channelClientService.getChannelFeed(MobiComUserPreference.getInstance(context).getChannelListLastGeneratedAtTime());
    if (syncChannelFeed == null || !syncChannelFeed.isSuccess()) {
        return null;
    }
    List<ChannelFeed> channelFeeds = syncChannelFeed.getResponse();
    if (channelFeeds != null && !channelFeeds.isEmpty()) {
        processChannelFeedList(channelFeeds.toArray(new ChannelFeed[channelFeeds.size()]), false);
    }
    MobiComUserPreference.getInstance(context).setChannelListLastGeneratedAtTime(syncChannelFeed.getGeneratedAt());
    channelList = ChannelDatabaseService.getInstance(context).getAllChannels();
    if (channelList == null) {
        return new ArrayList<>();
    }
    return channelList;
}
Also used : Channel(com.applozic.mobicommons.people.channel.Channel) SyncChannelFeed(com.applozic.mobicomkit.sync.SyncChannelFeed) ArrayList(java.util.ArrayList) ChannelFeed(com.applozic.mobicomkit.feed.ChannelFeed) SyncChannelFeed(com.applozic.mobicomkit.sync.SyncChannelFeed) Nullable(androidx.annotation.Nullable)

Example 64 with Channel

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

the class ChannelService method getChannel.

/**
 * Utility method. Creates a {@link Channel} object from the given {@link ChannelFeed}.
 */
@NonNull
public Channel getChannel(@NonNull ChannelFeed channelFeed) {
    Channel channel = new Channel(channelFeed.getId(), channelFeed.getName(), channelFeed.getAdminName(), channelFeed.getType(), channelFeed.getUnreadCount(), channelFeed.getImageUrl());
    channel.setClientGroupId(channelFeed.getClientGroupId());
    channel.setNotificationAfterTime(channelFeed.getNotificationAfterTime());
    channel.setDeletedAtTime(channelFeed.getDeletedAtTime());
    channel.setMetadata(channelFeed.getMetadata());
    channel.setParentKey(channelFeed.getParentKey());
    channel.setParentClientGroupId(channelFeed.getParentClientGroupId());
    channel.setKmStatus(channel.generateKmStatus(loggedInUserId));
    return channel;
}
Also used : Channel(com.applozic.mobicommons.people.channel.Channel) NonNull(androidx.annotation.NonNull)

Example 65 with Channel

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

the class ChannelService method createGroupOfTwo.

/**
 * @deprecated Use {@link #createGroupOfTwoWithResponse(ChannelInfo)} instead.
 */
@Deprecated
public Channel createGroupOfTwo(ChannelInfo channelInfo) {
    if (channelInfo == null) {
        return null;
    }
    if (!TextUtils.isEmpty(channelInfo.getClientGroupId())) {
        Channel channel = channelDatabaseService.getChannelByClientGroupId(channelInfo.getClientGroupId());
        if (channel != null) {
            return channel;
        } else {
            ChannelFeedApiResponse channelFeedApiResponse = channelClientService.createChannelWithResponse(channelInfo);
            if (channelFeedApiResponse == null) {
                return null;
            }
            if (channelFeedApiResponse.isSuccess()) {
                ChannelFeed channelFeed = channelFeedApiResponse.getResponse();
                if (channelFeed != null) {
                    ChannelFeed[] channelFeeds = new ChannelFeed[1];
                    channelFeeds[0] = channelFeed;
                    processChannelFeedList(channelFeeds, true);
                    return getChannel(channelFeed);
                }
            } else {
                ChannelFeed channelFeed = channelClientService.getChannelInfo(channelInfo.getClientGroupId());
                if (channelFeed != null) {
                    ChannelFeed[] channelFeeds = new ChannelFeed[1];
                    channelFeeds[0] = channelFeed;
                    processChannelFeedList(channelFeeds, false);
                    return getChannel(channelFeed);
                }
            }
        }
    }
    return null;
}
Also used : Channel(com.applozic.mobicommons.people.channel.Channel) ChannelFeed(com.applozic.mobicomkit.feed.ChannelFeed) SyncChannelFeed(com.applozic.mobicomkit.sync.SyncChannelFeed) ChannelFeedApiResponse(com.applozic.mobicomkit.feed.ChannelFeedApiResponse)

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