aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/SubredditDatabase/SubredditRepository.java
blob: 2c66ad4bfbbb6d2e509a327ef045d652d7200cb3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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;
        }
    }
}
an>/+1 2021-03-21Add !queuerandomidiot131-0/+44 2021-03-20remove embed from run rejection messageSkycloudd1-1/+1 2021-03-16hopefully fixed the ultraxd thingSkycloudd1-1/+1 2021-03-05Tabs to spacesMango0x451-526/+541 2021-03-05Educate new members on input rulesMango0x451-535/+526 2021-02-28Make !pending not max out at 200 runs per gamerandomidiot131-5/+16 2021-02-27Update aiohttp due to security vulnerabilityMango0x452-1/+2 2021-02-24Make !verified asynchronousAnInternetTroll2-38/+36 2021-02-20Add verified commandrandomidiot131-0/+45 If I did everything right, there should be a "verified" command that does the same thing as "src!v", roughly. Be advised that I have no idea if what I'm doing is correct, good, and/or functional. 2021-02-13Whitelist coop all bosses when rejecting spamMango0x451-1/+1 2021-02-13Remove useless importsMango0x454-6/+1 2021-02-13Add better spam preventionMango0x451-15/+22 2021-02-13Remove useless dependenciesMango0x451-10/+8