[android] small improvements for contact list

parent 144ea0c2
Pipeline #3077 passed with stage
in 8 minutes and 55 seconds
......@@ -38,7 +38,7 @@ public abstract class BaseContactListAdapter<I extends ContactItem, VH extends C
@Override
public boolean areItemsTheSame(I c1, I c2) {
return c1.getContact().getId().equals(c2.getContact().getId());
return c1.getContact().equals(c2.getContact());
}
@Override
......@@ -47,8 +47,7 @@ public abstract class BaseContactListAdapter<I extends ContactItem, VH extends C
}
int findItemPosition(ContactId c) {
int count = getItemCount();
for (int i = 0; i < count; i++) {
for (int i = 0; i < getItemCount(); i++) {
I item = getItemAt(i);
if (item != null && item.getContact().getId().equals(c))
return i;
......
......@@ -5,8 +5,10 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import org.briarproject.briar.R;
@NotNullByDefault
public class ContactListAdapter extends
BaseContactListAdapter<ContactListItem, ContactListItemViewHolder> {
......@@ -28,6 +30,9 @@ public class ContactListAdapter extends
public boolean areContentsTheSame(ContactListItem c1, ContactListItem c2) {
// check for all properties that influence visual
// representation of contact
if (c1.isEmpty() != c2.isEmpty()) {
return false;
}
if (c1.getUnreadCount() != c2.getUnreadCount()) {
return false;
}
......@@ -39,11 +44,7 @@ public class ContactListAdapter extends
@Override
public int compare(ContactListItem c1, ContactListItem c2) {
long time1 = c1.getTimestamp();
long time2 = c2.getTimestamp();
if (time1 < time2) return 1;
if (time1 > time2) return -1;
return 0;
return Long.compare(c2.getTimestamp(), c1.getTimestamp());
}
}
......@@ -281,7 +281,7 @@ public class ContactListFragment extends BaseFragment implements EventListener {
ContactListItem item = adapter.getItemAt(position);
if (item != null) {
item.setConnected(connected);
adapter.notifyItemChanged(position);
adapter.updateItemAt(position, item);
}
});
}
......
Markdown is supported
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