Fail-safe

This commit is contained in:
M66B 2020-03-30 17:58:41 +02:00
parent f8982f70e0
commit 64e0ab7401
1 changed files with 28 additions and 23 deletions

View File

@ -803,32 +803,37 @@ public class FragmentCompose extends FragmentBase {
Collections.sort(items, new Comparator<EntityContact>() { Collections.sort(items, new Comparator<EntityContact>() {
@Override @Override
public int compare(EntityContact i1, EntityContact i2) { public int compare(EntityContact i1, EntityContact i2) {
if (suggest_frequently) { try {
int t = -i1.times_contacted.compareTo(i2.times_contacted); if (suggest_frequently) {
if (t != 0) int t = -i1.times_contacted.compareTo(i2.times_contacted);
return t; if (t != 0)
return t;
int l = -i1.last_contacted.compareTo(i2.last_contacted); int l = -i1.last_contacted.compareTo(i2.last_contacted);
if (l != 0) if (l != 0)
return l; return l;
} else { } else {
int a = -Boolean.compare(i1.id == 0, i2.id == 0); int a = -Boolean.compare(i1.id == 0, i2.id == 0);
if (a != 0) if (a != 0)
return a; return a;
} }
if (TextUtils.isEmpty(i1.name) && TextUtils.isEmpty(i2.name)) if (TextUtils.isEmpty(i1.name) && TextUtils.isEmpty(i2.name))
return 0;
if (TextUtils.isEmpty(i1.name) && !TextUtils.isEmpty(i2.name))
return 1;
if (!TextUtils.isEmpty(i1.name) && TextUtils.isEmpty(i2.name))
return -1;
int n = collator.compare(i1.name, i2.name);
if (n != 0)
return n;
return collator.compare(i1.email, i2.email);
} catch (Throwable ex) {
Log.e(ex);
return 0; return 0;
if (TextUtils.isEmpty(i1.name) && !TextUtils.isEmpty(i2.name)) }
return 1;
if (!TextUtils.isEmpty(i1.name) && TextUtils.isEmpty(i2.name))
return -1;
int n = collator.compare(i1.name, i2.name);
if (n != 0)
return n;
return collator.compare(i1.email, i2.email);
} }
}); });