mirror of https://github.com/readrops/Readrops.git
Not to hold a database instance in a viewmodel class
This commit is contained in:
parent
3cee4fead6
commit
83ca13249a
|
@ -6,19 +6,20 @@ import android.arch.lifecycle.LiveData;
|
|||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.readrops.app.database.Database;
|
||||
import com.readrops.app.database.dao.ItemDao;
|
||||
import com.readrops.app.database.pojo.ItemWithFeed;
|
||||
|
||||
public class ItemViewModel extends AndroidViewModel {
|
||||
|
||||
private Database db;
|
||||
private ItemDao itemDao;
|
||||
|
||||
public ItemViewModel(@NonNull Application application) {
|
||||
super(application);
|
||||
db = Database.getInstance(application);
|
||||
itemDao = Database.getInstance(application).itemDao();
|
||||
}
|
||||
|
||||
public LiveData<ItemWithFeed> getItemById(int id) {
|
||||
return db.itemDao().getItemById(id);
|
||||
return itemDao.getItemById(id);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue