mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-27 19:38:22 +01:00
Remove unused Post fields (#1212)
* Remove unused isHiddenInRecyclerView Post field Was used only for reads and was always false * Remove unused isHiddenManuallyByUser Post field Was only written to and read for serialization. Never used for any logic
This commit is contained in:
parent
d3ccaea2cc
commit
69ba6461ff
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user