diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhEngine.java b/app/src/main/java/com/hippo/ehviewer/client/EhEngine.java index 6236f4793..8e9728ce9 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/EhEngine.java +++ b/app/src/main/java/com/hippo/ehviewer/client/EhEngine.java @@ -24,7 +24,7 @@ import com.hippo.ehviewer.AppConfig; import com.hippo.ehviewer.GetText; import com.hippo.ehviewer.R; import com.hippo.ehviewer.Settings; -import com.hippo.ehviewer.client.data.GalleryComment; +import com.hippo.ehviewer.client.data.GalleryCommentList; import com.hippo.ehviewer.client.data.GalleryDetail; import com.hippo.ehviewer.client.data.GalleryInfo; import com.hippo.ehviewer.client.data.PreviewSet; @@ -418,7 +418,7 @@ public class EhEngine { } } - public static GalleryComment[] commentGallery(@Nullable EhClient.Task task, + public static GalleryCommentList commentGallery(@Nullable EhClient.Task task, OkHttpClient okHttpClient, String url, String comment, String id) throws Throwable { FormBody.Builder builder = new FormBody.Builder(); if (id == null) { diff --git a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryCommentList.java b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryCommentList.java new file mode 100644 index 000000000..23370155f --- /dev/null +++ b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryCommentList.java @@ -0,0 +1,65 @@ +/* + * Copyright 2019 Hippo Seven + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.hippo.ehviewer.client.data; + +import android.os.Parcel; +import android.os.Parcelable; +import java.util.Arrays; + +public class GalleryCommentList implements Parcelable { + + public GalleryComment[] comments; + public boolean hasMore; + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeParcelableArray(comments, flags); + dest.writeByte(hasMore ? (byte) 1 : (byte) 0); + } + + public GalleryCommentList(GalleryComment[] comments, boolean hasMore) { + this.comments = comments; + this.hasMore = hasMore; + } + + protected GalleryCommentList(Parcel in) { + Parcelable[] array = in.readParcelableArray(getClass().getClassLoader()); + if (array != null) { + comments = Arrays.copyOf(array, array.length, GalleryComment[].class); + } else { + comments = null; + } + hasMore = in.readByte() != 0; + } + + public static final Creator CREATOR = new Creator() { + @Override + public GalleryCommentList createFromParcel(Parcel in) { + return new GalleryCommentList(in); + } + + @Override + public GalleryCommentList[] newArray(int size) { + return new GalleryCommentList[size]; + } + }; +} diff --git a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryDetail.java b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryDetail.java index 5b11dfbf8..71e93615b 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryDetail.java +++ b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryDetail.java @@ -37,7 +37,7 @@ public class GalleryDetail extends GalleryInfo { public boolean isFavorited; public int ratingCount; public GalleryTagGroup[] tags; - public GalleryComment[] comments; + public GalleryCommentList comments; public int previewPages; public PreviewSet previewSet; @@ -60,8 +60,8 @@ public class GalleryDetail extends GalleryInfo { dest.writeInt(this.favoriteCount); dest.writeByte(isFavorited ? (byte) 1 : (byte) 0); dest.writeInt(this.ratingCount); - dest.writeParcelableArray(this.tags, 0); - dest.writeParcelableArray(this.comments, 0); + dest.writeParcelableArray(this.tags, flags); + dest.writeParcelable(this.comments, flags); dest.writeInt(this.previewPages); dest.writeParcelable(previewSet, flags); } @@ -88,12 +88,7 @@ public class GalleryDetail extends GalleryInfo { } else { this.tags = null; } - array = in.readParcelableArray(GalleryComment.class.getClassLoader()); - if (array != null) { - this.comments = Arrays.copyOf(array, array.length, GalleryComment[].class); - } else { - this.comments = null; - } + this.comments = in.readParcelable(getClass().getClassLoader()); this.previewPages = in.readInt(); this.previewSet = in.readParcelable(PreviewSet.class.getClassLoader()); } diff --git a/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.java b/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.java index b689756ad..6262dc55d 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.java +++ b/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.java @@ -22,6 +22,7 @@ import com.hippo.ehviewer.Settings; import com.hippo.ehviewer.client.EhUrl; import com.hippo.ehviewer.client.EhUtils; import com.hippo.ehviewer.client.data.GalleryComment; +import com.hippo.ehviewer.client.data.GalleryCommentList; import com.hippo.ehviewer.client.data.GalleryDetail; import com.hippo.ehviewer.client.data.GalleryTagGroup; import com.hippo.ehviewer.client.data.LargePreviewSet; @@ -33,6 +34,7 @@ import com.hippo.ehviewer.client.exception.ParseException; import com.hippo.ehviewer.client.exception.PiningException; import com.hippo.util.ExceptionUtils; import com.hippo.util.JsoupUtils; +import com.hippo.util.MutableBoolean; import com.hippo.yorozuya.NumberUtils; import com.hippo.yorozuya.StringUtils; import java.text.DateFormat; @@ -48,7 +50,10 @@ import java.util.regex.Pattern; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; +import org.jsoup.nodes.Node; import org.jsoup.select.Elements; +import org.jsoup.select.NodeTraversor; +import org.jsoup.select.NodeVisitor; public class GalleryDetailParser { @@ -66,7 +71,7 @@ public class GalleryDetailParser { private static final Pattern PATTERN_LARGE_PREVIEW = Pattern.compile("