summaryrefslogtreecommitdiff
path: root/src/de/blinkt
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
commit676f354bcfad2d93d984aa4a94124cfac5884984 (patch)
treee2fa0a18d00fc383edf0a8b88400470903654f6a /src/de/blinkt
parentb70cb63f91b260abae0d65ccd97ff88a069d9f26 (diff)
sort profies by name, better than not sorting at all
Diffstat (limited to 'src/de/blinkt')
-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);
}