diff options
Diffstat (limited to 'app/src/main/java/SubredditDatabase/SubredditRepository.java')
-rw-r--r-- | app/src/main/java/SubredditDatabase/SubredditRepository.java | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/app/src/main/java/SubredditDatabase/SubredditRepository.java b/app/src/main/java/SubredditDatabase/SubredditRepository.java deleted file mode 100644 index 2c66ad4b..00000000 --- a/app/src/main/java/SubredditDatabase/SubredditRepository.java +++ /dev/null @@ -1,40 +0,0 @@ -package SubredditDatabase; - -import android.os.AsyncTask; - -import androidx.lifecycle.LiveData; - -import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; - -public class SubredditRepository { - private SubredditDao mSubredditDao; - private LiveData<SubredditData> mSubredditLiveData; - - SubredditRepository(RedditDataRoomDatabase redditDataRoomDatabase, String subredditName) { - mSubredditDao = redditDataRoomDatabase.subredditDao(); - mSubredditLiveData = mSubredditDao.getSubredditLiveDataByName(subredditName); - } - - LiveData<SubredditData> getSubredditLiveData() { - return mSubredditLiveData; - } - - public void insert(SubredditData subredditData) { - new InsertAsyncTask(mSubredditDao).execute(subredditData); - } - - private static class InsertAsyncTask extends AsyncTask<SubredditData, Void, Void> { - - private SubredditDao mAsyncTaskDao; - - InsertAsyncTask(SubredditDao dao) { - mAsyncTaskDao = dao; - } - - @Override - protected Void doInBackground(final SubredditData... params) { - mAsyncTaskDao.insert(params[0]); - return null; - } - } -} |