mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 04:35:57 +00:00
Refactoring
This commit is contained in:
parent
2680a2d64f
commit
be68d49904
3 changed files with 4 additions and 32 deletions
|
@ -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<AdapterAnswer.ViewHolder> {
|
||||
private Context context;
|
||||
|
@ -136,19 +132,6 @@ public class AdapterAnswer extends RecyclerView.Adapter<AdapterAnswer.ViewHolder
|
|||
public void set(@NonNull List<EntityAnswer> 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<EntityAnswer>() {
|
||||
@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;
|
||||
|
|
|
@ -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<AdapterMessage.ViewHold
|
|||
});
|
||||
snackbar.show();
|
||||
} else {
|
||||
final Collator collator = Collator.getInstance(Locale.getDefault());
|
||||
collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc
|
||||
|
||||
Collections.sort(answers, new Comparator<EntityAnswer>() {
|
||||
@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);
|
||||
|
||||
|
|
|
@ -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<EntityAnswer> 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<List<EntityAnswer>> liveAnswers();
|
||||
|
||||
@Insert
|
||||
|
|
Loading…
Reference in a new issue