Local contacts improvements

This commit is contained in:
M66B
2019-03-16 16:58:57 +00:00
parent 936a0dc9bc
commit 044d94c6b5
5 changed files with 38 additions and 24 deletions

View File

@@ -35,18 +35,15 @@ public interface DaoContact {
List<EntityContact> getContacts();
@Query("SELECT * FROM contact" +
" ORDER BY" +
" CASE" +
" WHEN favorite = 1 THEN 0" +
" WHEN favorite = 2 THEN 2" +
" ELSE 1 END" +
", times_contacted DESC" +
", last_contacted DESC")
" ORDER BY times_contacted DESC, last_contacted DESC")
LiveData<List<EntityContact>> liveContacts();
@Query("SELECT * FROM contact" +
" WHERE favorite <> 2" +
" ORDER BY favorite DESC, times_contacted DESC, last_contacted DESC" +
" WHERE favorite <> " + EntityContact.STATE_IGNORE +
" ORDER BY" +
" CASE WHEN favorite = " + EntityContact.STATE_FAVORITE + " THEN 0 ELSE 1 END" +
", times_contacted DESC" +
", last_contacted DESC" +
" LIMIT :count")
List<EntityContact> getFrequentlyContacted(int count);
@@ -76,13 +73,10 @@ public interface DaoContact {
@Query("UPDATE contact SET favorite = :state WHERE id = :id")
int setContactState(long id, int state);
@Query("DELETE FROM contact WHERE id= :id")
int deleteContact(long id);
@Query("DELETE FROM contact" +
" WHERE last_contacted IS NOT NULL" +
" AND last_contacted < :before" +
" AND NOT favorite")
" AND favorite <> " + EntityContact.STATE_FAVORITE)
int deleteContacts(long before);
@Query("DELETE FROM contact")