diff options
author | Alex Ning <chineseperson5@gmail.com> | 2019-08-07 02:54:47 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2019-08-07 02:54:47 +0000 |
commit | 7f2bc01180c284154fb69976122016c4638e9973 (patch) | |
tree | b009b9cfab924cce98c25ae5b6355af4f18c311c /app/src/main/java/Account/AccountDao.java | |
parent | 77d83654aa8063b0c4d9f95ba91bd3d77be84ad9 (diff) | |
download | infinity-for-reddit-7f2bc01180c284154fb69976122016c4638e9973.tar infinity-for-reddit-7f2bc01180c284154fb69976122016c4638e9973.tar.gz infinity-for-reddit-7f2bc01180c284154fb69976122016c4638e9973.tar.bz2 infinity-for-reddit-7f2bc01180c284154fb69976122016c4638e9973.tar.lz infinity-for-reddit-7f2bc01180c284154fb69976122016c4638e9973.tar.xz infinity-for-reddit-7f2bc01180c284154fb69976122016c4638e9973.tar.zst infinity-for-reddit-7f2bc01180c284154fb69976122016c4638e9973.zip |
Preparing to support multi user. Use the database to store accounts' info. LoginActivity is successfully refactored. Any other features are unavailable for now.
Diffstat (limited to 'app/src/main/java/Account/AccountDao.java')
-rw-r--r-- | app/src/main/java/Account/AccountDao.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/app/src/main/java/Account/AccountDao.java b/app/src/main/java/Account/AccountDao.java new file mode 100644 index 00000000..bd53b92b --- /dev/null +++ b/app/src/main/java/Account/AccountDao.java @@ -0,0 +1,22 @@ +package Account; + +import androidx.lifecycle.LiveData; +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.OnConflictStrategy; +import androidx.room.Query; + +@Dao +public interface AccountDao { + @Insert(onConflict = OnConflictStrategy.REPLACE) + void insert(Account account); + + @Query("DELETE FROM accounts") + void deleteAllAccounts(); + + @Query("SELECT * FROM accounts WHERE username = :userName COLLATE NOCASE LIMIT 1") + LiveData<Account> getAccountLiveData(String userName); + + @Query("SELECT * FROM accounts WHERE username = :userName COLLATE NOCASE LIMIT 1") + Account getAccountData(String userName); +} |