From 21336ff78de3f14c8129f23a7c0477973901576e Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Mon, 13 Aug 2012 22:18:33 +0200 Subject: sort profies by name, better than not sorting at all --HG-- extra : rebase_source : 31ecdd1d6197a3ec95785a52e95b62a013c7539b --- src/de/blinkt/openvpn/VPNProfileList.java | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src') 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 { + + @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 allvpn = getPM().getProfiles(); + + TreeSet sortedset = new TreeSet(new VpnProfileNameComperator()); + sortedset.addAll(allvpn); + mArrayadapter.addAll(sortedset); setListAdapter(mArrayadapter); } -- cgit v1.2.3