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:
Alex Ning
2019-01-11 11:33:32 +08:00
parent f0b149ce82
commit e48bb565a5
29 changed files with 704 additions and 120 deletions

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