mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-29 04:17:12 +01:00
Only save read post ids in PostFragment. Add read post ids to readPosts in PostFragment.
This commit is contained in:
parent
d6c3bfddd7
commit
cc9952525b
@ -12,7 +12,7 @@ import ml.docilealligator.infinityforreddit.subscribedsubreddit.SubscribedSubred
|
|||||||
|
|
||||||
public class FetchPostFilterReadPostsAndConcatenatedSubredditNames {
|
public class FetchPostFilterReadPostsAndConcatenatedSubredditNames {
|
||||||
public interface FetchPostFilterAndReadPostsListener {
|
public interface FetchPostFilterAndReadPostsListener {
|
||||||
void success(PostFilter postFilter, ArrayList<ReadPost> readPostList);
|
void success(PostFilter postFilter, ArrayList<String> readPostList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface FetchPostFilterAndConcatenatecSubredditNamesListener {
|
public interface FetchPostFilterAndConcatenatecSubredditNamesListener {
|
||||||
@ -26,8 +26,12 @@ public class FetchPostFilterReadPostsAndConcatenatedSubredditNames {
|
|||||||
List<PostFilter> postFilters = redditDataRoomDatabase.postFilterDao().getValidPostFilters(postFilterUsage, nameOfUsage);
|
List<PostFilter> postFilters = redditDataRoomDatabase.postFilterDao().getValidPostFilters(postFilterUsage, nameOfUsage);
|
||||||
PostFilter mergedPostFilter = PostFilter.mergePostFilter(postFilters);
|
PostFilter mergedPostFilter = PostFilter.mergePostFilter(postFilters);
|
||||||
if (accountName != null) {
|
if (accountName != null) {
|
||||||
ArrayList<ReadPost> readPosts = (ArrayList<ReadPost>) redditDataRoomDatabase.readPostDao().getAllReadPosts(accountName);
|
List<ReadPost> readPosts = redditDataRoomDatabase.readPostDao().getAllReadPosts(accountName);
|
||||||
handler.post(() -> fetchPostFilterAndReadPostsListener.success(mergedPostFilter, readPosts));
|
ArrayList<String> readPostStrings = new ArrayList<>();
|
||||||
|
for (ReadPost readPost : readPosts) {
|
||||||
|
readPostStrings.add(readPost.getId());
|
||||||
|
}
|
||||||
|
handler.post(() -> fetchPostFilterAndReadPostsListener.success(mergedPostFilter, readPostStrings));
|
||||||
} else {
|
} else {
|
||||||
handler.post(() -> fetchPostFilterAndReadPostsListener.success(mergedPostFilter, null));
|
handler.post(() -> fetchPostFilterAndReadPostsListener.success(mergedPostFilter, null));
|
||||||
}
|
}
|
||||||
|
@ -314,6 +314,14 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
viewPager2.setCurrentItem(getIntent().getIntExtra(EXTRA_POST_LIST_POSITION, 0), false);
|
viewPager2.setCurrentItem(getIntent().getIntExtra(EXTRA_POST_LIST_POSITION, 0), false);
|
||||||
}
|
}
|
||||||
|
if (mSharedPreferences.getBoolean(mAccountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, false)) {
|
||||||
|
viewPager2.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
|
||||||
|
@Override
|
||||||
|
public void onPageSelected(int position) {
|
||||||
|
//EventBus.getDefault().post(new (getClass().getName()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
searchPanelMaterialCardView.setOnClickListener(null);
|
searchPanelMaterialCardView.setOnClickListener(null);
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package ml.docilealligator.infinityforreddit.adapters;
|
package ml.docilealligator.infinityforreddit.adapters;
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -60,12 +59,9 @@ public class Paging3LoadingStateAdapter extends LoadStateAdapter<Paging3LoadingS
|
|||||||
mRetry.setTextColor(mCustomThemeWrapper.getButtonTextColor());
|
mRetry.setTextColor(mCustomThemeWrapper.getButtonTextColor());
|
||||||
mRetry.setOnClickListener(retryCallback);
|
mRetry.setOnClickListener(retryCallback);
|
||||||
mErrorView.setOnClickListener(retryCallback);
|
mErrorView.setOnClickListener(retryCallback);
|
||||||
|
|
||||||
Log.i("asfasdf", "asdf ");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bind(LoadState loadState) {
|
public void bind(LoadState loadState) {
|
||||||
Log.i("asfasdf", "asdf bind");
|
|
||||||
mProgressBar.setVisibility(loadState instanceof LoadState.Loading
|
mProgressBar.setVisibility(loadState instanceof LoadState.Loading
|
||||||
? View.VISIBLE : View.GONE);
|
? View.VISIBLE : View.GONE);
|
||||||
mErrorView.setVisibility(loadState instanceof LoadState.Error
|
mErrorView.setVisibility(loadState instanceof LoadState.Error
|
||||||
|
@ -2574,6 +2574,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
}
|
}
|
||||||
if (mActivity != null && mActivity instanceof MarkPostAsReadInterface) {
|
if (mActivity != null && mActivity instanceof MarkPostAsReadInterface) {
|
||||||
((MarkPostAsReadInterface) mActivity).markPostAsRead(post);
|
((MarkPostAsReadInterface) mActivity).markPostAsRead(post);
|
||||||
|
mFragment.markPostAsRead(post);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3560,6 +3561,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
}
|
}
|
||||||
if (mActivity != null && mActivity instanceof MarkPostAsReadInterface) {
|
if (mActivity != null && mActivity instanceof MarkPostAsReadInterface) {
|
||||||
((MarkPostAsReadInterface) mActivity).markPostAsRead(post);
|
((MarkPostAsReadInterface) mActivity).markPostAsRead(post);
|
||||||
|
mFragment.markPostAsRead(post);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3796,6 +3798,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
}
|
}
|
||||||
if (mActivity != null && mActivity instanceof MarkPostAsReadInterface) {
|
if (mActivity != null && mActivity instanceof MarkPostAsReadInterface) {
|
||||||
((MarkPostAsReadInterface) mActivity).markPostAsRead(post);
|
((MarkPostAsReadInterface) mActivity).markPostAsRead(post);
|
||||||
|
mFragment.markPostAsRead(post);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,6 @@ import ml.docilealligator.infinityforreddit.post.PostPagingSource;
|
|||||||
import ml.docilealligator.infinityforreddit.post.PostViewModel;
|
import ml.docilealligator.infinityforreddit.post.PostViewModel;
|
||||||
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
|
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
|
||||||
import ml.docilealligator.infinityforreddit.postfilter.PostFilterUsage;
|
import ml.docilealligator.infinityforreddit.postfilter.PostFilterUsage;
|
||||||
import ml.docilealligator.infinityforreddit.readpost.ReadPost;
|
|
||||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||||
import ml.docilealligator.infinityforreddit.utils.Utils;
|
import ml.docilealligator.infinityforreddit.utils.Utils;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
@ -248,7 +247,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
private boolean vibrateWhenActionTriggered;
|
private boolean vibrateWhenActionTriggered;
|
||||||
private float swipeActionThreshold;
|
private float swipeActionThreshold;
|
||||||
private ItemTouchHelper touchHelper;
|
private ItemTouchHelper touchHelper;
|
||||||
private ArrayList<ReadPost> readPosts;
|
private ArrayList<String> readPosts;
|
||||||
private Unbinder unbinder;
|
private Unbinder unbinder;
|
||||||
private Map<String, String> subredditOrUserIcons = new HashMap<>();
|
private Map<String, String> subredditOrUserIcons = new HashMap<>();
|
||||||
|
|
||||||
@ -390,7 +389,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
recyclerViewPosition = savedInstanceState.getInt(RECYCLER_VIEW_POSITION_STATE);
|
recyclerViewPosition = savedInstanceState.getInt(RECYCLER_VIEW_POSITION_STATE);
|
||||||
|
|
||||||
isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
|
isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
|
||||||
readPosts = savedInstanceState.getParcelableArrayList(READ_POST_LIST_STATE);
|
readPosts = savedInstanceState.getStringArrayList(READ_POST_LIST_STATE);
|
||||||
postFilter = savedInstanceState.getParcelable(POST_FILTER_STATE);
|
postFilter = savedInstanceState.getParcelable(POST_FILTER_STATE);
|
||||||
concatenatedSubredditNames = savedInstanceState.getString(CONCATENATED_SUBREDDIT_NAMES_STATE);
|
concatenatedSubredditNames = savedInstanceState.getString(CONCATENATED_SUBREDDIT_NAMES_STATE);
|
||||||
postFragmentId = savedInstanceState.getLong(POST_FRAGMENT_ID_STATE);
|
postFragmentId = savedInstanceState.getLong(POST_FRAGMENT_ID_STATE);
|
||||||
@ -1264,7 +1263,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
outState.putBoolean(IS_IN_LAZY_MODE_STATE, isInLazyMode);
|
outState.putBoolean(IS_IN_LAZY_MODE_STATE, isInLazyMode);
|
||||||
outState.putParcelableArrayList(READ_POST_LIST_STATE, readPosts);
|
outState.putStringArrayList(READ_POST_LIST_STATE, readPosts);
|
||||||
if (mLinearLayoutManager != null) {
|
if (mLinearLayoutManager != null) {
|
||||||
outState.putInt(RECYCLER_VIEW_POSITION_STATE, mLinearLayoutManager.findFirstVisibleItemPosition());
|
outState.putInt(RECYCLER_VIEW_POSITION_STATE, mLinearLayoutManager.findFirstVisibleItemPosition());
|
||||||
} else if (mStaggeredGridLayoutManager != null) {
|
} else if (mStaggeredGridLayoutManager != null) {
|
||||||
@ -1561,6 +1560,10 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void markPostAsRead(Post post) {
|
||||||
|
readPosts.add(post.getId());
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onPostUpdateEvent(PostUpdateEventToPostList event) {
|
public void onPostUpdateEvent(PostUpdateEventToPostList event) {
|
||||||
ItemSnapshotList<Post> posts = mAdapter.snapshot();
|
ItemSnapshotList<Post> posts = mAdapter.snapshot();
|
||||||
|
@ -17,7 +17,6 @@ import java.util.regex.Matcher;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
|
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
|
||||||
import ml.docilealligator.infinityforreddit.readpost.ReadPost;
|
|
||||||
import ml.docilealligator.infinityforreddit.utils.JSONUtils;
|
import ml.docilealligator.infinityforreddit.utils.JSONUtils;
|
||||||
import ml.docilealligator.infinityforreddit.utils.Utils;
|
import ml.docilealligator.infinityforreddit.utils.Utils;
|
||||||
|
|
||||||
@ -26,54 +25,7 @@ import ml.docilealligator.infinityforreddit.utils.Utils;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public class ParsePost {
|
public class ParsePost {
|
||||||
public static void parsePosts(Executor executor, Handler handler, String response, int nPosts,
|
public static LinkedHashSet<Post> parsePostsSync(String response, int nPosts, PostFilter postFilter, List<String> readPostList) {
|
||||||
PostFilter postFilter, List<ReadPost> readPostList,
|
|
||||||
ParsePostsListingListener parsePostsListingListener) {
|
|
||||||
executor.execute(() -> {
|
|
||||||
LinkedHashSet<Post> newPosts = new LinkedHashSet<>();
|
|
||||||
try {
|
|
||||||
JSONObject jsonResponse = new JSONObject(response);
|
|
||||||
JSONArray allData = jsonResponse.getJSONObject(JSONUtils.DATA_KEY).getJSONArray(JSONUtils.CHILDREN_KEY);
|
|
||||||
String lastItem = jsonResponse.getJSONObject(JSONUtils.DATA_KEY).getString(JSONUtils.AFTER_KEY);
|
|
||||||
|
|
||||||
//Posts listing
|
|
||||||
int size;
|
|
||||||
if (nPosts < 0 || nPosts > allData.length()) {
|
|
||||||
size = allData.length();
|
|
||||||
} else {
|
|
||||||
size = nPosts;
|
|
||||||
}
|
|
||||||
|
|
||||||
HashSet<ReadPost> readPostHashSet = null;
|
|
||||||
if (readPostList != null) {
|
|
||||||
readPostHashSet = new HashSet<>(readPostList);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
try {
|
|
||||||
if (allData.getJSONObject(i).getString(JSONUtils.KIND_KEY).equals("t3")) {
|
|
||||||
JSONObject data = allData.getJSONObject(i).getJSONObject(JSONUtils.DATA_KEY);
|
|
||||||
Post post = parseBasicData(data);
|
|
||||||
if (readPostHashSet != null && readPostHashSet.contains(ReadPost.convertPost(post))) {
|
|
||||||
post.markAsRead(false);
|
|
||||||
}
|
|
||||||
if (PostFilter.isPostAllowed(post, postFilter)) {
|
|
||||||
newPosts.add(post);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handler.post(() -> parsePostsListingListener.onParsePostsListingSuccess(newPosts, lastItem));
|
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
handler.post(parsePostsListingListener::onParsePostsListingFail);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LinkedHashSet<Post> parsePostsSync(String response, int nPosts, PostFilter postFilter, List<ReadPost> readPostList) {
|
|
||||||
LinkedHashSet<Post> newPosts = new LinkedHashSet<>();
|
LinkedHashSet<Post> newPosts = new LinkedHashSet<>();
|
||||||
try {
|
try {
|
||||||
JSONObject jsonResponse = new JSONObject(response);
|
JSONObject jsonResponse = new JSONObject(response);
|
||||||
@ -87,7 +39,7 @@ public class ParsePost {
|
|||||||
size = nPosts;
|
size = nPosts;
|
||||||
}
|
}
|
||||||
|
|
||||||
HashSet<ReadPost> readPostHashSet = null;
|
HashSet<String> readPostHashSet = null;
|
||||||
if (readPostList != null) {
|
if (readPostList != null) {
|
||||||
readPostHashSet = new HashSet<>(readPostList);
|
readPostHashSet = new HashSet<>(readPostList);
|
||||||
}
|
}
|
||||||
@ -96,7 +48,7 @@ public class ParsePost {
|
|||||||
if (allData.getJSONObject(i).getString(JSONUtils.KIND_KEY).equals("t3")) {
|
if (allData.getJSONObject(i).getString(JSONUtils.KIND_KEY).equals("t3")) {
|
||||||
JSONObject data = allData.getJSONObject(i).getJSONObject(JSONUtils.DATA_KEY);
|
JSONObject data = allData.getJSONObject(i).getJSONObject(JSONUtils.DATA_KEY);
|
||||||
Post post = parseBasicData(data);
|
Post post = parseBasicData(data);
|
||||||
if (readPostHashSet != null && readPostHashSet.contains(ReadPost.convertPost(post))) {
|
if (readPostHashSet != null && readPostHashSet.contains(post.getId())) {
|
||||||
post.markAsRead(false);
|
post.markAsRead(false);
|
||||||
}
|
}
|
||||||
if (PostFilter.isPostAllowed(post, postFilter)) {
|
if (PostFilter.isPostAllowed(post, postFilter)) {
|
||||||
|
@ -54,7 +54,7 @@ public class PostPagingSource extends ListenableFuturePagingSource<String, Post>
|
|||||||
private int postType;
|
private int postType;
|
||||||
private SortType sortType;
|
private SortType sortType;
|
||||||
private PostFilter postFilter;
|
private PostFilter postFilter;
|
||||||
private List<ReadPost> readPostList;
|
private List<String> readPostList;
|
||||||
private String userWhere;
|
private String userWhere;
|
||||||
private String multiRedditPath;
|
private String multiRedditPath;
|
||||||
private LinkedHashSet<Post> postLinkedHashSet;
|
private LinkedHashSet<Post> postLinkedHashSet;
|
||||||
@ -62,7 +62,7 @@ public class PostPagingSource extends ListenableFuturePagingSource<String, Post>
|
|||||||
PostPagingSource(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
PostPagingSource(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
||||||
SharedPreferences sharedPreferences,
|
SharedPreferences sharedPreferences,
|
||||||
SharedPreferences postFeedScrolledPositionSharedPreferences, int postType,
|
SharedPreferences postFeedScrolledPositionSharedPreferences, int postType,
|
||||||
SortType sortType, PostFilter postFilter, List<ReadPost> readPostList) {
|
SortType sortType, PostFilter postFilter, List<String> readPostList) {
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
this.retrofit = retrofit;
|
this.retrofit = retrofit;
|
||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
@ -79,7 +79,7 @@ public class PostPagingSource extends ListenableFuturePagingSource<String, Post>
|
|||||||
PostPagingSource(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
PostPagingSource(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
||||||
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
||||||
String path, int postType, SortType sortType, PostFilter postFilter,
|
String path, int postType, SortType sortType, PostFilter postFilter,
|
||||||
List<ReadPost> readPostList) {
|
List<String> readPostList) {
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
this.retrofit = retrofit;
|
this.retrofit = retrofit;
|
||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
@ -117,7 +117,7 @@ public class PostPagingSource extends ListenableFuturePagingSource<String, Post>
|
|||||||
PostPagingSource(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
PostPagingSource(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
||||||
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
||||||
String subredditOrUserName, int postType, SortType sortType, PostFilter postFilter,
|
String subredditOrUserName, int postType, SortType sortType, PostFilter postFilter,
|
||||||
String where, List<ReadPost> readPostList) {
|
String where, List<String> readPostList) {
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
this.retrofit = retrofit;
|
this.retrofit = retrofit;
|
||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
@ -136,7 +136,7 @@ public class PostPagingSource extends ListenableFuturePagingSource<String, Post>
|
|||||||
PostPagingSource(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
PostPagingSource(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
||||||
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
||||||
String subredditOrUserName, String query, String trendingSource, int postType,
|
String subredditOrUserName, String query, String trendingSource, int postType,
|
||||||
SortType sortType, PostFilter postFilter, List<ReadPost> readPostList) {
|
SortType sortType, PostFilter postFilter, List<String> readPostList) {
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
this.retrofit = retrofit;
|
this.retrofit = retrofit;
|
||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
|
@ -23,7 +23,6 @@ import java.util.concurrent.Executor;
|
|||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.SortType;
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
|
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
|
||||||
import ml.docilealligator.infinityforreddit.readpost.ReadPost;
|
|
||||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
@ -41,7 +40,7 @@ public class PostViewModel extends ViewModel {
|
|||||||
private SortType sortType;
|
private SortType sortType;
|
||||||
private PostFilter postFilter;
|
private PostFilter postFilter;
|
||||||
private String userWhere;
|
private String userWhere;
|
||||||
private List<ReadPost> readPostList;
|
private List<String> readPostList;
|
||||||
private MutableLiveData<Boolean> currentlyReadPostIdsLiveData = new MutableLiveData<>();
|
private MutableLiveData<Boolean> currentlyReadPostIdsLiveData = new MutableLiveData<>();
|
||||||
|
|
||||||
private LiveData<PagingData<Post>> posts;
|
private LiveData<PagingData<Post>> posts;
|
||||||
@ -54,7 +53,7 @@ public class PostViewModel extends ViewModel {
|
|||||||
public PostViewModel(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
public PostViewModel(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
||||||
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
||||||
@Nullable SharedPreferences postHistorySharedPreferences, int postType,
|
@Nullable SharedPreferences postHistorySharedPreferences, int postType,
|
||||||
SortType sortType, PostFilter postFilter, List<ReadPost> readPostList) {
|
SortType sortType, PostFilter postFilter, List<String> readPostList) {
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
this.retrofit = retrofit;
|
this.retrofit = retrofit;
|
||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
@ -95,7 +94,7 @@ public class PostViewModel extends ViewModel {
|
|||||||
public PostViewModel(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
public PostViewModel(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
||||||
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
||||||
@Nullable SharedPreferences postHistorySharedPreferences, String subredditName, int postType,
|
@Nullable SharedPreferences postHistorySharedPreferences, String subredditName, int postType,
|
||||||
SortType sortType, PostFilter postFilter, List<ReadPost> readPostList) {
|
SortType sortType, PostFilter postFilter, List<String> readPostList) {
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
this.retrofit = retrofit;
|
this.retrofit = retrofit;
|
||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
@ -139,7 +138,7 @@ public class PostViewModel extends ViewModel {
|
|||||||
SharedPreferences postFeedScrolledPositionSharedPreferences,
|
SharedPreferences postFeedScrolledPositionSharedPreferences,
|
||||||
@Nullable SharedPreferences postHistorySharedPreferences, String username,
|
@Nullable SharedPreferences postHistorySharedPreferences, String username,
|
||||||
int postType, SortType sortType, PostFilter postFilter, String userWhere,
|
int postType, SortType sortType, PostFilter postFilter, String userWhere,
|
||||||
List<ReadPost> readPostList) {
|
List<String> readPostList) {
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
this.retrofit = retrofit;
|
this.retrofit = retrofit;
|
||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
@ -183,7 +182,7 @@ public class PostViewModel extends ViewModel {
|
|||||||
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
||||||
@Nullable SharedPreferences postHistorySharedPreferences, String subredditName, String query,
|
@Nullable SharedPreferences postHistorySharedPreferences, String subredditName, String query,
|
||||||
String trendingSource, int postType, SortType sortType, PostFilter postFilter,
|
String trendingSource, int postType, SortType sortType, PostFilter postFilter,
|
||||||
List<ReadPost> readPostList) {
|
List<String> readPostList) {
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
this.retrofit = retrofit;
|
this.retrofit = retrofit;
|
||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
@ -290,12 +289,12 @@ public class PostViewModel extends ViewModel {
|
|||||||
private SortType sortType;
|
private SortType sortType;
|
||||||
private PostFilter postFilter;
|
private PostFilter postFilter;
|
||||||
private String userWhere;
|
private String userWhere;
|
||||||
private List<ReadPost> readPostList;
|
private List<String> readPostList;
|
||||||
|
|
||||||
public Factory(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
public Factory(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
||||||
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
||||||
SharedPreferences postHistorySharedPreferences, int postType, SortType sortType,
|
SharedPreferences postHistorySharedPreferences, int postType, SortType sortType,
|
||||||
PostFilter postFilter, List<ReadPost> readPostList) {
|
PostFilter postFilter, List<String> readPostList) {
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
this.retrofit = retrofit;
|
this.retrofit = retrofit;
|
||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
@ -312,7 +311,7 @@ public class PostViewModel extends ViewModel {
|
|||||||
public Factory(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
public Factory(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
||||||
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
||||||
SharedPreferences postHistorySharedPreferences, String name, int postType, SortType sortType,
|
SharedPreferences postHistorySharedPreferences, String name, int postType, SortType sortType,
|
||||||
PostFilter postFilter, List<ReadPost> readPostList) {
|
PostFilter postFilter, List<String> readPostList) {
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
this.retrofit = retrofit;
|
this.retrofit = retrofit;
|
||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
@ -331,7 +330,7 @@ public class PostViewModel extends ViewModel {
|
|||||||
public Factory(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
public Factory(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
||||||
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
||||||
SharedPreferences postHistorySharedPreferences, String username, int postType,
|
SharedPreferences postHistorySharedPreferences, String username, int postType,
|
||||||
SortType sortType, PostFilter postFilter, String where, List<ReadPost> readPostList) {
|
SortType sortType, PostFilter postFilter, String where, List<String> readPostList) {
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
this.retrofit = retrofit;
|
this.retrofit = retrofit;
|
||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
@ -350,7 +349,7 @@ public class PostViewModel extends ViewModel {
|
|||||||
public Factory(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
public Factory(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
||||||
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
||||||
SharedPreferences postHistorySharedPreferences, String name, String query, String trendingSource,
|
SharedPreferences postHistorySharedPreferences, String name, String query, String trendingSource,
|
||||||
int postType, SortType sortType, PostFilter postFilter, List<ReadPost> readPostList) {
|
int postType, SortType sortType, PostFilter postFilter, List<String> readPostList) {
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
this.retrofit = retrofit;
|
this.retrofit = retrofit;
|
||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
|
@ -10,7 +10,6 @@ import androidx.room.Entity;
|
|||||||
import androidx.room.ForeignKey;
|
import androidx.room.ForeignKey;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.account.Account;
|
import ml.docilealligator.infinityforreddit.account.Account;
|
||||||
import ml.docilealligator.infinityforreddit.post.Post;
|
|
||||||
|
|
||||||
@Entity(tableName = "read_posts", primaryKeys = {"username", "id"},
|
@Entity(tableName = "read_posts", primaryKeys = {"username", "id"},
|
||||||
foreignKeys = @ForeignKey(entity = Account.class, parentColumns = "username",
|
foreignKeys = @ForeignKey(entity = Account.class, parentColumns = "username",
|
||||||
@ -23,10 +22,6 @@ public class ReadPost implements Parcelable {
|
|||||||
@ColumnInfo(name = "id")
|
@ColumnInfo(name = "id")
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
public static ReadPost convertPost(Post post) {
|
|
||||||
return new ReadPost("temp", post.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReadPost(@NonNull String username, @NonNull String id) {
|
public ReadPost(@NonNull String username, @NonNull String id) {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
Loading…
Reference in New Issue
Block a user