use of cx.ring.tv.model.TVContactRequestViewModel in project ring-client-android by savoirfairelinux.
the class MainPresenter method loadContactRequest.
public void loadContactRequest() {
mCompositeDisposable.add(Single.fromCallable(() -> {
List<TrustRequest> requests = mAccountService.getCurrentAccount().getRequests();
ArrayList<TVContactRequestViewModel> contactRequestViewModels = new ArrayList<>();
for (TrustRequest request : requests) {
byte[] photo;
if (request.getVCard().getPhotos().isEmpty()) {
photo = null;
} else {
photo = request.getVCard().getPhotos().get(0).getData();
}
TVContactRequestViewModel tvContactRequestVM = new TVContactRequestViewModel(request.getContactId(), request.getDisplayname(), request.getFullname(), photo, request.getMessage());
contactRequestViewModels.add(tvContactRequestVM);
}
return contactRequestViewModels;
}).subscribeOn(Schedulers.computation()).observeOn(mMainScheduler).subscribeWith(new ResourceSingleObserver<ArrayList<TVContactRequestViewModel>>() {
@Override
public void onSuccess(@NonNull ArrayList<TVContactRequestViewModel> contactRequestViewModels) {
mContactRequestViewModels = contactRequestViewModels;
if (mContactRequestViewModels.isEmpty()) {
getView().showContactRequestsRow(false);
} else {
getView().showContactRequestsRow(true);
getView().showContactRequests(mContactRequestViewModels);
}
}
@Override
public void onError(@NonNull Throwable e) {
Log.e(TAG, e.toString());
}
}));
}
use of cx.ring.tv.model.TVContactRequestViewModel in project ring-client-android by savoirfairelinux.
the class MainFragment method showContactRequests.
@Override
public void showContactRequests(final ArrayList<TVContactRequestViewModel> contactRequests) {
contactRequestRowAdapter.clear();
for (TVContactRequestViewModel contact : contactRequests) {
contactRequestRowAdapter.add(new ContactRequestCard(contact));
}
contactRequestRowAdapter.notifyArrayItemRangeChanged(0, contactRequests.size());
mRowsAdapter.notifyItemRangeChanged(2, 3);
}
use of cx.ring.tv.model.TVContactRequestViewModel in project ring-client-android by savoirfairelinux.
the class ContactRequestCardPresenter method onBindViewHolder.
@Override
public void onBindViewHolder(Card card, ImageCardView cardView) {
ContactRequestCard contact = (ContactRequestCard) card;
TVContactRequestViewModel model = contact.getModel();
if (model.getUserName().isEmpty() || model.getDisplayName().equals(model.getUserName())) {
cardView.setTitleText(model.getDisplayName());
cardView.setContentText("");
} else {
cardView.setTitleText(model.getUserName());
cardView.setContentText(model.getDisplayName());
}
cardView.setBackgroundColor(cardView.getResources().getColor(R.color.color_primary_dark));
cardView.setMainImage(getCardImage(contact));
}
use of cx.ring.tv.model.TVContactRequestViewModel in project ring-client-android by savoirfairelinux.
the class TVContactRequestDetailPresenter method onBindDescription.
@Override
protected void onBindDescription(ViewHolder viewHolder, Object item) {
TVContactRequestViewModel contactRequestViewModel = (TVContactRequestViewModel) item;
if (contactRequestViewModel != null) {
viewHolder.getTitle().setText(contactRequestViewModel.getUserName());
viewHolder.getSubtitle().setText(contactRequestViewModel.getDisplayName());
viewHolder.getBody().setText(contactRequestViewModel.getMessage());
}
}
Aggregations