aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java14
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java20
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java21
7 files changed, 14 insertions, 61 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java
index 8cb82325..a254bef3 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java
@@ -1699,20 +1699,6 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
mShowAbsoluteNumberOfVotes = showAbsoluteNumberOfVotes;
}
- public int getNextItemPositionWithoutBeingHidden(int fromPosition) {
- int temp = fromPosition;
- while (temp >= 0 && temp < super.getItemCount()) {
- Post post = getItem(temp);
- if (post != null && post.isHiddenInRecyclerView()) {
- temp++;
- } else {
- break;
- }
- }
-
- return temp;
- }
-
public void setAutoplay(boolean autoplay) {
mAutoplay = autoplay;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
index 443e0842..693a5920 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -1769,20 +1769,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
mShowAbsoluteNumberOfVotes = showAbsoluteNumberOfVotes;
}
- public int getNextItemPositionWithoutBeingHidden(int fromPosition) {
- int temp = fromPosition;
- while (temp >= 0 && temp < super.getItemCount()) {
- Post post = getItem(temp);
- if (post != null && post.isHiddenInRecyclerView()) {
- temp++;
- } else {
- break;
- }
- }
-
- return temp;
- }
-
public void setAutoplay(boolean autoplay) {
mAutoplay = autoplay;
}
@@ -2718,7 +2704,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
void markPostRead(Post post, boolean changePostItemColor) {
if (mAccessToken != null && !post.isRead() && mMarkPostsAsRead) {
- post.markAsRead(true);
+ post.markAsRead();
if (changePostItemColor) {
if (itemViewIsNotCardView) {
itemView.setBackgroundColor(mReadPostCardViewBackgroundColor);
@@ -3993,7 +3979,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
void markPostRead(Post post, boolean changePostItemColor) {
if (mAccessToken != null && !post.isRead() && mMarkPostsAsRead) {
- post.markAsRead(true);
+ post.markAsRead();
if (changePostItemColor) {
itemView.setBackgroundColor(mReadPostCardViewBackgroundColor);
titleTextView.setTextColor(mReadPostTitleColor);
@@ -4259,7 +4245,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
void markPostRead(Post post, boolean changePostItemColor) {
if (mAccessToken != null && !post.isRead() && mMarkPostsAsRead) {
- post.markAsRead(true);
+ post.markAsRead();
if (changePostItemColor) {
itemView.setBackgroundTintList(ColorStateList.valueOf(mReadPostCardViewBackgroundColor));
titleTextView.setTextColor(mReadPostTitleColor);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java
index 738faa17..27608f1f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java
@@ -299,16 +299,16 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
int nPosts = mAdapter.getItemCount();
if (getCurrentPosition() == -1) {
if (mLinearLayoutManager != null) {
- setCurrentPosition(mAdapter.getNextItemPositionWithoutBeingHidden(mLinearLayoutManager.findFirstVisibleItemPosition()));
+ setCurrentPosition(mLinearLayoutManager.findFirstVisibleItemPosition());
} else {
int[] into = new int[2];
- setCurrentPosition(mAdapter.getNextItemPositionWithoutBeingHidden(mStaggeredGridLayoutManager.findFirstVisibleItemPositions(into)[1]));
+ setCurrentPosition(mStaggeredGridLayoutManager.findFirstVisibleItemPositions(into)[1]);
}
}
if (getCurrentPosition() != RecyclerView.NO_POSITION && nPosts > getCurrentPosition()) {
incrementCurrentPosition();
- smoothScroller.setTargetPosition(mAdapter.getNextItemPositionWithoutBeingHidden(getCurrentPosition()));
+ smoothScroller.setTargetPosition(getCurrentPosition());
if (mLinearLayoutManager != null) {
mLinearLayoutManager.startSmoothScroll(smoothScroller);
} else {
@@ -1029,7 +1029,7 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
post.setFlair(event.post.getFlair());
post.setSaved(event.post.isSaved());
if (event.post.isRead()) {
- post.markAsRead(true);
+ post.markAsRead();
}
mAdapter.notifyItemChanged(event.positionInList);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
index cb3f1694..763ef3cb 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
@@ -361,16 +361,16 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
int nPosts = mAdapter.getItemCount();
if (getCurrentPosition() == -1) {
if (mLinearLayoutManager != null) {
- setCurrentPosition(mAdapter.getNextItemPositionWithoutBeingHidden(mLinearLayoutManager.findFirstVisibleItemPosition()));
+ setCurrentPosition(mLinearLayoutManager.findFirstVisibleItemPosition());
} else {
int[] into = new int[2];
- setCurrentPosition(mAdapter.getNextItemPositionWithoutBeingHidden(mStaggeredGridLayoutManager.findFirstVisibleItemPositions(into)[1]));
+ setCurrentPosition(mStaggeredGridLayoutManager.findFirstVisibleItemPositions(into)[1]);
}
}
if (getCurrentPosition() != RecyclerView.NO_POSITION && nPosts > getCurrentPosition()) {
incrementCurrentPosition();
- smoothScroller.setTargetPosition(mAdapter.getNextItemPositionWithoutBeingHidden(getCurrentPosition()));
+ smoothScroller.setTargetPosition(getCurrentPosition());
if (mLinearLayoutManager != null) {
mLinearLayoutManager.startSmoothScroll(smoothScroller);
} else {
@@ -1777,7 +1777,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
post.setFlair(event.post.getFlair());
post.setSaved(event.post.isSaved());
if (event.post.isRead()) {
- post.markAsRead(true);
+ post.markAsRead();
}
mAdapter.notifyItemChanged(event.positionInList);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
index 3196d705..03e08059 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
@@ -1189,7 +1189,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
private void tryMarkingPostAsRead() {
if (mMarkPostsAsRead && mPost != null && !mPost.isRead()) {
- mPost.markAsRead(true);
+ mPost.markAsRead();
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, mPost.getId());
EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition));
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java
index 9374ba75..dddb4d69 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java
@@ -51,7 +51,7 @@ public class ParsePost {
JSONObject data = allData.getJSONObject(i).getJSONObject(JSONUtils.DATA_KEY);
Post post = parseBasicData(data);
if (readPostHashSet != null && readPostHashSet.contains(post.getId())) {
- post.markAsRead(false);
+ post.markAsRead();
}
if (PostFilter.isPostAllowed(post, postFilter)) {
newPosts.add(post);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java
index 82060f0e..090e7005 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java
@@ -76,8 +76,6 @@ public class Post implements Parcelable {
private boolean saved;
private boolean isCrosspost;
private boolean isRead;
- private boolean isHiddenInRecyclerView = false;
- private boolean isHiddenManuallyByUser = false;
private String crosspostParentId;
private ArrayList<Preview> previews = new ArrayList<>();
private ArrayList<Gallery> gallery = new ArrayList<>();
@@ -199,8 +197,6 @@ public class Post implements Parcelable {
saved = in.readByte() != 0;
isCrosspost = in.readByte() != 0;
isRead = in.readByte() != 0;
- isHiddenInRecyclerView = in.readByte() != 0;
- isHiddenManuallyByUser = in.readByte() != 0;
crosspostParentId = in.readString();
in.readTypedList(previews, Preview.CREATOR);
in.readTypedList(gallery, Gallery.CREATOR);
@@ -496,27 +492,14 @@ public class Post implements Parcelable {
return isCrosspost;
}
- public void markAsRead(boolean isHiddenManuallyByUser) {
+ public void markAsRead() {
isRead = true;
- this.isHiddenManuallyByUser = isHiddenManuallyByUser;
}
public boolean isRead() {
return isRead;
}
- public boolean isHiddenInRecyclerView() {
- return isHiddenInRecyclerView;
- }
-
- public void hidePostInRecyclerView() {
- isHiddenInRecyclerView = true;
- }
-
- public boolean isHiddenManuallyByUser() {
- return isHiddenManuallyByUser;
- }
-
public String getCrosspostParentId() {
return crosspostParentId;
}
@@ -586,8 +569,6 @@ public class Post implements Parcelable {
parcel.writeByte((byte) (saved ? 1 : 0));
parcel.writeByte((byte) (isCrosspost ? 1 : 0));
parcel.writeByte((byte) (isRead ? 1 : 0));
- parcel.writeByte((byte) (isHiddenInRecyclerView ? 1 : 0));
- parcel.writeByte((byte) (isHiddenManuallyByUser ? 1 : 0));
parcel.writeString(crosspostParentId);
parcel.writeTypedList(previews);
parcel.writeTypedList(gallery);