• R/O
  • SSH
  • HTTPS

androidstudying: Commit


Commit MetaInfo

Revision64 (tree)
Time2020-03-05 13:30:47
Authorpbtdanh

Log Message

* update

Change Summary

Incremental Difference

--- trunk/dictdroid2020/single/app/src/main/java/com/xynotec/dictdroid/data/local/dao/AppDatabase.java (revision 63)
+++ trunk/dictdroid2020/single/app/src/main/java/com/xynotec/dictdroid/data/local/dao/AppDatabase.java (nonexistent)
@@ -1,14 +0,0 @@
1-package com.xynotec.dictdroid.data.local.dao;
2-
3-import androidx.room.Database;
4-import androidx.room.RoomDatabase;
5-
6-//@Database(entities = {User.class, Question.class, Option.class}, version = 2)
7-public abstract class AppDatabase{
8-
9-// public abstract OptionDao optionDao();
10-//
11-// public abstract QuestionDao questionDao();
12-//
13-// public abstract UserDao userDao();
14-}
\ No newline at end of file
--- trunk/dictdroid2020/single/app/src/main/java/com/xynotec/dictdroid/data/local/dao/DbHelper.java (revision 63)
+++ trunk/dictdroid2020/single/app/src/main/java/com/xynotec/dictdroid/data/local/dao/DbHelper.java (nonexistent)
@@ -1,16 +0,0 @@
1-package com.xynotec.dictdroid.data.local.dao;
2-
3-import com.xynotec.dictdroid.data.model.Favorite;
4-import com.xynotec.dictdroid.data.model.History;
5-
6-import java.util.List;
7-
8-public interface DbHelper {
9-
10- List<History> getHistory();
11- List<Favorite> getFavorite();
12- void insertHistory(History history);
13- void insertFavorite(Favorite favorite);
14-
15-
16-}
--- trunk/dictdroid2020/single/app/src/main/java/com/xynotec/dictdroid/data/local/dao/AppDbHelper.java (revision 63)
+++ trunk/dictdroid2020/single/app/src/main/java/com/xynotec/dictdroid/data/local/dao/AppDbHelper.java (nonexistent)
@@ -1,37 +0,0 @@
1-package com.xynotec.dictdroid.data.local.dao;
2-
3-import com.xynotec.dictdroid.data.model.Favorite;
4-import com.xynotec.dictdroid.data.model.History;
5-
6-import java.util.List;
7-
8-import javax.inject.Inject;
9-
10-public class AppDbHelper implements DbHelper {
11- private final AppDatabase mAppDatabase;
12-
13- @Inject
14- public AppDbHelper(AppDatabase appDatabase) {
15- this.mAppDatabase = appDatabase;
16- }
17-
18- @Override
19- public List<History> getHistory() {
20- return null;
21- }
22-
23- @Override
24- public List<Favorite> getFavorite() {
25- return null;
26- }
27-
28- @Override
29- public void insertHistory(History history) {
30-
31- }
32-
33- @Override
34- public void insertFavorite(Favorite favorite) {
35-
36- }
37-}
--- trunk/dictdroid2020/single/app/src/main/java/com/xynotec/dictdroid/data/local/dao/FavoriteDao.java (nonexistent)
+++ trunk/dictdroid2020/single/app/src/main/java/com/xynotec/dictdroid/data/local/dao/FavoriteDao.java (revision 64)
@@ -0,0 +1,30 @@
1+package com.xynotec.dictdroid.data.local.dao;
2+
3+import androidx.lifecycle.LiveData;
4+
5+import com.xynotec.dictdroid.data.model.Favorite;
6+import com.xynotec.realm.livemodel.LiveRealmResults;
7+
8+import java.util.List;
9+
10+import javax.inject.Inject;
11+
12+import io.realm.Realm;
13+import io.realm.RealmConfiguration;
14+
15+public class FavoriteDao {
16+
17+ RealmConfiguration mConfig;
18+
19+ @Inject
20+ public FavoriteDao(RealmConfiguration config) {
21+ mConfig = config;
22+ }
23+
24+ public LiveData<List<Favorite>> getFavorites()
25+ {
26+ final Realm realm = Realm.getInstance(mConfig);
27+ return new LiveRealmResults<>(realm.where(Favorite.class).findAllAsync());
28+ }
29+
30+}
\ No newline at end of file
--- trunk/dictdroid2020/single/app/src/main/java/com/xynotec/dictdroid/data/local/dao/HistoryDao.java (revision 63)
+++ trunk/dictdroid2020/single/app/src/main/java/com/xynotec/dictdroid/data/local/dao/HistoryDao.java (revision 64)
@@ -1,7 +1,15 @@
11 package com.xynotec.dictdroid.data.local.dao;
22
3+import androidx.lifecycle.LiveData;
4+
5+import com.xynotec.dictdroid.data.model.History;
6+import com.xynotec.realm.livemodel.LiveRealmResults;
7+
8+import java.util.List;
9+
310 import javax.inject.Inject;
411
12+import io.realm.Realm;
513 import io.realm.RealmConfiguration;
614
715 public class HistoryDao {
@@ -13,4 +21,10 @@
1321 mConfig = config;
1422 }
1523
24+ public LiveData<List<History>> getHistories()
25+ {
26+ final Realm realm = Realm.getInstance(mConfig);
27+ return new LiveRealmResults<>(realm.where(History.class).findAllAsync());
28+ }
29+
1630 }
Show on old repository browser