Search in sources :

Example 1 with ChannelUsersFeed

use of com.applozic.mobicomkit.feed.ChannelUsersFeed in project Applozic-Android-SDK by AppLozic.

the class ChannelInfoActivity method onContextItemSelected.

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    int position = info.position;
    if (channelUserMapperList.size() <= position) {
        return true;
    }
    if (channel == null) {
        return true;
    }
    ChannelUserMapper channelUserMapper = channelUserMapperList.get(position);
    switch(item.getItemId()) {
        case 0:
            Intent startConversationIntent = new Intent(ChannelInfoActivity.this, ConversationActivity.class);
            startConversationIntent.putExtra(ConversationUIService.USER_ID, channelUserMapper.getUserKey());
            startActivity(startConversationIntent);
            finish();
            break;
        case 1:
            removeChannelUser(channel, channelUserMapper);
            break;
        case 2:
            if (Utils.isInternetAvailable(getApplicationContext())) {
                GroupInfoUpdate groupInfoUpdate = new GroupInfoUpdate(channelUserMapper.getKey());
                List<ChannelUsersFeed> channelUsersFeedList = new ArrayList<>();
                ChannelUsersFeed channelUsersFeed = new ChannelUsersFeed();
                channelUsersFeed.setUserId(channelUserMapper.getUserKey());
                channelUsersFeed.setRole(1);
                channelUsersFeedList.add(channelUsersFeed);
                groupInfoUpdate.setUsers(channelUsersFeedList);
                new ChannelUserRoleAsyncTask(channelUserMapper, groupInfoUpdate, this).execute();
            } else {
                Toast toast = Toast.makeText(this, getString(R.string.you_dont_have_any_network_access_info), Toast.LENGTH_SHORT);
                toast.setGravity(Gravity.CENTER, 0, 0);
                toast.show();
            }
            break;
        default:
            return super.onContextItemSelected(item);
    }
    return true;
}
Also used : GroupInfoUpdate(com.applozic.mobicomkit.feed.GroupInfoUpdate) Toast(android.widget.Toast) ChannelUsersFeed(com.applozic.mobicomkit.feed.ChannelUsersFeed) ArrayList(java.util.ArrayList) AdapterView(android.widget.AdapterView) Intent(android.content.Intent) ChannelUserMapper(com.applozic.mobicommons.people.channel.ChannelUserMapper)

Example 2 with ChannelUsersFeed

use of com.applozic.mobicomkit.feed.ChannelUsersFeed in project Applozic-Android-SDK by AppLozic.

the class ChannelService method processChannelList.

public synchronized void processChannelList(List<ChannelFeed> channelFeedList) {
    if (channelFeedList != null && channelFeedList.size() > 0) {
        for (ChannelFeed channelFeed : channelFeedList) {
            Set<String> memberUserIds = channelFeed.getMembersName();
            Set<String> userIds = new HashSet<>();
            Channel channel = getChannel(channelFeed);
            if (channelDatabaseService.isChannelPresent(channel.getKey())) {
                channelDatabaseService.updateChannel(channel);
                channelDatabaseService.deleteChannelUserMappers(channel.getKey());
            } else {
                channelDatabaseService.addChannel(channel);
            }
            if (memberUserIds != null && memberUserIds.size() > 0) {
                for (String userId : memberUserIds) {
                    ChannelUserMapper channelUserMapper = new ChannelUserMapper(channelFeed.getId(), userId);
                    channelDatabaseService.addChannelUserMapper(channelUserMapper);
                    if (!baseContactService.isContactExists(userId)) {
                        userIds.add(userId);
                    }
                }
                if (userIds != null && userIds.size() > 0) {
                    userService.processUserDetailsByUserIds(userIds);
                }
            }
            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());
                    }
                }
            }
        }
    }
}
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 3 with ChannelUsersFeed

use of com.applozic.mobicomkit.feed.ChannelUsersFeed 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)

Aggregations

ChannelUsersFeed (com.applozic.mobicomkit.feed.ChannelUsersFeed)3 ChannelUserMapper (com.applozic.mobicommons.people.channel.ChannelUserMapper)3 ChannelFeed (com.applozic.mobicomkit.feed.ChannelFeed)2 SyncChannelFeed (com.applozic.mobicomkit.sync.SyncChannelFeed)2 Channel (com.applozic.mobicommons.people.channel.Channel)2 HashSet (java.util.HashSet)2 Intent (android.content.Intent)1 AdapterView (android.widget.AdapterView)1 Toast (android.widget.Toast)1 GroupInfoUpdate (com.applozic.mobicomkit.feed.GroupInfoUpdate)1 ArrayList (java.util.ArrayList)1