use of cx.ring.model.Account in project ring-client-android by savoirfairelinux.
the class ContactRequestsPresenter method updateList.
public void updateList(boolean clear) {
if (getView() == null) {
return;
}
Log.d(TAG, "updateList");
Account currentAccount = ((mAccountID == null) ? mAccountService.getCurrentAccount() : mAccountService.getAccount(mAccountID));
if (currentAccount == null) {
return;
}
boolean hasPane = !currentAccount.equals(mAccountService.getCurrentAccount());
if (clear) {
mTrustRequests.clear();
mTrustRequests.addAll(currentAccount.getRequests());
}
if (mContactRequestsViewModels == null) {
mContactRequestsViewModels = new ArrayList<>();
} else {
mContactRequestsViewModels.clear();
}
for (TrustRequest request : mTrustRequests) {
mContactRequestsViewModels.add(new PendingContactRequestsViewModel(currentAccount, request, hasPane));
}
getView().updateView(mContactRequestsViewModels);
mNotificationService.cancelTrustRequestNotification(currentAccount.getAccountID());
}
use of cx.ring.model.Account in project ring-client-android by savoirfairelinux.
the class TVProfileEditingFragment method showViewModel.
@Override
public void showViewModel(RingNavigationViewModel viewModel) {
// displays account available info
VCard vcard = viewModel.getVcard(getActivity().getFilesDir());
Account account = viewModel.getAccount();
if (account == null) {
Log.e(TAG, "Not able to get current account");
return;
}
if (!this.actions.isEmpty() && this.actions.get(0).getId() == USER_NAME) {
this.actions.get(0).setEditDescription(account.getAlias());
}
if (vcard == null || vcard.getPhotos().isEmpty()) {
getGuidanceStylist().getIconView().setImageDrawable(getActivity().getResources().getDrawable(R.drawable.ic_contact_picture_fallback));
return;
}
Drawable contactPicture = AvatarFactory.getAvatar(getActivity(), vcard.getPhotos().get(0).getData(), account.getDisplayUsername(), account.getUri());
Glide.with(getActivity()).load(contactPicture).apply(AvatarFactory.getGlideOptions(true, false)).transition(DrawableTransitionOptions.withCrossFade()).into(getGuidanceStylist().getIconView());
}
use of cx.ring.model.Account in project ring-client-android by savoirfairelinux.
the class MainPresenter method reloadConversations.
public void reloadConversations() {
getView().showLoading(true);
Account currentAccount = mAccountService.getCurrentAccount();
if (currentAccount == null) {
Log.e(TAG, "reloadConversations: Not able to get currentAccount");
return;
}
final Collection<CallContact> contacts = currentAccount.getContacts().values();
// Get all non-ban contact and then get last message and last call to create a smartList entry
mCompositeDisposable.add(io.reactivex.Observable.fromIterable(contacts).filter(callContact -> !callContact.isBanned()).map(this::modelToViewModel).toSortedList().subscribeOn(Schedulers.computation()).observeOn(mMainScheduler).subscribeWith(new DisposableSingleObserver<List<TVListViewModel>>() {
@Override
public void onSuccess(List<TVListViewModel> tvListViewModels) {
MainPresenter.this.mTvListViewModels = tvListViewModels;
getView().showContacts(tvListViewModels);
getView().showLoading(false);
subscribePresence();
}
@Override
public void onError(Throwable throwable) {
Log.e(TAG, throwable.toString());
getView().showLoading(false);
}
}));
}
use of cx.ring.model.Account in project ring-client-android by savoirfairelinux.
the class ConversationFacade method startConversation.
/**
* @return the started new conversation
*/
public Conversation startConversation(CallContact contact) {
Conversation conversation = getConversationByContact(contact);
if (conversation == null) {
conversation = new Conversation(contact);
mConversationMap.put(contact.getIds().get(0), conversation);
Account account = mAccountService.getCurrentAccount();
if (account != null && account.isRing()) {
Uri number = contact.getPhones().get(0).getNumber();
if (number.isRingId()) {
mAccountService.lookupAddress(account.getAccountID(), "", number.getRawRingId());
}
}
setChanged();
ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.CONVERSATIONS_CHANGED);
notifyObservers(event);
updateTextNotifications();
}
return conversation;
}
Aggregations