aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/Account/AccountRepository.java
blob: 573f00f88998bb2c4f2130da9c0075ce688551c3 (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
41
42
package Account;

import android.os.AsyncTask;

import androidx.lifecycle.LiveData;

import java.util.List;

import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;

public class AccountRepository {
    private AccountDao mAccountDao;
    private LiveData<List<Account>> mAccountsExceptCurrentAccountLiveData;

    AccountRepository(RedditDataRoomDatabase redditDataRoomDatabase, String username) {
        mAccountDao = redditDataRoomDatabase.accountDao();
        mAccountsExceptCurrentAccountLiveData = mAccountDao.getAccountsExceptCurrentAccountLiveData();
    }

    public LiveData<List<Account>> getAccountsExceptCurrentAccountLiveData() {
        return mAccountsExceptCurrentAccountLiveData;
    }

    public void insert(Account Account) {
        new InsertAsyncTask(mAccountDao).execute(Account);
    }

    private static class InsertAsyncTask extends AsyncTask<Account, Void, Void> {

        private AccountDao mAsyncTaskDao;

        InsertAsyncTask(AccountDao dao) {
            mAsyncTaskDao = dao;
        }

        @Override
        protected Void doInBackground(final Account... params) {
            mAsyncTaskDao.insert(params[0]);
            return null;
        }
    }
}
ml?id=a6975f2489119a0e0cc278fcdee8cead97978b14&follow=1'>Hide read posts in MainActivity (there is an issue in lazy mode).Alex Ning11-2/+131 2020-12-07Prevent inserting read posts into database multiple times when clicking posts.Alex Ning1-13/+17 2020-12-07Fix wrong vote and save info in CommentsListingRecyclerViewAdapter.Alex Ning1-20/+42 2020-12-07Fix wrong vote info showing in posts and comments.Alex Ning2-80/+154 2020-12-07Fix crash when parsing post with null readPostList value.Alex Ning1-2/+5 2020-12-07View video or image to mark the post as read.Alex Ning1-0/+3 2020-12-07Mark posts as read.Alex Ning19-126/+338 2020-12-07Prepare to add a new feature: hide read posts.Alex Ning8-120/+410 2020-12-06Add donation infoDocile-Alligator1-0/+3 2020-12-06Version 4.1.1.Alex Ning2-3/+3 2020-12-06Fix very small flair icon.Alex Ning1-17/+4 2020-12-03Add setImmersiveModeNotApplicable() in some activities.Alex Ning2-0/+6 2020-12-02Version 4.1.1-beta1.Alex Ning3-5/+6 2020-12-02Add an option to disable search history.Alex Ning6-17/+31 2020-12-02Lower the threshold for image preview width and height.Alex Ning2-22/+26 2020-12-02Try fixing ANR when releasing ExoPlayer.Alex Ning5-6/+14 2020-12-02Fix some NullPointerException.Alex Ning2-10/+11 2020-12-02Try fixing IllegalStateException for fragments in various Activities.Alex Ning5-11/+12 2020-12-02Maybe fixed IllegaStateException for ShareLinkBottomSheetFragment and CopyTex...Alex Ning2-12/+9 2020-12-01Maybe fix IndexOutOfBoundsException when parsing spoiler syntax.Alex Ning4-0/+25 2020-12-01Disable nsfw warning in ViewUserDetailActivity.Alex Ning1-3/+3 2020-12-01Maybe fix crash when downloading media.Alex Ning3-240/+2 2020-12-01Minor bugs fixed.Alex Ning3-13/+28 2020-12-01Fix ArrayIndexOutOfBoundsException in FollowedUsersRecyclerViewAdapter. Minor...Alex Ning4-122/+147 2020-12-01Update translation.Alex Ning10-849/+1636 2020-12-01Show upvoted or downvoted color in topScoreTextView in CommentViewHolder.Alex Ning1-0/+10 2020-11-30Changing language is now available.Alex Ning8-3/+83