mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Sort group names alphabetically in composition activities.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package net.sf.briar.android.groups;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import net.sf.briar.api.messaging.Group;
|
||||
|
||||
class GroupNameComparator implements Comparator<Group> {
|
||||
|
||||
static final GroupNameComparator INSTANCE = new GroupNameComparator();
|
||||
|
||||
public int compare(Group a, Group b) {
|
||||
return String.CASE_INSENSITIVE_ORDER.compare(a.getName(), b.getName());
|
||||
}
|
||||
}
|
||||
@@ -224,15 +224,16 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
if(groups.isEmpty()) finish();
|
||||
int index = -1;
|
||||
for(LocalGroup g : groups) {
|
||||
if(g.getId().equals(localGroupId)) {
|
||||
localGroup = g;
|
||||
index = toAdapter.getCount();
|
||||
toAdapter.clear();
|
||||
for(LocalGroup g : groups) toAdapter.add(g);
|
||||
toAdapter.sort(GroupNameComparator.INSTANCE);
|
||||
int count = toAdapter.getCount();
|
||||
for(int i = 0; i < count; i++) {
|
||||
if(toAdapter.getItem(i).getId().equals(localGroupId)) {
|
||||
toSpinner.setSelection(i);
|
||||
break;
|
||||
}
|
||||
toAdapter.add(g);
|
||||
}
|
||||
if(index != -1) toSpinner.setSelection(index);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -229,15 +229,16 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
if(groups.isEmpty()) finish();
|
||||
int index = -1;
|
||||
for(Group g : groups) {
|
||||
if(g.getId().equals(groupId)) {
|
||||
group = g;
|
||||
index = toAdapter.getCount();
|
||||
toAdapter.clear();
|
||||
for(Group g : groups) toAdapter.add(g);
|
||||
toAdapter.sort(GroupNameComparator.INSTANCE);
|
||||
int count = toAdapter.getCount();
|
||||
for(int i = 0; i < count; i++) {
|
||||
if(toAdapter.getItem(i).getId().equals(groupId)) {
|
||||
toSpinner.setSelection(i);
|
||||
break;
|
||||
}
|
||||
toAdapter.add(g);
|
||||
}
|
||||
if(index != -1) toSpinner.setSelection(index);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user