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;
}
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);
}
}
}
}
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;
}
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;
}
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;
}
Aggregations