From be68d4990437fbe360f6278b28ee89c8d76f5eb5 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 27 Apr 2019 15:27:23 +0200 Subject: [PATCH] Refactoring --- .../java/eu/faircode/email/AdapterAnswer.java | 17 ----------------- .../java/eu/faircode/email/AdapterMessage.java | 13 ------------- .../main/java/eu/faircode/email/DaoAnswer.java | 6 ++++-- 3 files changed, 4 insertions(+), 32 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterAnswer.java b/app/src/main/java/eu/faircode/email/AdapterAnswer.java index af75beabdc..5fa2ecb1b9 100644 --- a/app/src/main/java/eu/faircode/email/AdapterAnswer.java +++ b/app/src/main/java/eu/faircode/email/AdapterAnswer.java @@ -34,12 +34,8 @@ import androidx.recyclerview.widget.DiffUtil; import androidx.recyclerview.widget.ListUpdateCallback; import androidx.recyclerview.widget.RecyclerView; -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 AdapterAnswer extends RecyclerView.Adapter { private Context context; @@ -136,19 +132,6 @@ public class AdapterAnswer extends RecyclerView.Adapter answers) { Log.i("Set answers=" + answers.size()); - final Collator collator = Collator.getInstance(Locale.getDefault()); - collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc - - Collections.sort(answers, new Comparator() { - @Override - public int compare(EntityAnswer a1, EntityAnswer a2) { - int n = collator.compare(a1.name, a2.name); - if (n != 0) - return n; - return a1.id.compareTo(a2.id); - } - }); - DiffUtil.DiffResult diff = DiffUtil.calculateDiff(new DiffCallback(items, answers), false); items = answers; diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index cab5daa57a..447a8627bf 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -108,17 +108,14 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.UnsupportedEncodingException; -import java.text.Collator; import java.text.DateFormat; import java.text.NumberFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.Comparator; import java.util.Date; import java.util.List; -import java.util.Locale; import javax.mail.Address; import javax.mail.internet.InternetAddress; @@ -2979,16 +2976,6 @@ public class AdapterMessage extends RecyclerView.Adapter() { - @Override - public int compare(EntityAnswer a1, EntityAnswer a2) { - return collator.compare(a1.name, a2.name); - } - }); - View anchor = bnvActions.findViewById(R.id.action_reply); PopupMenu popupMenu = new PopupMenu(context, anchor); diff --git a/app/src/main/java/eu/faircode/email/DaoAnswer.java b/app/src/main/java/eu/faircode/email/DaoAnswer.java index 3bbe13b911..34cb1cd3be 100644 --- a/app/src/main/java/eu/faircode/email/DaoAnswer.java +++ b/app/src/main/java/eu/faircode/email/DaoAnswer.java @@ -30,13 +30,15 @@ import java.util.List; @Dao public interface DaoAnswer { @Query("SELECT * FROM answer" + - " WHERE :all OR NOT hide") + " WHERE :all OR NOT hide" + + " ORDER BY name COLLATE NOCASE") List getAnswers(boolean all); @Query("SELECT * FROM answer WHERE id = :id") EntityAnswer getAnswer(long id); - @Query("SELECT * FROM answer") + @Query("SELECT * FROM answer" + + " ORDER BY name COLLATE NOCASE") LiveData> liveAnswers(); @Insert