From 119afb6084cbdc3f85889893281082a0640b56ee Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Fri, 31 Jan 2020 19:44:51 +0800 Subject: Fix unsubscribed subreddits and deleted multireddits still show in lists. --- .../Activity/MultiRedditListingActivity.java | 4 +- .../Adapter/CommentAndPostRecyclerViewAdapter.java | 12 --- .../MultiRedditListingRecyclerViewAdapter.java | 21 ++-- .../AsyncTask/InsertMultiRedditAsyncTask.java | 41 ++++++- .../AsyncTask/InsertSubscribedThingsAsyncTask.java | 118 +++++++++++++++++---- .../MultiReddit/FavoriteMultiReddit.java | 6 +- .../MultiReddit/MultiRedditDao.java | 6 ++ .../SubscribedSubredditDao.java | 3 + .../SubscribedUserDatabase/SubscribedUserDao.java | 3 + 9 files changed, 165 insertions(+), 49 deletions(-) (limited to 'app/src/main/java/ml') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java index a4d9d6d0..7acda3c9 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java @@ -183,7 +183,7 @@ public class MultiRedditListingActivity extends BaseActivity { mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); MultiRedditListingRecyclerViewAdapter adapter = new MultiRedditListingRecyclerViewAdapter(this, - mOauthRetrofit, mRedditDataRoomDatabase, mAccessToken); + mOauthRetrofit, mRedditDataRoomDatabase, mAccessToken, mAccountName); mRecyclerView.setAdapter(adapter); mMultiRedditViewModel = new ViewModelProvider(this, @@ -218,7 +218,7 @@ public class MultiRedditListingActivity extends BaseActivity { GetMultiReddit.getMyMultiReddits(mOauthRetrofit, mAccessToken, new GetMultiReddit.GetMultiRedditListener() { @Override public void success(ArrayList multiReddits) { - new InsertMultiRedditAsyncTask(mRedditDataRoomDatabase, multiReddits, () -> { + new InsertMultiRedditAsyncTask(mRedditDataRoomDatabase, multiReddits, mAccountName, () -> { mInsertSuccess = true; mSwipeRefreshLayout.setRefreshing(false); }).execute(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java index 9fd8ffc6..b58c87ee 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java @@ -1003,17 +1003,6 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter { - try { - Intent intent = new Intent(Intent.ACTION_SEND); - intent.setType("text/plain"); - intent.putExtra(Intent.EXTRA_TEXT, comment.getPermalink()); - mActivity.startActivity(Intent.createChooser(intent, mActivity.getString(R.string.share))); - } catch (ActivityNotFoundException e) { - Toast.makeText(mActivity, R.string.no_activity_found_for_share, Toast.LENGTH_SHORT).show(); - } - });*/ - ((CommentViewHolder) holder).expandButton.setOnClickListener(view -> { if (((CommentViewHolder) holder).expandButton.getVisibility() == View.VISIBLE) { int commentPosition = mIsSingleCommentThreadMode ? holder.getAdapterPosition() - 2 : holder.getAdapterPosition() - 1; @@ -1579,7 +1568,6 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter mMultiReddits; private List mFavoriteMultiReddits; public MultiRedditListingRecyclerViewAdapter(Context context, Retrofit oauthRetrofit, RedditDataRoomDatabase redditDataRoomDatabase, - String accessToken) { + String accessToken, String accountName) { mContext = context; mGlide = Glide.with(context.getApplicationContext()); mOauthRetrofit = oauthRetrofit; mRedditDataRoomDatabase = redditDataRoomDatabase; mAccessToken = accessToken; - + mAccountName = accountName; } @Override @@ -114,8 +115,8 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter< if(multiReddit.isFavorite()) { ((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp); multiReddit.setFavorite(false); - FavoriteMultiReddit.favoriteMultiReddit(mOauthRetrofit, mRedditDataRoomDatabase, mAccessToken, - false, multiReddit, + FavoriteMultiReddit.favoriteMultiReddit(mOauthRetrofit, mRedditDataRoomDatabase, + mAccessToken, mAccountName, false, multiReddit, new FavoriteMultiReddit.FavoriteMultiRedditListener() { @Override public void success() { @@ -140,8 +141,8 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter< } else { ((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp); multiReddit.setFavorite(true); - FavoriteMultiReddit.favoriteMultiReddit(mOauthRetrofit, mRedditDataRoomDatabase, mAccessToken, - true, multiReddit, + FavoriteMultiReddit.favoriteMultiReddit(mOauthRetrofit, mRedditDataRoomDatabase, + mAccessToken, mAccountName, true, multiReddit, new FavoriteMultiReddit.FavoriteMultiRedditListener() { @Override public void success() { @@ -197,8 +198,8 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter< if(multiReddit.isFavorite()) { ((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp); multiReddit.setFavorite(false); - FavoriteMultiReddit.favoriteMultiReddit(mOauthRetrofit, mRedditDataRoomDatabase, mAccessToken, - false, multiReddit, + FavoriteMultiReddit.favoriteMultiReddit(mOauthRetrofit, mRedditDataRoomDatabase, + mAccessToken, mAccountName, false, multiReddit, new FavoriteMultiReddit.FavoriteMultiRedditListener() { @Override public void success() { @@ -223,8 +224,8 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter< } else { ((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp); multiReddit.setFavorite(true); - FavoriteMultiReddit.favoriteMultiReddit(mOauthRetrofit, mRedditDataRoomDatabase, mAccessToken, - true, multiReddit, + FavoriteMultiReddit.favoriteMultiReddit(mOauthRetrofit, mRedditDataRoomDatabase, + mAccessToken, mAccountName, true, multiReddit, new FavoriteMultiReddit.FavoriteMultiRedditListener() { @Override public void success() { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertMultiRedditAsyncTask.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertMultiRedditAsyncTask.java index 22613362..91d72ae1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertMultiRedditAsyncTask.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertMultiRedditAsyncTask.java @@ -3,6 +3,8 @@ package ml.docilealligator.infinityforreddit.AsyncTask; import android.os.AsyncTask; import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import ml.docilealligator.infinityforreddit.MultiReddit.MultiReddit; import ml.docilealligator.infinityforreddit.MultiReddit.MultiRedditDao; @@ -11,18 +13,29 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; public class InsertMultiRedditAsyncTask extends AsyncTask { private MultiRedditDao multiRedditDao; private ArrayList multiReddits; + private String accountName; private InsertMultiRedditAsyncTaskListener insertMultiRedditAsyncTaskListener; public InsertMultiRedditAsyncTask(RedditDataRoomDatabase redditDataRoomDatabase, - ArrayList multiReddits, + ArrayList multiReddits, String accountName, InsertMultiRedditAsyncTaskListener insertMultiRedditAsyncTaskListener) { multiRedditDao = redditDataRoomDatabase.multiRedditDao(); this.multiReddits = multiReddits; + this.accountName = accountName; this.insertMultiRedditAsyncTaskListener = insertMultiRedditAsyncTaskListener; } @Override protected Void doInBackground(Void... voids) { + List existingMultiReddits = multiRedditDao.getAllMultiRedditsList(accountName); + Collections.sort(multiReddits, (multiReddit, t1) -> multiReddit.getName().compareToIgnoreCase(t1.getName())); + List deletedMultiredditNames = new ArrayList<>(); + compareTwoMultiRedditList(multiReddits, existingMultiReddits, deletedMultiredditNames, 0, 0); + + for (String deleted : deletedMultiredditNames) { + multiRedditDao.deleteMultiReddit(deleted, accountName); + } + for (MultiReddit multiReddit : multiReddits) { multiRedditDao.insert(multiReddit); } @@ -35,6 +48,32 @@ public class InsertMultiRedditAsyncTask extends AsyncTask { insertMultiRedditAsyncTaskListener.success(); } + private void compareTwoMultiRedditList(List newMultiReddits, + List oldMultiReddits, + List deletedMultiReddits, int i1, int i2) { + if (newMultiReddits.size() <= i1 && oldMultiReddits.size() <= i2) { + return; + } + + if (newMultiReddits.size() <= i1) { + for (int i = 0; i < oldMultiReddits.size(); i++) { + deletedMultiReddits.add(oldMultiReddits.get(i).getName()); + } + return; + } + + if (oldMultiReddits.size() > i2) { + if (newMultiReddits.get(i1).getName().compareToIgnoreCase(oldMultiReddits.get(i2).getName()) == 0) { + compareTwoMultiRedditList(newMultiReddits, oldMultiReddits, deletedMultiReddits, i1 + 1, i2 + 1); + } else if (newMultiReddits.get(i1).getName().compareToIgnoreCase(oldMultiReddits.get(i2).getName()) < 0) { + compareTwoMultiRedditList(newMultiReddits, oldMultiReddits, deletedMultiReddits, i1 + 1, i2); + } else { + deletedMultiReddits.add(oldMultiReddits.get(i2).getName()); + compareTwoMultiRedditList(newMultiReddits, oldMultiReddits, deletedMultiReddits, i1, i2 + 1); + } + } + } + public interface InsertMultiRedditAsyncTaskListener { void success(); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertSubscribedThingsAsyncTask.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertSubscribedThingsAsyncTask.java index 00c6c3e7..a1ea1b68 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertSubscribedThingsAsyncTask.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertSubscribedThingsAsyncTask.java @@ -4,6 +4,8 @@ import android.os.AsyncTask; import androidx.annotation.Nullable; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; @@ -23,15 +25,15 @@ public class InsertSubscribedThingsAsyncTask extends AsyncTask private SubredditDao mSubredditDao; private SubscribedSubredditData mSingleSubscribedSubredditData; private SubscribedUserData mSingleSubscribedUserData; - private List subscribedSubredditData; - private List subscribedUserData; - private List subredditData; + private List subscribedSubredditDataList; + private List subscribedUserDataList; + private List subredditDataList; private InsertSubscribedThingListener mInsertSubscribedThingListener; public InsertSubscribedThingsAsyncTask(RedditDataRoomDatabase redditDataRoomDatabase, @Nullable String accountName, - List subscribedSubredditData, - List subscribedUserData, - List subredditData, + List subscribedSubredditDataList, + List subscribedUserDataList, + List subredditDataList, InsertSubscribedThingListener insertSubscribedThingListener) { mRedditDataRoomDatabase = redditDataRoomDatabase; mAccountName = accountName; @@ -39,29 +41,29 @@ public class InsertSubscribedThingsAsyncTask extends AsyncTask mSubscribedUserDao = redditDataRoomDatabase.subscribedUserDao(); mSubredditDao = redditDataRoomDatabase.subredditDao(); - this.subscribedSubredditData = subscribedSubredditData; - this.subscribedUserData = subscribedUserData; - this.subredditData = subredditData; + this.subscribedSubredditDataList = subscribedSubredditDataList; + this.subscribedUserDataList = subscribedUserDataList; + this.subredditDataList = subredditDataList; mInsertSubscribedThingListener = insertSubscribedThingListener; } public InsertSubscribedThingsAsyncTask(RedditDataRoomDatabase redditDataRoomDatabase, - SubscribedSubredditData subscribedSubredditData, + SubscribedSubredditData subscribedSubredditDataList, InsertSubscribedThingListener insertSubscribedThingListener) { mRedditDataRoomDatabase = redditDataRoomDatabase; mSubscribedSubredditDao = redditDataRoomDatabase.subscribedSubredditDao(); - mAccountName = subscribedSubredditData.getUsername(); - mSingleSubscribedSubredditData = subscribedSubredditData; + mAccountName = subscribedSubredditDataList.getUsername(); + mSingleSubscribedSubredditData = subscribedSubredditDataList; mInsertSubscribedThingListener = insertSubscribedThingListener; } public InsertSubscribedThingsAsyncTask(RedditDataRoomDatabase redditDataRoomDatabase, - SubscribedUserData subscribedUserData, + SubscribedUserData subscribedUserDataList, InsertSubscribedThingListener insertSubscribedThingListener) { mRedditDataRoomDatabase = redditDataRoomDatabase; mSubscribedUserDao = redditDataRoomDatabase.subscribedUserDao(); - mAccountName = subscribedUserData.getUsername(); - mSingleSubscribedUserData = subscribedUserData; + mAccountName = subscribedUserDataList.getUsername(); + mSingleSubscribedUserData = subscribedUserDataList; mInsertSubscribedThingListener = insertSubscribedThingListener; } @@ -76,20 +78,42 @@ public class InsertSubscribedThingsAsyncTask extends AsyncTask } else if (mSingleSubscribedUserData != null) { mSubscribedUserDao.insert(mSingleSubscribedUserData); } else { - if (subscribedSubredditData != null) { - for (SubscribedSubredditData s : subscribedSubredditData) { + if (subscribedSubredditDataList != null) { + List existingSubscribedSubredditDataList = + mSubscribedSubredditDao.getAllSubscribedSubredditsList(mAccountName); + Collections.sort(subscribedSubredditDataList, (subscribedSubredditData, t1) -> subscribedSubredditData.getName().compareToIgnoreCase(t1.getName())); + List unsubscribedSubreddits = new ArrayList<>(); + compareTwoSubscribedSubredditList(subscribedSubredditDataList, existingSubscribedSubredditDataList, + unsubscribedSubreddits, 0, 0); + + for (String unsubscribed : unsubscribedSubreddits) { + mSubscribedSubredditDao.deleteSubscribedSubreddit(unsubscribed, mAccountName); + } + + for (SubscribedSubredditData s : subscribedSubredditDataList) { mSubscribedSubredditDao.insert(s); } } - if (subscribedUserData != null) { - for (SubscribedUserData s : subscribedUserData) { + if (subscribedUserDataList != null) { + List existingSubscribedUserDataList = + mSubscribedUserDao.getAllSubscribedUsersList(mAccountName); + Collections.sort(subscribedUserDataList, (subscribedUserData, t1) -> subscribedUserData.getName().compareToIgnoreCase(t1.getName())); + List unsubscribedUsers = new ArrayList<>(); + compareTwoSubscribedUserList(subscribedUserDataList, existingSubscribedUserDataList, + unsubscribedUsers, 0, 0); + + for (String unsubscribed : unsubscribedUsers) { + mSubscribedUserDao.deleteSubscribedUser(unsubscribed, mAccountName); + } + + for (SubscribedUserData s : subscribedUserDataList) { mSubscribedUserDao.insert(s); } } - if (subredditData != null) { - for (SubredditData s : subredditData) { + if (subredditDataList != null) { + for (SubredditData s : subredditDataList) { mSubredditDao.insert(s); } } @@ -102,6 +126,58 @@ public class InsertSubscribedThingsAsyncTask extends AsyncTask mInsertSubscribedThingListener.insertSuccess(); } + private void compareTwoSubscribedSubredditList(List newSubscribedSubreddits, + List oldSubscribedSubreddits, + List unsubscribedSubredditNames, int i1, int i2) { + if (newSubscribedSubreddits.size() <= i1 && oldSubscribedSubreddits.size() <= i2) { + return; + } + + if (newSubscribedSubreddits.size() <= i1) { + for (int i = 0; i < oldSubscribedSubreddits.size(); i++) { + unsubscribedSubredditNames.add(oldSubscribedSubreddits.get(i).getName()); + } + return; + } + + if (oldSubscribedSubreddits.size() > i2) { + if (newSubscribedSubreddits.get(i1).getName().compareToIgnoreCase(oldSubscribedSubreddits.get(i2).getName()) == 0) { + compareTwoSubscribedSubredditList(newSubscribedSubreddits, oldSubscribedSubreddits, unsubscribedSubredditNames, i1 + 1, i2 + 1); + } else if (newSubscribedSubreddits.get(i1).getName().compareToIgnoreCase(oldSubscribedSubreddits.get(i2).getName()) < 0) { + compareTwoSubscribedSubredditList(newSubscribedSubreddits, oldSubscribedSubreddits, unsubscribedSubredditNames, i1 + 1, i2); + } else { + unsubscribedSubredditNames.add(oldSubscribedSubreddits.get(i2).getName()); + compareTwoSubscribedSubredditList(newSubscribedSubreddits, oldSubscribedSubreddits, unsubscribedSubredditNames, i1, i2 + 1); + } + } + } + + private void compareTwoSubscribedUserList(List newSubscribedUsers, + List oldSubscribedUsers, + List unsubscribedUserNames, int i1, int i2) { + if (newSubscribedUsers.size() <= i1 && oldSubscribedUsers.size() <= i2) { + return; + } + + if (newSubscribedUsers.size() <= i1) { + for (int i = 0; i < oldSubscribedUsers.size(); i++) { + unsubscribedUserNames.add(oldSubscribedUsers.get(i).getName()); + } + return; + } + + if (oldSubscribedUsers.size() > i2) { + if (newSubscribedUsers.get(i1).getName().compareToIgnoreCase(oldSubscribedUsers.get(i2).getName()) == 0) { + compareTwoSubscribedUserList(newSubscribedUsers, oldSubscribedUsers, unsubscribedUserNames, i1 + 1, i2 + 1); + } else if (newSubscribedUsers.get(i1).getName().compareToIgnoreCase(oldSubscribedUsers.get(i2).getName()) < 0) { + compareTwoSubscribedUserList(newSubscribedUsers, oldSubscribedUsers, unsubscribedUserNames, i1 + 1, i2); + } else { + unsubscribedUserNames.add(oldSubscribedUsers.get(i2).getName()); + compareTwoSubscribedUserList(newSubscribedUsers, oldSubscribedUsers, unsubscribedUserNames, i1, i2 + 1); + } + } + } + public interface InsertSubscribedThingListener { void insertSuccess(); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MultiReddit/FavoriteMultiReddit.java b/app/src/main/java/ml/docilealligator/infinityforreddit/MultiReddit/FavoriteMultiReddit.java index d05e917b..8c7a8947 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/MultiReddit/FavoriteMultiReddit.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/MultiReddit/FavoriteMultiReddit.java @@ -22,8 +22,8 @@ public class FavoriteMultiReddit { } public static void favoriteMultiReddit(Retrofit oauthRetrofit, RedditDataRoomDatabase redditDataRoomDatabase, - String accessToken, boolean makeFavorite, MultiReddit multiReddit, - FavoriteMultiRedditListener favoriteMultiRedditListener) { + String accessToken, String accountName, boolean makeFavorite, + MultiReddit multiReddit, FavoriteMultiRedditListener favoriteMultiRedditListener) { Map params = new HashMap<>(); params.put(RedditUtils.MULTIPATH_KEY, multiReddit.getPath()); params.put(RedditUtils.MAKE_FAVORITE_KEY, String.valueOf(makeFavorite)); @@ -36,7 +36,7 @@ public class FavoriteMultiReddit { multiReddit.setFavorite(true); ArrayList singleMultiRedditList = new ArrayList<>(); singleMultiRedditList.add(multiReddit); - new InsertMultiRedditAsyncTask(redditDataRoomDatabase, singleMultiRedditList, + new InsertMultiRedditAsyncTask(redditDataRoomDatabase, singleMultiRedditList, accountName, favoriteMultiRedditListener::success).execute(); } else { favoriteMultiRedditListener.failed(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MultiReddit/MultiRedditDao.java b/app/src/main/java/ml/docilealligator/infinityforreddit/MultiReddit/MultiRedditDao.java index 1e72966d..7d3654c8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/MultiReddit/MultiRedditDao.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/MultiReddit/MultiRedditDao.java @@ -16,6 +16,9 @@ public interface MultiRedditDao { @Query("SELECT * FROM multi_reddits WHERE username = :username ORDER BY name COLLATE NOCASE ASC") LiveData> getAllMultiReddits(String username); + @Query("SELECT * FROM multi_reddits WHERE username = :username ORDER BY name COLLATE NOCASE ASC") + List getAllMultiRedditsList(String username); + @Query("SELECT * FROM multi_reddits WHERE username = :username AND is_favorite ORDER BY name COLLATE NOCASE ASC") LiveData> getAllFavoriteMultiReddits(String username); @@ -24,4 +27,7 @@ public interface MultiRedditDao { @Query("DELETE FROM multi_reddits WHERE name = :name AND username = :username") void deleteMultiReddit(String name, String username); + + @Query("DELETE FROM multi_reddits WHERE username = :username") + void deleteAllUserMultiReddits(String username); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditDatabase/SubscribedSubredditDao.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditDatabase/SubscribedSubredditDao.java index 6bfa103e..cc0434d7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditDatabase/SubscribedSubredditDao.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditDatabase/SubscribedSubredditDao.java @@ -19,6 +19,9 @@ public interface SubscribedSubredditDao { @Query("SELECT * from subscribed_subreddits WHERE username = :accountName ORDER BY name COLLATE NOCASE ASC") LiveData> getAllSubscribedSubreddits(String accountName); + @Query("SELECT * from subscribed_subreddits WHERE username = :accountName ORDER BY name COLLATE NOCASE ASC") + List getAllSubscribedSubredditsList(String accountName); + @Query("SELECT * from subscribed_subreddits WHERE username = :accountName AND is_favorite = 1 ORDER BY name COLLATE NOCASE ASC") LiveData> getAllFavoriteSubscribedSubreddits(String accountName); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserDatabase/SubscribedUserDao.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserDatabase/SubscribedUserDao.java index c085f298..661eb988 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserDatabase/SubscribedUserDao.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserDatabase/SubscribedUserDao.java @@ -16,6 +16,9 @@ public interface SubscribedUserDao { @Query("SELECT * FROM subscribed_users WHERE username = :accountName ORDER BY name COLLATE NOCASE ASC") LiveData> getAllSubscribedUsers(String accountName); + @Query("SELECT * FROM subscribed_users WHERE username = :accountName ORDER BY name COLLATE NOCASE ASC") + List getAllSubscribedUsersList(String accountName); + @Query("SELECT * FROM subscribed_users WHERE username = :accountName AND is_favorite = 1 ORDER BY name COLLATE NOCASE ASC") LiveData> getAllFavoriteSubscribedUsers(String accountName); -- cgit v1.2.3