use of cx.ring.model.CallContact 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.CallContact in project ring-client-android by savoirfairelinux.
the class ActionHelper method launchCopyNumberToClipboardFromContact.
public static void launchCopyNumberToClipboardFromContact(final Context context, final CallContact callContact, final Conversation.ConversationActionCallback callback) {
if (callContact == null) {
Log.d(TAG, "launchCopyNumberToClipboardFromContact: callContact is null");
return;
}
if (context == null) {
Log.d(TAG, "launchCopyNumberToClipboardFromContact: activity is null");
return;
}
if (callContact.getPhones().isEmpty()) {
Log.d(TAG, "launchCopyNumberToClipboardFromContact: no number to copy");
return;
}
if (callContact.getPhones().size() == 1 && callback != null) {
String number = callContact.getPhones().get(0).getNumber().toString();
callback.copyContactNumberToClipboard(number);
} else {
final NumberAdapter adapter = new NumberAdapter(context, callContact, true);
AlertDialog alertDialog = new AlertDialog.Builder(context).setTitle(R.string.conversation_action_select_peer_number).setAdapter(adapter, (dialog, which) -> {
if (callback != null) {
Phone selectedPhone = (Phone) adapter.getItem(which);
callback.copyContactNumberToClipboard(selectedPhone.getNumber().toString());
}
}).create();
final int listViewSidePadding = (int) context.getResources().getDimension(R.dimen.alert_dialog_side_padding_list_view);
alertDialog.getListView().setPadding(listViewSidePadding, 0, listViewSidePadding, 0);
alertDialog.show();
}
}
use of cx.ring.model.CallContact in project ring-client-android by savoirfairelinux.
the class ConversationFacade method parseHistoryCalls.
private void parseHistoryCalls(List<HistoryCall> historyCalls, boolean acceptAllMessages) {
for (HistoryCall call : historyCalls) {
CallContact contact = mContactService.findContact(call.getContactID(), call.getContactKey(), new Uri(call.getNumber()));
String key = contact.getIds().get(0);
String phone = contact.getPhones().get(0).getNumber().getRawUriString();
if (mConversationMap.containsKey(key) || mConversationMap.containsKey(phone)) {
mConversationMap.get(key).addHistoryCall(call);
} else if (acceptAllMessages) {
Conversation conversation = new Conversation(contact);
conversation.addHistoryCall(call);
mConversationMap.put(key, conversation);
}
}
}
Aggregations