aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml/docilealligator
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/ml/docilealligator')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/FetchSubscribedThing.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/LoadSubredditIconAsyncTask.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubredditData.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubscribedThing.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubredditDao.java25
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubredditData.java63
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubredditRepository.java43
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubredditRoomDatabase.java26
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubredditViewModel.java48
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditDao.java21
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditData.java38
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditRecyclerViewAdapter.java1
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditRepository.java41
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditRoomDatabase.java26
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditViewModel.java26
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserDao.java21
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserData.java37
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserRecyclerViewAdapter.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserRepository.java41
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserRoomDatabase.java26
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserViewModel.java26
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java1
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java4
25 files changed, 33 insertions, 510 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchSubscribedThing.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchSubscribedThing.java
index cfda92de..691d170b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchSubscribedThing.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchSubscribedThing.java
@@ -6,6 +6,9 @@ import android.util.Log;
import java.util.ArrayList;
+import SubredditDatabase.SubredditData;
+import SubscribedSubredditDatabase.SubscribedSubredditData;
+import SubscribedUserDatabase.SubscribedUserData;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/LoadSubredditIconAsyncTask.java b/app/src/main/java/ml/docilealligator/infinityforreddit/LoadSubredditIconAsyncTask.java
index 957e52ab..f7f0fdcd 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/LoadSubredditIconAsyncTask.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/LoadSubredditIconAsyncTask.java
@@ -2,6 +2,8 @@ package ml.docilealligator.infinityforreddit;
import android.os.AsyncTask;
+import SubredditDatabase.SubredditDao;
+
class LoadSubredditIconAsyncTask extends AsyncTask<Void, Void, Void> {
interface LoadSubredditIconAsyncTaskListener {
void loadIconSuccess(String iconImageUrl);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java
index 5f559aa1..00ca7f15 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java
@@ -31,6 +31,17 @@ import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
+import SubredditDatabase.SubredditDao;
+import SubredditDatabase.SubredditData;
+import SubredditDatabase.SubredditRoomDatabase;
+import SubscribedSubredditDatabase.SubscribedSubredditDao;
+import SubscribedSubredditDatabase.SubscribedSubredditData;
+import SubscribedSubredditDatabase.SubscribedSubredditRoomDatabase;
+import SubscribedSubredditDatabase.SubscribedSubredditViewModel;
+import SubscribedUserDatabase.SubscribedUserDao;
+import SubscribedUserDatabase.SubscribedUserData;
+import SubscribedUserDatabase.SubscribedUserRoomDatabase;
+import SubscribedUserDatabase.SubscribedUserViewModel;
import butterknife.BindView;
import butterknife.ButterKnife;
import de.hdodenhof.circleimageview.CircleImageView;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubredditData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubredditData.java
index 1f9b4a9e..5292a976 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubredditData.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubredditData.java
@@ -6,6 +6,8 @@ import android.util.Log;
import org.json.JSONException;
import org.json.JSONObject;
+import SubredditDatabase.SubredditData;
+
class ParseSubredditData {
interface ParseSubredditDataListener {
void onParseSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubscribedThing.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubscribedThing.java
index 2cddfc2f..a69d0c22 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubscribedThing.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubscribedThing.java
@@ -9,6 +9,10 @@ import org.json.JSONObject;
import java.util.ArrayList;
+import SubredditDatabase.SubredditData;
+import SubscribedSubredditDatabase.SubscribedSubredditData;
+import SubscribedUserDatabase.SubscribedUserData;
+
class ParseSubscribedThing {
interface ParseSubscribedSubredditsListener {
void onParseSubscribedSubredditsSuccess(ArrayList<SubscribedSubredditData> subscribedSubredditData,
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java
index 2d6f54aa..9ec8b83b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java
@@ -39,6 +39,8 @@ import com.bumptech.glide.request.target.Target;
import java.util.List;
import CustomView.AspectRatioGifImageView;
+import SubredditDatabase.SubredditDao;
+import SubredditDatabase.SubredditRoomDatabase;
import butterknife.BindView;
import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.BlurTransformation;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditDao.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditDao.java
deleted file mode 100644
index 2e1b0bb7..00000000
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditDao.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package ml.docilealligator.infinityforreddit;
-
-import android.arch.lifecycle.LiveData;
-import android.arch.persistence.room.Dao;
-import android.arch.persistence.room.Insert;
-import android.arch.persistence.room.OnConflictStrategy;
-import android.arch.persistence.room.Query;
-
-@Dao
-public interface SubredditDao {
- @Insert(onConflict = OnConflictStrategy.REPLACE)
- void insert(SubredditData SubredditData);
-
- @Query("DELETE FROM subreddits")
- void deleteAllSubreddits();
-
- @Query("SELECT * from subreddits WHERE id = :id")
- LiveData<SubredditData> getSubredditLiveDataById(String id);
-
- @Query("SELECT * from subreddits WHERE name = :namePrefixed")
- LiveData<SubredditData> getSubredditLiveDataByNamePrefixed(String namePrefixed);
-
- @Query("SELECT * from subreddits WHERE name = :namePrefixed")
- SubredditData getSubredditData(String namePrefixed);
-}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditData.java
deleted file mode 100644
index 59b8e6b8..00000000
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditData.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package ml.docilealligator.infinityforreddit;
-
-import android.arch.persistence.room.ColumnInfo;
-import android.arch.persistence.room.Entity;
-import android.arch.persistence.room.PrimaryKey;
-import android.support.annotation.NonNull;
-
-@Entity(tableName = "subreddits")
-class SubredditData {
- @PrimaryKey
- @NonNull
- @ColumnInfo(name = "id")
- private String id;
-
- @ColumnInfo(name = "name")
- private String name;
-
- @ColumnInfo(name = "icon_url")
- private String iconUrl;
-
- @ColumnInfo(name = "banner_url")
- private String bannerUrl;
-
- @ColumnInfo(name = "description")
- private String description;
-
- @ColumnInfo(name = "subscribers_count")
- private int nSubscribers;
-
- SubredditData(@NonNull String id, String name, String iconUrl, String bannerUrl, String description, int nSubscribers) {
- this.id = id;
- this.name = name;
- this.iconUrl = iconUrl;
- this.bannerUrl = bannerUrl;
- this.description = description;
- this.nSubscribers = nSubscribers;
- }
-
- @NonNull
- public String getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public String getIconUrl() {
- return iconUrl;
- }
-
- public String getBannerUrl() {
- return bannerUrl;
- }
-
- public String getDescription() {
- return description;
- }
-
- public int getNSubscribers() {
- return nSubscribers;
- }
-}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditRepository.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditRepository.java
deleted file mode 100644
index deb68806..00000000
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditRepository.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package ml.docilealligator.infinityforreddit;
-
-import android.app.Application;
-import android.arch.lifecycle.LiveData;
-import android.os.AsyncTask;
-
-public class SubredditRepository {
- private SubredditDao mSubredditDao;
- private LiveData<SubredditData> mSubredditLiveData;
-
- SubredditRepository(Application application, String value, boolean isId) {
- SubredditRoomDatabase db = SubredditRoomDatabase.getDatabase(application);
- mSubredditDao = db.subredditDao();
- if(isId) {
- mSubredditLiveData = mSubredditDao.getSubredditLiveDataById(value);
- } else {
- mSubredditLiveData = mSubredditDao.getSubredditLiveDataByNamePrefixed(value);
- }
- }
-
- LiveData<SubredditData> getSubredditLiveData() {
- return mSubredditLiveData;
- }
-
- public void insert(SubredditData subredditData) {
- new SubredditRepository.insertAsyncTask(mSubredditDao).execute(subredditData);
- }
-
- private static class insertAsyncTask extends AsyncTask<SubredditData, Void, Void> {
-
- private SubredditDao mAsyncTaskDao;
-
- insertAsyncTask(SubredditDao dao) {
- mAsyncTaskDao = dao;
- }
-
- @Override
- protected Void doInBackground(final SubredditData... params) {
- mAsyncTaskDao.insert(params[0]);
- return null;
- }
- }
-}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditRoomDatabase.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditRoomDatabase.java
deleted file mode 100644
index 16affad3..00000000
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditRoomDatabase.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package ml.docilealligator.infinityforreddit;
-
-import android.arch.persistence.room.Database;
-import android.arch.persistence.room.Room;
-import android.arch.persistence.room.RoomDatabase;
-import android.content.Context;
-
-@Database(entities = {SubredditData.class}, version = 1)
-public abstract class SubredditRoomDatabase extends RoomDatabase{
- private static SubredditRoomDatabase INSTANCE;
-
- public abstract SubredditDao subredditDao();
-
- public static SubredditRoomDatabase getDatabase(final Context context) {
- if(INSTANCE == null) {
- synchronized (SubredditRoomDatabase.class) {
- if(INSTANCE == null) {
- INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
- SubredditRoomDatabase.class, "subreddits")
- .build();
- }
- }
- }
- return INSTANCE;
- }
-}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditViewModel.java
deleted file mode 100644
index ee636b43..00000000
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditViewModel.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package ml.docilealligator.infinityforreddit;
-
-import android.app.Application;
-import android.arch.lifecycle.AndroidViewModel;
-import android.arch.lifecycle.LiveData;
-import android.arch.lifecycle.ViewModel;
-import android.arch.lifecycle.ViewModelProvider;
-import android.support.annotation.NonNull;
-
-public class SubredditViewModel extends AndroidViewModel {
- private SubredditRepository mSubredditRepository;
- private LiveData<SubredditData> mSubredditLiveData;
-
- SubredditViewModel(Application application, String id, boolean isId) {
- super(application);
- mSubredditRepository = new SubredditRepository(application, id, isId);
- mSubredditLiveData = mSubredditRepository.getSubredditLiveData();
- }
-
- public LiveData<SubredditData> getSubredditLiveData() {
- return mSubredditLiveData;
- }
-
- public void insert(SubredditData subredditData) {
- mSubredditRepository.insert(subredditData);
- }
-
- public static class Factory extends ViewModelProvider.NewInstanceFactory {
-
- @NonNull
- private final Application mApplication;
-
- private final String value;
- private final boolean isId;
-
- public Factory(@NonNull Application application, String value, boolean isId) {
- mApplication = application;
- this.value = value;
- this.isId = isId;
- }
-
- @Override
- public <T extends ViewModel> T create(Class<T> modelClass) {
- //noinspection unchecked
- return (T) new SubredditViewModel(mApplication, value, isId);
- }
- }
-}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditDao.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditDao.java
deleted file mode 100644
index 9ced85c1..00000000
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditDao.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package ml.docilealligator.infinityforreddit;
-
-import android.arch.lifecycle.LiveData;
-import android.arch.persistence.room.Dao;
-import android.arch.persistence.room.Insert;
-import android.arch.persistence.room.OnConflictStrategy;
-import android.arch.persistence.room.Query;
-
-import java.util.List;
-
-@Dao
-public interface SubscribedSubredditDao {
- @Insert(onConflict = OnConflictStrategy.REPLACE)
- void insert(SubscribedSubredditData subscribedSubredditData);
-
- @Query("DELETE FROM subscribed_subreddits")
- void deleteAllSubscribedSubreddits();
-
- @Query("SELECT * from subscribed_subreddits ORDER BY name COLLATE NOCASE ASC")
- LiveData<List<SubscribedSubredditData>> getAllSubscribedSubreddits();
-}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditData.java
deleted file mode 100644
index 10b2c8e0..00000000
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditData.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package ml.docilealligator.infinityforreddit;
-
-import android.arch.persistence.room.ColumnInfo;
-import android.arch.persistence.room.Entity;
-import android.arch.persistence.room.PrimaryKey;
-import android.support.annotation.NonNull;
-
-@Entity(tableName = "subscribed_subreddits")
-class SubscribedSubredditData {
-
- @PrimaryKey
- @NonNull
- @ColumnInfo(name = "id")
- private String id;
- @ColumnInfo(name = "name")
- private String name;
- @ColumnInfo(name = "icon")
- private String iconUrl;
-
- SubscribedSubredditData(@NonNull String id, String name, String iconUrl) {
- this.id = id;
- this.name = name;
- this.iconUrl = iconUrl;
- }
-
- @NonNull
- public String getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public String getIconUrl() {
- return iconUrl;
- }
-}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditRecyclerViewAdapter.java
index 87c679cd..9bc4f5e7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditRecyclerViewAdapter.java
@@ -23,6 +23,7 @@ import com.felipecsl.gifimageview.library.GifImageView;
import java.util.List;
+import SubscribedSubredditDatabase.SubscribedSubredditData;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
class SubscribedSubredditRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditRepository.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditRepository.java
deleted file mode 100644
index 3173bba4..00000000
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditRepository.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package ml.docilealligator.infinityforreddit;
-
-import android.app.Application;
-import android.arch.lifecycle.LiveData;
-import android.os.AsyncTask;
-
-import java.util.List;
-
-public class SubscribedSubredditRepository {
- private SubscribedSubredditDao mSubscribedSubredditDao;
- private LiveData<List<SubscribedSubredditData>> mAllSubscribedSubreddits;
-
- SubscribedSubredditRepository(Application application) {
- SubscribedSubredditRoomDatabase db = SubscribedSubredditRoomDatabase.getDatabase(application);
- mSubscribedSubredditDao = db.subscribedSubredditDao();
- mAllSubscribedSubreddits = mSubscribedSubredditDao.getAllSubscribedSubreddits();
- }
-
- LiveData<List<SubscribedSubredditData>> getAllSubscribedSubreddits() {
- return mAllSubscribedSubreddits;
- }
-
- public void insert(SubscribedSubredditData subscribedSubredditData) {
- new insertAsyncTask(mSubscribedSubredditDao).execute(subscribedSubredditData);
- }
-
- private static class insertAsyncTask extends AsyncTask<SubscribedSubredditData, Void, Void> {
-
- private SubscribedSubredditDao mAsyncTaskDao;
-
- insertAsyncTask(SubscribedSubredditDao dao) {
- mAsyncTaskDao = dao;
- }
-
- @Override
- protected Void doInBackground(final SubscribedSubredditData... params) {
- mAsyncTaskDao.insert(params[0]);
- return null;
- }
- }
-}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditRoomDatabase.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditRoomDatabase.java
deleted file mode 100644
index d4b1f710..00000000
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditRoomDatabase.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package ml.docilealligator.infinityforreddit;
-
-import android.arch.persistence.room.Database;
-import android.arch.persistence.room.Room;
-import android.arch.persistence.room.RoomDatabase;
-import android.content.Context;
-
-@Database(entities = {SubscribedSubredditData.class}, version = 1)
-public abstract class SubscribedSubredditRoomDatabase extends RoomDatabase {
- private static SubscribedSubredditRoomDatabase INSTANCE;
-
- public abstract SubscribedSubredditDao subscribedSubredditDao();
-
- public static SubscribedSubredditRoomDatabase getDatabase(final Context context) {
- if(INSTANCE == null) {
- synchronized (SubscribedSubredditRoomDatabase.class) {
- if(INSTANCE == null) {
- INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
- SubscribedSubredditRoomDatabase.class, "subscribed_subreddits")
- .build();
- }
- }
- }
- return INSTANCE;
- }
-}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditViewModel.java
deleted file mode 100644
index bd092640..00000000
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditViewModel.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package ml.docilealligator.infinityforreddit;
-
-import android.app.Application;
-import android.arch.lifecycle.AndroidViewModel;
-import android.arch.lifecycle.LiveData;
-
-import java.util.List;
-
-public class SubscribedSubredditViewModel extends AndroidViewModel {
- private SubscribedSubredditRepository mSubscribedSubredditRepository;
- private LiveData<List<SubscribedSubredditData>> mAllSubscribedSubreddits;
-
- public SubscribedSubredditViewModel(Application application) {
- super(application);
- mSubscribedSubredditRepository = new SubscribedSubredditRepository(application);
- mAllSubscribedSubreddits = mSubscribedSubredditRepository.getAllSubscribedSubreddits();
- }
-
- public LiveData<List<SubscribedSubredditData>> getAllSubscribedSubreddits() {
- return mAllSubscribedSubreddits;
- }
-
- public void insert(SubscribedSubredditData subscribedSubredditData) {
- mSubscribedSubredditRepository.insert(subscribedSubredditData);
- }
-}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserDao.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserDao.java
deleted file mode 100644
index a2979dcd..00000000
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserDao.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package ml.docilealligator.infinityforreddit;
-
-import android.arch.lifecycle.LiveData;
-import android.arch.persistence.room.Dao;
-import android.arch.persistence.room.Insert;
-import android.arch.persistence.room.OnConflictStrategy;
-import android.arch.persistence.room.Query;
-
-import java.util.List;
-
-@Dao
-public interface SubscribedUserDao {
- @Insert(onConflict = OnConflictStrategy.REPLACE)
- void insert(SubscribedUserData subscribedUserData);
-
- @Query("DELETE FROM subscribed_users")
- void deleteAllSubscribedUsers();
-
- @Query("SELECT * from subscribed_users ORDER BY name COLLATE NOCASE ASC")
- LiveData<List<SubscribedUserData>> getAllSubscribedUsers();
-}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserData.java
deleted file mode 100644
index 9bf58700..00000000
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserData.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package ml.docilealligator.infinityforreddit;
-
-import android.arch.persistence.room.ColumnInfo;
-import android.arch.persistence.room.Entity;
-import android.arch.persistence.room.PrimaryKey;
-import android.support.annotation.NonNull;
-
-@Entity(tableName = "subscribed_users")
-class SubscribedUserData {
- @PrimaryKey
- @NonNull
- @ColumnInfo(name = "id")
- private String id;
- @ColumnInfo(name = "name")
- private String name;
- @ColumnInfo(name = "icon")
- private String iconUrl;
-
- SubscribedUserData(@NonNull String id, String name, String iconUrl) {
- this.id = id;
- this.name = name;
- this.iconUrl = iconUrl;
- }
-
- @NonNull
- public String getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public String getIconUrl() {
- return iconUrl;
- }
-}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserRecyclerViewAdapter.java
index e36dea17..013d75c1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserRecyclerViewAdapter.java
@@ -22,14 +22,15 @@ import com.felipecsl.gifimageview.library.GifImageView;
import java.util.List;
+import SubscribedUserDatabase.SubscribedUserData;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
-class SubscribedUserRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
+public class SubscribedUserRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private List<SubscribedUserData> mSubscribedUserData;
private RequestManager glide;
private OnItemClickListener mOnItemClickListener;
- interface OnItemClickListener {
+ public interface OnItemClickListener {
void onClick();
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserRepository.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserRepository.java
deleted file mode 100644
index 8dfc4204..00000000
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserRepository.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package ml.docilealligator.infinityforreddit;
-
-import android.app.Application;
-import android.arch.lifecycle.LiveData;
-import android.os.AsyncTask;
-
-import java.util.List;
-
-public class SubscribedUserRepository {
- private SubscribedUserDao mSubscribedUserDao;
- private LiveData<List<SubscribedUserData>> mAllSubscribedUsers;
-
- SubscribedUserRepository(Application application) {
- SubscribedUserRoomDatabase db = SubscribedUserRoomDatabase.getDatabase(application);
- mSubscribedUserDao = db.subscribedUserDao();
- mAllSubscribedUsers = mSubscribedUserDao.getAllSubscribedUsers();
- }
-
- LiveData<List<SubscribedUserData>> getAllSubscribedSubreddits() {
- return mAllSubscribedUsers;
- }
-
- public void insert(SubscribedUserData subscribedUserData) {
- new SubscribedUserRepository.insertAsyncTask(mSubscribedUserDao).execute(subscribedUserData);
- }
-
- private static class insertAsyncTask extends AsyncTask<SubscribedUserData, Void, Void> {
-
- private SubscribedUserDao mAsyncTaskDao;
-
- insertAsyncTask(SubscribedUserDao dao) {
- mAsyncTaskDao = dao;
- }
-
- @Override
- protected Void doInBackground(final SubscribedUserData... params) {
- mAsyncTaskDao.insert(params[0]);
- return null;
- }
- }
-}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserRoomDatabase.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserRoomDatabase.java
deleted file mode 100644
index 0f6575d7..00000000
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserRoomDatabase.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package ml.docilealligator.infinityforreddit;
-
-import android.arch.persistence.room.Database;
-import android.arch.persistence.room.Room;
-import android.arch.persistence.room.RoomDatabase;
-import android.content.Context;
-
-@Database(entities = {SubscribedUserData.class}, version = 1)
-public abstract class SubscribedUserRoomDatabase extends RoomDatabase {
- private static SubscribedUserRoomDatabase INSTANCE;
-
- public abstract SubscribedUserDao subscribedUserDao();
-
- public static SubscribedUserRoomDatabase getDatabase(final Context context) {
- if(INSTANCE == null) {
- synchronized (SubscribedUserRoomDatabase.class) {
- if(INSTANCE == null) {
- INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
- SubscribedUserRoomDatabase.class, "subscribed_users")
- .build();
- }
- }
- }
- return INSTANCE;
- }
-}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserViewModel.java
deleted file mode 100644
index 44e40fe5..00000000
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserViewModel.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package ml.docilealligator.infinityforreddit;
-
-import android.app.Application;
-import android.arch.lifecycle.AndroidViewModel;
-import android.arch.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);
- }
-}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java
index 6c8f209e..5140ac94 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java
@@ -42,6 +42,7 @@ import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
+import SubredditDatabase.SubredditRoomDatabase;
import butterknife.BindView;
import butterknife.ButterKnife;
import de.hdodenhof.circleimageview.CircleImageView;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java
index cc7bb742..1c63ffac 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java
@@ -33,6 +33,10 @@ import com.felipecsl.gifimageview.library.GifImageView;
import javax.inject.Inject;
import javax.inject.Named;
+import SubredditDatabase.SubredditDao;
+import SubredditDatabase.SubredditData;
+import SubredditDatabase.SubredditRoomDatabase;
+import SubredditDatabase.SubredditViewModel;
import butterknife.BindView;
import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;