aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/SubscribedUserDatabase/SubscribedUserViewModel.java
blob: ed1db58f1b4fe25b541fedd481ceecae7e6b1a85 (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
package SubscribedUserDatabase;

import android.app.Application;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;

import java.util.List;

public class SubscribedUserViewModel extends AndroidViewModel {
    private SubscribedUserRepository mSubscribedUserRepository;
    private LiveData<List<SubscribedUserData>> mAllSubscribedUsers;

    public SubscribedUserViewModel(Application application) {
        super(application);
        mSubscribedUserRepository = new SubscribedUserRepository(application);
        mAllSubscribedUsers = mSubscribedUserRepository.getAllSubscribedSubreddits();
    }

    public LiveData<List<SubscribedUserData>> getAllSubscribedUsers() {
        return mAllSubscribedUsers;
    }

    public void insert(SubscribedUserData subscribedUserData) {
        mSubscribedUserRepository.insert(subscribedUserData);
    }
}