mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 03:39:05 +01:00
Prettier display of available forums, cleaned up list comparators.
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
package org.briarproject.android.contact;
|
||||
|
||||
import org.briarproject.api.Contact;
|
||||
|
||||
public class ContactItem {
|
||||
|
||||
public static final ContactItem NEW = new ContactItem(null);
|
||||
|
||||
private final Contact contact;
|
||||
|
||||
public ContactItem(Contact contact) {
|
||||
this.contact = contact;
|
||||
}
|
||||
|
||||
public Contact getContact() {
|
||||
return contact;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package org.briarproject.android.contact;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
public class ContactItemComparator implements Comparator<ContactItem> {
|
||||
|
||||
public static final ContactItemComparator INSTANCE =
|
||||
new ContactItemComparator();
|
||||
|
||||
public int compare(ContactItem a, ContactItem b) {
|
||||
if(a == b) return 0;
|
||||
if(a == ContactItem.NEW) return 1;
|
||||
if(b == ContactItem.NEW) return -1;
|
||||
String aName = a.getContact().getAuthor().getName();
|
||||
String bName = b.getContact().getAuthor().getName();
|
||||
return String.CASE_INSENSITIVE_ORDER.compare(aName, bName);
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,6 @@ import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP_1;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Logger;
|
||||
@@ -178,7 +177,7 @@ ConnectionListener {
|
||||
// Add a new item
|
||||
adapter.add(new ContactListItem(c, connected, lastConnected,
|
||||
inbox, headers));
|
||||
adapter.sort(ItemComparator.INSTANCE);
|
||||
adapter.sort(ContactListItemComparator.INSTANCE);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
@@ -318,15 +317,4 @@ ConnectionListener {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static class ItemComparator implements Comparator<ContactListItem> {
|
||||
|
||||
private static final ItemComparator INSTANCE = new ItemComparator();
|
||||
|
||||
public int compare(ContactListItem a, ContactListItem b) {
|
||||
String aName = a.getContact().getAuthor().getName();
|
||||
String bName = b.getContact().getAuthor().getName();
|
||||
return String.CASE_INSENSITIVE_ORDER.compare(aName, bName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.briarproject.android.contact;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
class ContactListItemComparator implements Comparator<ContactListItem> {
|
||||
|
||||
static final ContactListItemComparator INSTANCE =
|
||||
new ContactListItemComparator();
|
||||
|
||||
public int compare(ContactListItem a, ContactListItem b) {
|
||||
String aName = a.getContact().getAuthor().getName();
|
||||
String bName = b.getContact().getAuthor().getName();
|
||||
return String.CASE_INSENSITIVE_ORDER.compare(aName, bName);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user