public void setConnectionType (ConnectionType type) { this.type = type.ordinal(); }
public ConnectionType getConnectionType () { return ConnectionType.values()[this.type]; }
public List<User> getContacts(ConnectionType type) { List<User> contactList = new ArrayList<>(); // For some reason the default ContactLinks do not persist, have to find in DB List<ContactLink> contactLinks = DaoCore.fetchEntitiesWithProperty(ContactLink.class, ContactLinkDao.Properties.LinkOwnerUserDaoId, this.getId()); for (ContactLink contactLink : contactLinks){ if(contactLink.getConnectionType().equals(type)) { User user = contactLink.getUser(); if(user != null && StringUtils.isNotEmpty(user.getName())) { contactList.add(contactLink.getUser()); } } } return contactList; }
public void deleteContact (User user, ConnectionType type) { Property [] properties = { ContactLinkDao.Properties.LinkOwnerUserDaoId, ContactLinkDao.Properties.UserId, ContactLinkDao.Properties.Type }; List<ContactLink> contactLinks = DaoCore.fetchEntitiesWithProperties(ContactLink.class, properties, this.getId(), user.getId(), type.ordinal()); for(ContactLink link : contactLinks) { DaoCore.deleteEntity(link); } daoSession.update(this); }
Object type = ((HashMap) value).get(Keys.Type); if (type instanceof Long) { ConnectionType connectionType = ConnectionType.values()[((Long) type).intValue()]; ChatSDK.contact().addContactLocal(contact, connectionType); eventSource.onNext(NetworkEvent.contactAdded(contact)); Object type = ((HashMap) value).get(Keys.Type); if (type instanceof Long) { ConnectionType connectionType = ConnectionType.values()[((Long) type).intValue()]; ChatSDK.contact().deleteContactLocal(contact, connectionType); eventSource.onNext(NetworkEvent.contactDeleted(contact));
@Override public Completable addContact(User user, ConnectionType type) { return Completable.create(emitter -> { DatabaseReference ref = FirebasePaths.userContactsRef(ChatSDK.currentUser().getEntityID()).child(user.getEntityID()); HashMap<String, Integer> data = new HashMap<>(); data.put(Keys.Type, type.ordinal()); ref.setValue(data, (databaseError, databaseReference) -> { if (databaseError == null) { emitter.onComplete(); } else { emitter.onError(databaseError.toException()); } }); }); }