aboutsummaryrefslogblamecommitdiff
path: root/app/src/main/java/SubscribedUserDatabase/SubscribedUserViewModel.java
blob: ed1db58f1b4fe25b541fedd481ceecae7e6b1a85 (plain) (tree)
1
2
3
4
5
                               

                               

                                           




















                                                                                     
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);
    }
}