seven332 / Nimingban

[DEPRECATED] A Nimingban Client
Apache License 2.0
309 stars 51 forks source link

fix bug : ListActivity show repeat post sometimes #91

Closed ju5t4fun closed 7 years ago

ju5t4fun commented 7 years ago
  1. add boolean equals(Object obj) method in com.hippo.nimingban.client.ac.data.ACPost
  2. add filter in com.hippo.nimingban.widget.ContentLayout.onGetPageData(int taskId, List<E> data) to remove repeat post
seven332 commented 7 years ago
  1. Always override hashCode when you override equals.
  2. 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.
  3. Why only TYPE_NEXT_PAGE_KEEP_POS?
ju5t4fun commented 7 years ago
  1. Always override hashCode when you override equals.
  1. 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 tmpdir--17_2_26_4_26_44 Here is the Json file 1_Full.txt
seven332 commented 7 years ago

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

ju5t4fun commented 7 years ago

That's better, looking forward to the release of the new version.