Fix rating if the gallery has been rated by the user

This commit is contained in:
seven332 committed 2019-01-21 20:17:27 +08:00
1 parent 59d141fc8e
commit 016ec23fbd
3 files changed
+20 -1

No files matched your search

@@ -209,7 +209,22 @@ public class EhEngine {
}
}
if (list.size() > 0 && (TextUtils.isEmpty(list.get(0).uploader) || Settings.getShowJpnTitle() || Settings.getShowGalleryPages() || sEhFilter.needCallApi())) {
boolean anyRated = false;
for (GalleryInfo info : list) {
if (info.rated) {
anyRated = true;
break;
}
}
boolean needFillByApi = list.size() > 0
&& (TextUtils.isEmpty(list.get(0).uploader)
|| anyRated
|| Settings.getShowJpnTitle()
|| Settings.getShowGalleryPages()
|| sEhFilter.needCallApi());
if (needFillByApi) {
// Fill by api
fillGalleryListByApi(task, okHttpClient, list);
@@ -121,6 +121,8 @@ public class GalleryInfo implements Parcelable {
*/
public String simpleLanguage;
public boolean rated;
public final void generateSLang() {
if (simpleTags != null) {
generateSLangFromTags();
@@ -162,6 +162,8 @@ public class GalleryListParser {
Element it4r = JsoupUtils.getElementByClass(e, "it4r");
if (null != it4r) {
gi.rating = NumberUtils.parseFloatSafely(parseRating(it4r.attr("style")), -1.0f);
// TODO The gallery may be rated even if it has one of these classes
gi.rated = it4r.hasClass("irr") || it4r.hasClass("irg") || it4r.hasClass("irb");
} else {
Log.w(TAG, "Can't parse gallery info rating");
gi.rating = -1.0f;