mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 05:39:53 +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() {
|
runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if(groups.isEmpty()) finish();
|
if(groups.isEmpty()) finish();
|
||||||
int index = -1;
|
toAdapter.clear();
|
||||||
for(LocalGroup g : groups) {
|
for(LocalGroup g : groups) toAdapter.add(g);
|
||||||
if(g.getId().equals(localGroupId)) {
|
toAdapter.sort(GroupNameComparator.INSTANCE);
|
||||||
localGroup = g;
|
int count = toAdapter.getCount();
|
||||||
index = 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() {
|
runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if(groups.isEmpty()) finish();
|
if(groups.isEmpty()) finish();
|
||||||
int index = -1;
|
toAdapter.clear();
|
||||||
for(Group g : groups) {
|
for(Group g : groups) toAdapter.add(g);
|
||||||
if(g.getId().equals(groupId)) {
|
toAdapter.sort(GroupNameComparator.INSTANCE);
|
||||||
group = g;
|
int count = toAdapter.getCount();
|
||||||
index = 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