1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-01-02 21:24:34 +00:00

Sort providers on name

This commit is contained in:
M66B 2018-08-03 04:34:02 +00:00
parent a78fb6ba91
commit 30a2b5ee31

View file

@ -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<Provider>() {
@Override
public int compare(Provider p1, Provider p2) {
return collator.compare(p1.name, p2.name);
}
});
return result;
}