From 30a2b5ee31c8a41c835650990ea735b4e2edc11f Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 3 Aug 2018 04:34:02 +0000 Subject: [PATCH] Sort providers on name --- app/src/main/java/eu/faircode/email/Provider.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/Provider.java b/app/src/main/java/eu/faircode/email/Provider.java index e8edabbe..bd24d32e 100644 --- a/app/src/main/java/eu/faircode/email/Provider.java +++ b/app/src/main/java/eu/faircode/email/Provider.java @@ -25,8 +25,12 @@ import android.util.Log; import org.xmlpull.v1.XmlPullParser; +import java.text.Collator; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.List; +import java.util.Locale; public class Provider { public String name; @@ -77,6 +81,16 @@ public class Provider { } catch (Throwable ex) { Log.e(Helper.TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } + final Collator collator = Collator.getInstance(Locale.getDefault()); + collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc + + Collections.sort(result, new Comparator() { + @Override + public int compare(Provider p1, Provider p2) { + return collator.compare(p1.name, p2.name); + } + }); + return result; }