Closed ju5t4fun closed 7 years ago
Post
looks odd. Why not apply the filter to all kind of data, or maybe add a setXXX(boolean)
method to toggle this feature.TYPE_NEXT_PAGE_KEEP_POS
?
- Always override hashCode when you override equals.
Already add hashCode in next commit.
- The casting to Post looks odd. Why not apply the filter to all kind of data, or maybe add a setXXX(boolean) method to toggle this feature.
Already moved the casting.
- Why only TYPE_NEXT_PAGE_KEEP_POS?
- This problem only happens when you get next page post json, the server returns repeated data. Then APP looks like this Here is the Json file 1_Full.txt
It's not a good idea to making ACPost.equals()
fit the filter featrue of ContentHelper
. Usually equals()
must check all fields.
ContentHelper
is abstract. It's better to add a method to it, like:
/**
* Returns {@code true} if the two items are duplicate.
*/
protected boolean isDuplicate(@Nullable E e1, @Nullable E e2) {
return ObjectUtils.equals(e1, e2);
}
Subclass can override the method to meet their requirements.
Actually I have already refactored the ContentLayout
and ContentHelper
.
They contain the filter feature.
https://github.com/seven332/EhViewer/blob/2.x/app/src/main/java/com/hippo/ehviewer/widget/ContentData.java
https://github.com/seven332/EhViewer/blob/2.x/app/src/main/java/com/hippo/ehviewer/widget/ContentLayout.java
That's better, looking forward to the release of the new version.
boolean equals(Object obj)
method incom.hippo.nimingban.client.ac.data.ACPost
com.hippo.nimingban.widget.ContentLayout.onGetPageData(int taskId, List<E> data)
to remove repeat post