Commit 79f1ac47 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

smartlist: fix crash when searching

Change-Id: Id83ff61029299d77d9661f935f3c1d4d41980700
parent 1b7571c3
...@@ -38,6 +38,7 @@ import cx.ring.databinding.ItemSmartlistBinding; ...@@ -38,6 +38,7 @@ import cx.ring.databinding.ItemSmartlistBinding;
import cx.ring.databinding.ItemSmartlistHeaderBinding; import cx.ring.databinding.ItemSmartlistHeaderBinding;
import cx.ring.utils.ResourceMapper; import cx.ring.utils.ResourceMapper;
import cx.ring.views.AvatarDrawable; import cx.ring.views.AvatarDrawable;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.disposables.CompositeDisposable; import io.reactivex.rxjava3.disposables.CompositeDisposable;
public class SmartListViewHolder extends RecyclerView.ViewHolder { public class SmartListViewHolder extends RecyclerView.ViewHolder {
...@@ -65,10 +66,10 @@ public class SmartListViewHolder extends RecyclerView.ViewHolder { ...@@ -65,10 +66,10 @@ public class SmartListViewHolder extends RecyclerView.ViewHolder {
if (binding != null) { if (binding != null) {
itemView.setOnClickListener(v -> clickListener.onItemClick(smartListViewModel)); itemView.setOnClickListener(v -> clickListener.onItemClick(smartListViewModel));
compositeDisposable.add(smartListViewModel.getSelected().subscribe(selected -> { Observable<Boolean> selected = smartListViewModel.getSelected();
Log.w("SmartListViewHolder", "selected " + selected + " " + smartListViewModel.getContactName()); if (selected != null) {
binding.itemLayout.setActivated(selected); compositeDisposable.add(smartListViewModel.getSelected().subscribe(binding.itemLayout::setActivated));
})); }
itemView.setOnLongClickListener(v -> { itemView.setOnLongClickListener(v -> {
clickListener.onItemLongClick(smartListViewModel); clickListener.onItemLongClick(smartListViewModel);
return true; return true;
......
...@@ -344,8 +344,13 @@ public class Conversation extends ConversationHistory { ...@@ -344,8 +344,13 @@ public class Conversation extends ConversationHistory {
if (interaction.getContact() == null) { if (interaction.getContact() == null) {
if (mContacts.size() == 1) if (mContacts.size() == 1)
interaction.setContact(mContacts.get(0)); interaction.setContact(mContacts.get(0));
else else {
interaction.setContact(findContact(Uri.fromString(interaction.getAuthor()))); if (interaction.getAuthor() == null) {
Log.e(TAG, "Can't set interaction properties: no author for type:" + interaction.getType() + " id:" + interaction.getId() + " status:" + interaction.mStatus);
} else {
interaction.setContact(findContact(Uri.fromString(interaction.getAuthor())));
}
}
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment