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