mirror of
https://github.com/Docile-Alligator/Infinity-For-Reddit.git
synced 2026-03-07 08:19:09 +00:00
View user details in ViewUserDetailActivity. Follow or unfollow user is not properly implemented right now. Change users and subscribed_users databases' schemes. Press Profile in navigation drawer to view my reddit info. Press the username in the post to view that account's info.
This commit is contained in:
39
app/src/main/java/User/UserRepository.java
Normal file
39
app/src/main/java/User/UserRepository.java
Normal file
@ -0,0 +1,39 @@
|
||||
package User;
|
||||
|
||||
import android.app.Application;
|
||||
import android.arch.lifecycle.LiveData;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
public class UserRepository {
|
||||
private UserDao mUserDao;
|
||||
private LiveData<UserData> mUserLiveData;
|
||||
|
||||
UserRepository(Application application, String userName) {
|
||||
mUserDao = UserRoomDatabase.getDatabase(application).userDao();
|
||||
|
||||
mUserLiveData = mUserDao.getUserLiveData(userName);
|
||||
}
|
||||
|
||||
LiveData<UserData> getUserLiveData() {
|
||||
return mUserLiveData;
|
||||
}
|
||||
|
||||
public void insert(UserData userData) {
|
||||
new InsertAsyncTask(mUserDao).execute(userData);
|
||||
}
|
||||
|
||||
private static class InsertAsyncTask extends AsyncTask<UserData, Void, Void> {
|
||||
|
||||
private UserDao mAsyncTaskDao;
|
||||
|
||||
InsertAsyncTask(UserDao dao) {
|
||||
mAsyncTaskDao = dao;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(final UserData... params) {
|
||||
mAsyncTaskDao.insert(params[0]);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user