summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2012-08-13 22:18:33 +0200
committerArne Schwabe <arne@rfc2549.org>2012-08-13 22:18:33 +0200
commit21336ff78de3f14c8129f23a7c0477973901576e (patch)
tree6f0613f6ca9ed5fcf1d0fa86e818dcd5aad1bfe4 /src
parentd50f18d33452dd2edd48e000f6d8694336d26533 (diff)
sort profies by name, better than not sorting at all
--HG-- extra : rebase_source : 31ecdd1d6197a3ec95785a52e95b62a013c7539b
Diffstat (limited to 'src')
-rw-r--r--src/de/blinkt/openvpn/VPNProfileList.java24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/de/blinkt/openvpn/VPNProfileList.java b/src/de/blinkt/openvpn/VPNProfileList.java
index 974090d4..53c0707f 100644
--- a/src/de/blinkt/openvpn/VPNProfileList.java
+++ b/src/de/blinkt/openvpn/VPNProfileList.java
@@ -1,5 +1,14 @@
package de.blinkt.openvpn;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.Vector;
+
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ListFragment;
@@ -91,9 +100,22 @@ public class VPNProfileList extends ListFragment {
setListAdapter();
}
+ class VpnProfileNameComperator implements Comparator<VpnProfile> {
+
+ @Override
+ public int compare(VpnProfile lhs, VpnProfile rhs) {
+ return lhs.mName.compareTo(rhs.mName);
+ }
+
+ }
+
private void setListAdapter() {
mArrayadapter = new VPNArrayAdapter(getActivity(),R.layout.vpn_list_item,R.id.vpn_item_title);
- mArrayadapter.addAll(getPM().getProfiles());
+ Collection<VpnProfile> allvpn = getPM().getProfiles();
+
+ TreeSet<VpnProfile> sortedset = new TreeSet<VpnProfile>(new VpnProfileNameComperator());
+ sortedset.addAll(allvpn);
+ mArrayadapter.addAll(sortedset);
setListAdapter(mArrayadapter);
}