Source:
public void bind(@NonNull MessageThread thread) { mThread = thread; mDisposables.dispose(); mDisposables = new CompositeDisposable(); mRoot.setVisibility(View.GONE); int tf = thread.isUnread() ? Typeface.BOLD : Typeface.NORMAL; mLblParticipants.setTypeface(null, tf); mLblLastUpdated.setTypeface(null, tf); mLblSubject.setTypeface(null, tf); mLblSubject.setText(thread.subject); mLblLastUpdated.setText(DateUtils.getRelativeTimeSpanString( thread.lastUpdated.getTime(), new Date().getTime(), 0, DateUtils.FORMAT_NUMERIC_DATE | DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_ABBREV_RELATIVE) .toString()); @SuppressLint("UseSparseArrays") Map<Integer, Host> participants = new HashMap<>(); mDisposables.add(Observable.merge( mUserRepository.get(getParticipantIdsWithoutCurrentUser(thread), UserRepository.ShouldSaveInDb.YES)) .observeOn(AndroidSchedulers.mainThread()) .subscribe(userResource -> { Host user = userResource.data; if (user == null) { return; } participants.put(user.getId(), user); mIcon.setUsers(participants.values()); List<String> names = new ArrayList<>(participants.size()); for (Host participant : participants.values()) { names.add(TextUtils.isEmpty(participant.getFullname()) ? participant.getName() : participant.getFullname()); } mLblParticipants.setText(StringUtils.join(names, ", ")); mRoot.setVisibility(View.VISIBLE); })); if (!thread.messages.isEmpty()) { Message newestMessage = Collections.max(thread.messages, MessageListAdapter.COMPARATOR); mLblPreview.setText(Html.fromHtml(newestMessage.body)); if (newestMessage.status == Message.STATUS_OUTGOING) { mLblLastUpdated.setText("..."); } } mRoot.setOnClickListener(view -> mNavigationController.navigateToMessageThread(thread.id)); }

Target:
public void bind(@NonNull MessageThread thread) { mThread = thread; mDisposables.dispose(); mDisposables = new CompositeDisposable(); mRoot.setVisibility(View.GONE); int tf = thread.isUnread() ? Typeface.BOLD : Typeface.NORMAL; mLblParticipants.setTypeface(null, tf); mLblLastUpdated.setTypeface(null, tf); mLblSubject.setTypeface(null, tf); mLblSubject.setText(thread.subject); mLblLastUpdated.setText(DateUtils.getRelativeTimeSpanString( thread.lastUpdated.getTime(), new Date().getTime(), 0, DateUtils.FORMAT_NUMERIC_DATE | DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_ABBREV_RELATIVE).toString()); @SuppressLint("UseSparseArrays") Map<Integer, Host> participants = new HashMap<>(); mDisposables.add(Observable.merge( mUserRepository.get(getParticipantIdsWithoutCurrentUser(thread), UserRepository.ShouldSaveInDb.YES)) .observeOn(AndroidSchedulers.mainThread()) .subscribe(userResource -> { Host user = userResource.data; if (user == null) { return; } participants.put(user.getId(), user); mIcon.setUsers(participants.values()); List<String> names = new ArrayList<>(participants.size()); for (Host participant : participants.values()) { names.add(TextUtils.isEmpty(participant.getFullname()) ? participant.getName() : participant.getFullname()); } mLblParticipants.setText(TextUtils.join(", ", names)); mRoot.setVisibility(View.VISIBLE); })); if (!thread.messages.isEmpty()) { Message newestMessage = Collections.max(thread.messages, MessageListAdapter.COMPARATOR); mLblPreview.setText(Html.fromHtml(newestMessage.body)); if (newestMessage.status == Message.STATUS_OUTGOING) { mLblLastUpdated.setText("..."); } } mRoot.setOnClickListener( view -> mNavigationController.navigateToMessageThread(thread.id)); }