use of com.applozic.mobicommons.people.contact.Contact in project Applozic-Android-SDK by AppLozic.
the class MobiComConversationFragment method sendMessage.
protected void sendMessage() {
if (channel != null) {
if (Channel.GroupType.GROUPOFTWO.getValue().equals(channel.getType())) {
String userId = ChannelService.getInstance(getActivity()).getGroupOfTwoReceiverUserId(channel.getKey());
if (!TextUtils.isEmpty(userId)) {
Contact withUserContact = appContactService.getContactById(userId);
if (withUserContact.isBlocked()) {
userBlockDialog(false, withUserContact, true);
} else {
handleSendAndRecordButtonView(false);
processSendMessage();
}
}
} else if (Channel.GroupType.OPEN.getValue().equals(channel.getType())) {
if (Utils.isInternetAvailable(getActivity())) {
handleSendAndRecordButtonView(false);
processSendMessage();
} else {
Toast.makeText(ApplozicService.getContext(getContext()), ApplozicService.getContext(getContext()).getString(R.string.internet_connection_not_available), Toast.LENGTH_SHORT).show();
}
} else {
handleSendAndRecordButtonView(false);
processSendMessage();
}
} else if (contact != null) {
if (contact.isBlocked()) {
userBlockDialog(false, contact, false);
} else {
handleSendAndRecordButtonView(false);
processSendMessage();
}
}
}
use of com.applozic.mobicommons.people.contact.Contact in project Applozic-Android-SDK by AppLozic.
the class AlTypingIndicator method createView.
/**
* This method is always called whenever the typing status change is received from the subscribed userId or Group
* Be careful to instantiate your views here.
*/
public void createView() {
Contact contact = new AppContactService(getContext()).getContactById(typerUserId);
removeAllViews();
if (typingText == null) {
typingText = new TextView(getContext());
LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
typingText.setLayoutParams(params);
typingText.setTextSize(14);
typingText.setTextColor(getContext().getResources().getColor(R.color.apploizc_black_color));
}
addView(typingText);
if (isTyping) {
typingText.setText((contact != null ? contact.getDisplayName() : "") + " is Typing...");
} else {
typingText.setText((contact != null ? contact.getDisplayName() : "") + " is not Typing...");
}
}
use of com.applozic.mobicommons.people.contact.Contact in project Applozic-Android-SDK by AppLozic.
the class UserService method processSyncUserBlock.
/**
* Internal. Do not use.
*
* This method handle block user syncing. Calling this method is done internally by the SDK.
*/
public synchronized void processSyncUserBlock() {
try {
SyncBlockUserApiResponse apiResponse = userClientService.getSyncUserBlockList(userPreference.getUserBlockSyncTime());
if (apiResponse != null && SyncBlockUserApiResponse.SUCCESS.equals(apiResponse.getStatus())) {
SyncUserBlockListFeed syncUserBlockListFeed = apiResponse.getResponse();
if (syncUserBlockListFeed != null) {
List<SyncUserBlockFeed> blockedToUserList = syncUserBlockListFeed.getBlockedToUserList();
List<SyncUserBlockFeed> blockedByUserList = syncUserBlockListFeed.getBlockedByUserList();
if (blockedToUserList != null && blockedToUserList.size() > 0) {
for (SyncUserBlockFeed syncUserBlockedFeed : blockedToUserList) {
Contact contact = new Contact();
if (syncUserBlockedFeed.getUserBlocked() != null && !TextUtils.isEmpty(syncUserBlockedFeed.getBlockedTo())) {
if (baseContactService.isContactExists(syncUserBlockedFeed.getBlockedTo())) {
baseContactService.updateUserBlocked(syncUserBlockedFeed.getBlockedTo(), syncUserBlockedFeed.getUserBlocked());
} else {
contact.setBlocked(syncUserBlockedFeed.getUserBlocked());
contact.setUserId(syncUserBlockedFeed.getBlockedTo());
baseContactService.upsert(contact);
baseContactService.updateUserBlocked(syncUserBlockedFeed.getBlockedTo(), syncUserBlockedFeed.getUserBlocked());
}
}
}
}
if (blockedByUserList != null && blockedByUserList.size() > 0) {
for (SyncUserBlockFeed syncUserBlockByFeed : blockedByUserList) {
Contact contact = new Contact();
if (syncUserBlockByFeed.getUserBlocked() != null && !TextUtils.isEmpty(syncUserBlockByFeed.getBlockedBy())) {
if (baseContactService.isContactExists(syncUserBlockByFeed.getBlockedBy())) {
baseContactService.updateUserBlockedBy(syncUserBlockByFeed.getBlockedBy(), syncUserBlockByFeed.getUserBlocked());
} else {
contact.setBlockedBy(syncUserBlockByFeed.getUserBlocked());
contact.setUserId(syncUserBlockByFeed.getBlockedBy());
baseContactService.upsert(contact);
baseContactService.updateUserBlockedBy(syncUserBlockByFeed.getBlockedBy(), syncUserBlockByFeed.getUserBlocked());
}
}
}
}
}
userPreference.setUserBlockSyncTime(apiResponse.getGeneratedAt());
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.applozic.mobicommons.people.contact.Contact in project Applozic-Android-SDK by AppLozic.
the class UserService method getOnlineUsers.
/**
* Retrieves a list of the current online users from the server. They are also saved locally.
*
* <p>This methods updates the local database for these retrieved users by calling {@link UserService#processUserDetail(Set)}.</p>
*
* <p>Note: This method has database and network operation. Run it asynchronously.</p>
*
* @param numberOfUser the number of users to return
* @return array of userIds of the online users
*/
@Nullable
public synchronized String[] getOnlineUsers(int numberOfUser) {
try {
Map<String, String> userMapList = userClientService.getOnlineUserList(numberOfUser);
if (userMapList != null && userMapList.size() > 0) {
String[] userIdArray = new String[userMapList.size()];
Set<String> userIds = new HashSet<String>();
int i = 0;
for (Map.Entry<String, String> keyValue : userMapList.entrySet()) {
Contact contact = new Contact();
contact.setUserId(keyValue.getKey());
contact.setConnected(keyValue.getValue().contains("true"));
userIdArray[i] = keyValue.getKey();
userIds.add(keyValue.getKey());
baseContactService.upsert(contact);
i++;
}
processUserDetails(userIds);
return userIdArray;
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of com.applozic.mobicommons.people.contact.Contact in project Applozic-Android-SDK by AppLozic.
the class UserService method processUser.
// Cleanup: private or rename
/**
* Internal. Do not use.
*
* This method inserts/updates the user(user detail) in the local database.
*
* <p>Note: This method has database and network operation. Run it asynchronously.</p>
*
* @param userDetail the user detail to save
* @param contactType the contact type of the user
*/
public synchronized void processUser(UserDetail userDetail, Contact.ContactType contactType) {
Contact contact = new Contact();
contact.setUserId(userDetail.getUserId());
contact.setContactNumber(userDetail.getPhoneNumber());
contact.setConnected(userDetail.isConnected());
contact.setStatus(userDetail.getStatusMessage());
if (!TextUtils.isEmpty(userDetail.getDisplayName())) {
contact.setFullName(userDetail.getDisplayName());
}
contact.setLastSeenAt(userDetail.getLastSeenAtTime());
contact.setUserTypeId(userDetail.getUserTypeId());
contact.setUnreadCount(0);
contact.setLastMessageAtTime(userDetail.getLastMessageAtTime());
contact.setMetadata(userDetail.getMetadata());
contact.setRoleType(userDetail.getRoleType());
contact.setDeletedAtTime(userDetail.getDeletedAtTime());
contact.setEmailId(userDetail.getEmailId());
if (!TextUtils.isEmpty(userDetail.getImageLink())) {
contact.setImageURL(userDetail.getImageLink());
}
contact.setContactType(contactType.getValue());
baseContactService.upsert(contact);
}
Aggregations