Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-notes.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Niedermann <info@niedermann.it>2021-01-03 13:16:18 +0300
committerStefan Niedermann <info@niedermann.it>2021-01-03 13:16:18 +0300
commit7b68f925e71662cc4caf26998efadc6df44848e5 (patch)
treeab5f4be5ef547773a2cc71dfb0d2ae2df006933a /app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/AccountDao.java
parent02e9b71a4cdbc7f026a4fa984aea2dbfafa14f70 (diff)
Deduplicate Dao queries for LiveData and Non-LiveData
Diffstat (limited to 'app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/AccountDao.java')
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/AccountDao.java37
1 files changed, 21 insertions, 16 deletions
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/AccountDao.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/AccountDao.java
index 1734e1a7..0fe6f768 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/AccountDao.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/AccountDao.java
@@ -20,29 +20,34 @@ public interface AccountDao {
@Delete
int deleteAccount(Account localAccount);
- @Query("SELECT * FROM Account WHERE ID = :accountId")
- Account getAccount(long accountId);
+ String getAccountById = "SELECT * FROM Account WHERE ID = :accountId";
+ String getAccountByName = "SELECT * FROM Account WHERE ACCOUNTNAME = :accountName";
+ String getAccounts = "SELECT * FROM Account";
+ String countAccounts = "SELECT COUNT(*) FROM Account";
- @Query("SELECT * FROM Account WHERE ID = :accountId")
- LiveData<Account> getAccountLiveData(long accountId);
+ @Query(getAccountById)
+ LiveData<Account> getAccountById$(long accountId);
- @Query("SELECT * FROM Account WHERE ACCOUNTNAME = :accountName")
- Account getLocalAccountByAccountName(String accountName);
+ @Query(getAccountById)
+ Account getAccountById(long accountId);
- @Query("SELECT * FROM Account WHERE ACCOUNTNAME = :accountName")
- LiveData<Account> getLocalAccountByAccountNameLiveData(String accountName);
+ @Query(getAccountByName)
+ LiveData<Account> getAccountByName$(String accountName);
- @Query("SELECT * FROM Account")
- List<Account> getAccounts();
+ @Query(getAccountByName)
+ Account getAccountByName(String accountName);
+
+ @Query(getAccounts)
+ LiveData<List<Account>> getAccounts$();
- @Query("SELECT * FROM Account")
- LiveData<List<Account>> getAccountsLiveData();
+ @Query(getAccounts)
+ List<Account> getAccounts();
- @Query("SELECT COUNT(*) FROM Account")
- Integer getAccountsCount();
+ @Query(countAccounts)
+ LiveData<Integer> countAccounts$();
- @Query("SELECT COUNT(*) FROM Account")
- LiveData<Integer> getAccountsCountLiveData();
+ @Query(countAccounts)
+ Integer countAccounts();
@Query("UPDATE Account SET COLOR = :color, TEXTCOLOR = :textColor WHERE id = :id")
void updateBrand(long id, @ColorInt Integer color, @ColorInt Integer textColor);