Cleanup JvmFields in GalleryInfo

This commit is contained in:
tarsin committed 2023-01-06 09:33:24 +08:00
1 parent ce008f5576
commit 13660cb70a
21 files changed
+240 -258

No files matched your search

@@ -118,7 +118,7 @@ public class EhDB {
// Insert or update
public static synchronized void putDownloadInfo(DownloadInfo downloadInfo) {
DownloadsDao dao = db.downloadsDao();
if (null != dao.load(downloadInfo.gid)) {
if (null != dao.load(downloadInfo.getGid())) {
// Update
dao.update(downloadInfo);
} else {
@@ -256,7 +256,7 @@ public class EhDB {
public static synchronized void putLocalFavorites(GalleryInfo galleryInfo) {
LocalFavoritesDao dao = db.localFavoritesDao();
if (null == dao.load(galleryInfo.gid)) {
if (null == dao.load(galleryInfo.getGid())) {
LocalFavoriteInfo info;
if (galleryInfo instanceof LocalFavoriteInfo) {
info = (LocalFavoriteInfo) galleryInfo;
@@ -335,7 +335,7 @@ public class EhDB {
info = new HistoryInfo(galleryInfo);
}
info.time = System.currentTimeMillis();
if (null != dao.load(info.gid)) {
if (null != dao.load(info.getGid())) {
dao.update(info);
} else {
dao.insert(info);
@@ -345,7 +345,7 @@ public class EhDB {
public static synchronized void putHistoryInfo(List<HistoryInfo> historyInfoList) {
HistoryDao dao = db.historyDao();
for (HistoryInfo info : historyInfoList) {
if (null == dao.load(info.gid)) {
if (null == dao.load(info.getGid())) {
dao.insert(info);
}
}
@@ -51,7 +51,7 @@ public class FavouriteStatusRouter {
for (Map<Long, GalleryInfo> map : maps.values()) {
GalleryInfo info = map.get(gid);
if (info != null) {
info.favoriteSlot = slot;
info.setFavoriteSlot(slot);
}
}
@@ -56,7 +56,7 @@ public final class UrlOpener {
if (galleryDetail != null) {
GalleryPageUrlParser.Result result = GalleryPageUrlParser.parse(url);
if (result != null) {
if (result.gid == galleryDetail.gid) {
if (result.gid == galleryDetail.getGid()) {
intent = new Intent(context, ReaderActivity.class);
intent.setAction(ReaderActivity.ACTION_EH);
intent.putExtra(ReaderActivity.KEY_GALLERY_INFO, galleryDetail);
@@ -156,7 +156,7 @@ public final class EhFilter {
}
// Title
String title = info.title;
String title = info.getTitle();
List<Filter> filters = mTitleFilterList;
if (null != title && filters.size() > 0) {
for (int i = 0, n = filters.size(); i < n; i++) {
@@ -175,7 +175,7 @@ public final class EhFilter {
}
// Uploader
String uploader = info.uploader;
String uploader = info.getUploader();
List<Filter> filters = mUploaderFilterList;
if (null != uploader && filters.size() > 0) {
for (int i = 0, n = filters.size(); i < n; i++) {
@@ -227,7 +227,7 @@ public final class EhFilter {
}
// Tag
String[] tags = info.simpleTags;
String[] tags = info.getSimpleTags();
List<Filter> filters = mTagFilterList;
if (null != tags && filters.size() > 0) {
for (String tag : tags) {
@@ -262,7 +262,7 @@ public final class EhFilter {
return false;
}
String[] tags = info.simpleTags;
String[] tags = info.getSimpleTags();
List<Filter> filters = mTagNamespaceFilterList;
if (null != tags && filters.size() > 0) {
for (String tag : tags) {
@@ -133,9 +133,9 @@ public class EhUtils {
public static String getSuitableTitle(GalleryInfo gi) {
if (Settings.getShowJpnTitle()) {
return TextUtils.isEmpty(gi.titleJpn) ? gi.title : gi.titleJpn;
return TextUtils.isEmpty(gi.getTitleJpn()) ? gi.getTitle() : gi.getTitleJpn();
} else {
return TextUtils.isEmpty(gi.title) ? gi.titleJpn : gi.title;
return TextUtils.isEmpty(gi.getTitle()) ? gi.getTitleJpn() : gi.getTitle();
}
}
@@ -24,64 +24,49 @@ import java.util.regex.Pattern
@Parcelize
open class GalleryInfo(
@JvmField
@PrimaryKey
@ColumnInfo(name = "GID")
var gid: Long = 0,
@JvmField
@ColumnInfo(name = "TOKEN")
var token: String? = null,
@JvmField
@ColumnInfo(name = "TITLE")
var title: String? = null,
@JvmField
@ColumnInfo(name = "TITLE_JPN")
var titleJpn: String? = null,
@JvmField
@ColumnInfo(name = "THUMB")
var thumb: String? = null,
@JvmField
@ColumnInfo(name = "CATEGORY")
var category: Int = 0,
@JvmField
@ColumnInfo(name = "POSTED")
var posted: String? = null,
@JvmField
@ColumnInfo(name = "UPLOADER")
var uploader: String? = null,
@JvmField
@Ignore
var disowned: Boolean = false,
@JvmField
@ColumnInfo(name = "RATING")
var rating: Float = 0f,
@JvmField
@Ignore
var rated: Boolean = false,
@JvmField
@Ignore
var simpleTags: Array<String>? = null,
@JvmField
@Ignore
var pages: Int = 0,
@JvmField
@Ignore
var thumbWidth: Int = 0,
@JvmField
@Ignore
var thumbHeight: Int = 0,
@@ -97,15 +82,12 @@ open class GalleryInfo(
/**
* language from title
*/
@JvmField
@ColumnInfo(name = "SIMPLE_LANGUAGE")
var simpleLanguage: String? = null,
@JvmField
@Ignore
var favoriteSlot: Int = -2,
@JvmField
@Ignore
var favoriteName: String? = null
@@ -39,13 +39,13 @@ public class GalleryApiParser {
if (gi == null) {
continue;
}
gi.title = ParserUtils.trim(g.getString("title"));
gi.titleJpn = ParserUtils.trim(g.getString("title_jpn"));
gi.category = EhUtils.getCategory(g.getString("category"));
gi.thumb = EhUtils.handleThumbUrlResolution(g.getString("thumb"));
gi.uploader = g.getString("uploader");
gi.posted = ParserUtils.formatDate(ParserUtils.parseLong(g.getString("posted"), 0) * 1000);
gi.rating = NumberUtils.parseFloatSafely(g.getString("rating"), 0.0f);
gi.setTitle(ParserUtils.trim(g.getString("title")));
gi.setTitleJpn(ParserUtils.trim(g.getString("title_jpn")));
gi.setCategory(EhUtils.getCategory(g.getString("category")));
gi.setThumb(EhUtils.handleThumbUrlResolution(g.getString("thumb")));
gi.setUploader(g.getString("uploader"));
gi.setPosted(ParserUtils.formatDate(ParserUtils.parseLong(g.getString("posted"), 0) * 1000));
gi.setRating(NumberUtils.parseFloatSafely(g.getString("rating"), 0.0f));
// tags
JSONArray tagJa = g.getJSONArray("tags");
int tagLength = tagJa.length();
@@ -53,8 +53,8 @@ public class GalleryApiParser {
for (int j = 0; j < tagLength; j++) {
tags[j] = tagJa.getString(j);
}
gi.simpleTags = tags;
gi.pages = NumberUtils.parseIntSafely(g.getString("filecount"), 0);
gi.setSimpleTags(tags);
gi.setPages(NumberUtils.parseIntSafely(g.getString("filecount"), 0));
gi.generateSLang();
}
}
@@ -62,7 +62,7 @@ public class GalleryApiParser {
private static GalleryInfo getGalleryInfoByGid(List<GalleryInfo> galleryInfoList, long gid) {
for (int i = 0, size = galleryInfoList.size(); i < size; i++) {
GalleryInfo gi = galleryInfoList.get(i);
if (gi.gid == gid) {
if (gi.getGid() == gid) {
return gi;
}
}
@@ -124,7 +124,7 @@ public class GalleryDetailParser {
// Generate simpleLanguage for local favorites
for (int i = 0; i < LANGUAGES.length; i++) {
if (galleryDetail.language.equals(LANGUAGES[i])) {
galleryDetail.simpleLanguage = GalleryInfo.S_LANGS[i];
galleryDetail.setSimpleLanguage(GalleryInfo.S_LANGS[i]);
break;
}
}
@@ -136,14 +136,14 @@ public class GalleryDetailParser {
private static void parseDetail(GalleryDetail gd, Document d, String body) throws ParseException {
Matcher matcher = PATTERN_DETAIL.matcher(body);
if (matcher.find()) {
gd.gid = NumberUtils.parseLongSafely(matcher.group(1), -1L);
gd.token = matcher.group(2);
gd.setGid(NumberUtils.parseLongSafely(matcher.group(1), -1L));
gd.setToken(matcher.group(2));
gd.apiUid = NumberUtils.parseLongSafely(matcher.group(3), -1L);
gd.apiKey = matcher.group(4);
} else {
throw new ParseException("Can't parse gallery detail", body);
}
if (gd.gid == -1L) {
if (gd.getGid() == -1L) {
throw new ParseException("Can't parse gallery detail", body);
}
@@ -169,26 +169,26 @@ public class GalleryDetailParser {
// Thumb url
Element gd1 = gm.getElementById("gd1");
try {
gd.thumb = parseCoverStyle(StringUtils.trim(gd1.child(0).attr("style")));
gd.setThumb(parseCoverStyle(StringUtils.trim(gd1.child(0).attr("style"))));
} catch (Throwable e) {
ExceptionUtils.throwIfFatal(e);
gd.thumb = "";
gd.setThumb("");
}
// Title
Element gn = gm.getElementById("gn");
if (null != gn) {
gd.title = StringUtils.trim(gn.text());
gd.setTitle(StringUtils.trim(gn.text()));
} else {
gd.title = "";
gd.setTitle("");
}
// Jpn title
Element gj = gm.getElementById("gj");
if (null != gj) {
gd.titleJpn = StringUtils.trim(gj.text());
gd.setTitleJpn(StringUtils.trim(gj.text()));
} else {
gd.titleJpn = "";
gd.setTitleJpn("");
}
// Category
@@ -198,27 +198,27 @@ public class GalleryDetailParser {
if (ce == null) {
ce = JsoupUtils.getElementByClass(gdc, "cs");
}
gd.category = EhUtils.getCategory(ce.text());
gd.setCategory(EhUtils.getCategory(ce.text()));
} catch (Throwable e) {
ExceptionUtils.throwIfFatal(e);
gd.category = EhUtils.UNKNOWN;
gd.setCategory(EhUtils.UNKNOWN);
}
// Uploader
Element gdn = gm.getElementById("gdn");
if (null != gdn) {
gd.disowned = gdn.attr("style").contains("opacity:0.5");
gd.uploader = StringUtils.trim(gdn.text());
gd.setDisowned(gdn.attr("style").contains("opacity:0.5"));
gd.setUploader(StringUtils.trim(gdn.text()));
} else {
gd.uploader = "";
gd.setUploader("");
}
Element gdd = gm.getElementById("gdd");
gd.posted = "";
gd.setPosted("");
gd.parent = "";
gd.visible = "";
gd.size = "";
gd.pages = 0;
gd.setPages(0);
gd.favoriteCount = 0;
Elements es = gdd.child(0).child(0).children();
for (int i = 0, n = es.size(); i < n; i++) {
@@ -239,17 +239,17 @@ public class GalleryDetailParser {
if (null != rating_label) {
String ratingStr = StringUtils.trim(rating_label.text());
if ("Not Yet Rated".equals(ratingStr)) {
gd.rating = -1.0f;
gd.setRating(-1.0f);
} else {
int index = ratingStr.indexOf(' ');
if (index == -1 || index >= ratingStr.length()) {
gd.rating = 0f;
gd.setRating(0f);
} else {
gd.rating = NumberUtils.parseFloatSafely(ratingStr.substring(index + 1), 0f);
gd.setRating(NumberUtils.parseFloatSafely(ratingStr.substring(index + 1), 0f));
}
}
} else {
gd.rating = -1.0f;
gd.setRating(-1.0f);
}
// isFavorited
@@ -258,19 +258,19 @@ public class GalleryDetailParser {
if (gdf != null) {
final String favoriteName = StringUtils.trim(gdf.text());
if (favoriteName.equals("Add to Favorites")) {
gd.favoriteName = null;
gd.setFavoriteName(null);
} else {
gd.isFavorited = true;
gd.favoriteName = StringUtils.trim(gdf.text());
gd.setFavoriteName(StringUtils.trim(gdf.text()));
matcher = PATTERN_FAVORITE_SLOT.matcher(body);
if (matcher.find()) {
gd.favoriteSlot = (NumberUtils.parseIntSafely(matcher.group(1), 2) - 2) / 19;
gd.setFavoriteSlot((NumberUtils.parseIntSafely(matcher.group(1), 2) - 2) / 19);
}
}
}
if (gd.favoriteSlot == -2 && EhDB.containLocalFavorites(gd.gid)) {
gd.favoriteSlot = -1;
if (gd.getFavoriteSlot() == -2 && EhDB.containLocalFavorites(gd.getGid())) {
gd.setFavoriteSlot(-1);
}
} catch (Throwable e) {
ExceptionUtils.throwIfFatal(e);
@@ -292,10 +292,10 @@ public class GalleryDetailParser {
GalleryInfo gi = new GalleryInfo();
GalleryDetailUrlParser.Result result = GalleryDetailUrlParser.parse(element.attr("href"));
if (result != null) {
gi.gid = result.gid;
gi.token = result.token;
gi.title = StringUtils.trim(element.text());
gi.posted = dates.get(i);
gi.setGid(result.gid);
gi.setToken(result.token);
gi.setTitle(StringUtils.trim(element.text()));
gi.setPosted(dates.get(i));
gd.newerVersions.add(gi);
}
}
@@ -324,7 +324,7 @@ public class GalleryDetailParser {
String key = StringUtils.trim(es.get(0).text());
String value = StringUtils.trim(es.get(1).ownText());
if (key.startsWith("Posted")) {
gd.posted = value;
gd.setPosted(value);
} else if (key.startsWith("Parent")) {
Element a = es.get(1).children().first();
if (a != null) {
@@ -339,9 +339,9 @@ public class GalleryDetailParser {
} else if (key.startsWith("Length")) {
int index = value.indexOf(' ');
if (index >= 0) {
gd.pages = NumberUtils.parseIntSafely(value.substring(0, index), 1);
gd.setPages(NumberUtils.parseIntSafely(value.substring(0, index), 1));
} else {
gd.pages = 1;
gd.setPages(1);
}
} else if (key.startsWith("Favorited")) {
switch (value) {
@@ -125,8 +125,8 @@ public class GalleryListParser {
if (a != null) {
GalleryDetailUrlParser.Result result = GalleryDetailUrlParser.parse(a.attr("href"));
if (result != null) {
gi.gid = result.gid;
gi.token = result.token;
gi.setGid(result.gid);
gi.setToken(result.token);
}
}
@@ -136,9 +136,9 @@ public class GalleryListParser {
child = children.get(0);
children = child.children();
}
gi.title = child.text().trim();
gi.setTitle(child.text().trim());
}
if (gi.title == null) {
if (gi.getTitle() == null) {
return null;
}
@@ -149,17 +149,17 @@ public class GalleryListParser {
for (Element gt : gts) {
tags.add(gt.attr("title"));
}
gi.simpleTags = tags.toArray(new String[0]);
gi.setSimpleTags(tags.toArray(new String[0]));
}
// Category
gi.category = EhUtils.UNKNOWN;
gi.setCategory(EhUtils.UNKNOWN);
Element ce = JsoupUtils.getElementByClass(e, "cn");
if (ce == null) {
ce = JsoupUtils.getElementByClass(e, "cs");
}
if (ce != null) {
gi.category = EhUtils.getCategory(ce.text());
gi.setCategory(EhUtils.getCategory(ce.text()));
}
// Thumb
@@ -170,12 +170,12 @@ public class GalleryListParser {
// Thumb size
Matcher m = PATTERN_THUMB_SIZE.matcher(img.attr("style"));
if (m.find()) {
gi.thumbWidth = NumberUtils.parseIntSafely(m.group(2), 0);
gi.thumbHeight = NumberUtils.parseIntSafely(m.group(1), 0);
gi.setThumbWidth(NumberUtils.parseIntSafely(m.group(2), 0));
gi.setThumbHeight(NumberUtils.parseIntSafely(m.group(1), 0));
} else {
Log.w(TAG, "Can't parse gallery info thumb size");
gi.thumbWidth = 0;
gi.thumbHeight = 0;
gi.setThumbWidth(0);
gi.setThumbHeight(0);
}
// Thumb url
String url = img.attr("data-src");
@@ -185,7 +185,7 @@ public class GalleryListParser {
if (TextUtils.isEmpty(url)) {
url = null;
}
gi.thumb = EhUtils.handleThumbUrlResolution(url);
gi.setThumb(EhUtils.handleThumbUrlResolution(url));
}
// Pages
@@ -193,12 +193,12 @@ public class GalleryListParser {
if (div != null) {
Matcher matcher = PATTERN_PAGES.matcher(div.text());
if (matcher.find()) {
gi.pages = NumberUtils.parseIntSafely(matcher.group(1), 0);
gi.setPages(NumberUtils.parseIntSafely(matcher.group(1), 0));
}
}
}
// Try extended and thumbnail version
if (gi.thumb == null) {
if (gi.getThumb() == null) {
Element gl = JsoupUtils.getElementByClass(e, "gl1e");
if (gl == null) {
gl = JsoupUtils.getElementByClass(e, "gl3t");
@@ -209,35 +209,35 @@ public class GalleryListParser {
// Thumb size
Matcher m = PATTERN_THUMB_SIZE.matcher(img.attr("style"));
if (m.find()) {
gi.thumbWidth = NumberUtils.parseIntSafely(m.group(2), 0);
gi.thumbHeight = NumberUtils.parseIntSafely(m.group(1), 0);
gi.setThumbWidth(NumberUtils.parseIntSafely(m.group(2), 0));
gi.setThumbHeight(NumberUtils.parseIntSafely(m.group(1), 0));
} else {
Log.w(TAG, "Can't parse gallery info thumb size");
gi.thumbWidth = 0;
gi.thumbHeight = 0;
gi.setThumbWidth(0);
gi.setThumbHeight(0);
}
gi.thumb = EhUtils.handleThumbUrlResolution(img.attr("src"));
gi.setThumb(EhUtils.handleThumbUrlResolution(img.attr("src")));
}
}
}
// Posted
gi.favoriteSlot = -2;
Element posted = e.getElementById("posted_" + gi.gid);
gi.setFavoriteSlot(-2);
Element posted = e.getElementById("posted_" + gi.getGid());
if (posted != null) {
gi.posted = posted.text().trim();
gi.favoriteSlot = parseFavoriteSlot(posted.attr("style"));
gi.setPosted(posted.text().trim());
gi.setFavoriteSlot(parseFavoriteSlot(posted.attr("style")));
}
if (gi.favoriteSlot == -2) {
gi.favoriteSlot = EhDB.containLocalFavorites(gi.gid) ? -1 : -2;
if (gi.getFavoriteSlot() == -2) {
gi.setFavoriteSlot(EhDB.containLocalFavorites(gi.getGid()) ? -1 : -2);
}
// Rating
Element ir = JsoupUtils.getElementByClass(e, "ir");
if (ir != null) {
gi.rating = NumberUtils.parseFloatSafely(parseRating(ir.attr("style")), -1.0f);
gi.setRating(NumberUtils.parseFloatSafely(parseRating(ir.attr("style")), -1.0f));
// TODO The gallery may be rated even if it doesn't has one of these classes
gi.rated = ir.hasClass("irr") || ir.hasClass("irg") || ir.hasClass("irb");
gi.setRated(ir.hasClass("irr") || ir.hasClass("irg") || ir.hasClass("irb"));
}
// Uploader and pages
@@ -255,15 +255,15 @@ public class GalleryListParser {
if (children.size() > uploaderIndex) {
Element div = children.get(uploaderIndex);
if (div != null) {
gi.disowned = div.attr("style").contains("opacity:0.5");
gi.setDisowned(div.attr("style").contains("opacity:0.5"));
Element a = div.children().first();
gi.uploader = a == null ? div.text().trim() : a.text().trim();
gi.setUploader(a == null ? div.text().trim() : a.text().trim());
}
}
if (children.size() > pagesIndex) {
Matcher matcher = PATTERN_PAGES.matcher(children.get(pagesIndex).text());
if (matcher.find()) {
gi.pages = NumberUtils.parseIntSafely(matcher.group(1), 0);
gi.setPages(NumberUtils.parseIntSafely(matcher.group(1), 0));
}
}
}
@@ -274,7 +274,7 @@ public class GalleryListParser {
if (div != null) {
Matcher matcher = PATTERN_PAGES.matcher(div.text());
if (matcher.find()) {
gi.pages = NumberUtils.parseIntSafely(matcher.group(1), 0);
gi.setPages(NumberUtils.parseIntSafely(matcher.group(1), 0));
}
}
}
@@ -104,7 +104,7 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
DownloadInfo info = allInfoList.get(i);
// Add to all info map
allInfoMap.put(info.gid, info);
allInfoMap.put(info.getGid(), info);
// Add to each label list
LinkedList<DownloadInfo> list = getInfoListForLabel(info.label);
@@ -232,13 +232,13 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
}
void startDownload(GalleryInfo galleryInfo, @Nullable String label) {
if (mCurrentTask != null && mCurrentTask.gid == galleryInfo.gid) {
if (mCurrentTask != null && mCurrentTask.getGid() == galleryInfo.getGid()) {
// It is current task
return;
}
// Check in download list
DownloadInfo info = mAllInfoMap.get(galleryInfo.gid);
DownloadInfo info = mAllInfoMap.get(galleryInfo.getGid());
if (info != null) { // Get it in download list
if (info.state != DownloadInfo.STATE_WAIT) {
// Set state DownloadInfo.STATE_WAIT
@@ -274,7 +274,7 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
// Add to all download list and map
mAllInfoList.addFirst(info);
mAllInfoMap.put(galleryInfo.gid, info);
mAllInfoMap.put(galleryInfo.getGid(), info);
// Add to wait list
mWaitList.add(info);
@@ -359,7 +359,7 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
public void addDownload(List<DownloadInfo> downloadInfoList, boolean notify) {
for (DownloadInfo info : downloadInfoList) {
if (containDownloadInfo(info.gid)) {
if (containDownloadInfo(info.getGid())) {
// Contain
return;
}
@@ -387,7 +387,7 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
// Add to all download list and map
mAllInfoList.add(info);
mAllInfoMap.put(info.gid, info);
mAllInfoMap.put(info.getGid(), info);
// Save to
EhDB.putDownloadInfo(info);
@@ -415,7 +415,7 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
}
public void addDownload(GalleryInfo galleryInfo, @Nullable String label) {
if (containDownloadInfo(galleryInfo.gid)) {
if (containDownloadInfo(galleryInfo.getGid())) {
// Contain
return;
}
@@ -436,7 +436,7 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
// Add to all download list and map
mAllInfoList.addFirst(info);
mAllInfoMap.put(galleryInfo.gid, info);
mAllInfoMap.put(galleryInfo.getGid(), info);
// Save to
EhDB.putDownloadInfo(info);
@@ -516,7 +516,7 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
// Remove all list and map
mAllInfoList.remove(info);
mAllInfoMap.remove(info.gid);
mAllInfoMap.remove(info.getGid());
// Remove label list
LinkedList<DownloadInfo> list = getInfoListForLabel(info.label);
@@ -552,7 +552,7 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
// Remove from all info map
mAllInfoList.remove(info);
mAllInfoMap.remove(info.gid);
mAllInfoMap.remove(info.getGid());
// Remove from label list
LinkedList<DownloadInfo> list = getInfoListForLabel(info.label);
@@ -579,16 +579,16 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
protected Void doInBackground(Void... voids) {
GalleryInfo galleryInfo = new GalleryInfo();
for (DownloadInfo downloadInfo : list) {
galleryInfo.gid = downloadInfo.gid;
galleryInfo.token = downloadInfo.token;
galleryInfo.title = downloadInfo.title;
galleryInfo.thumb = downloadInfo.thumb;
galleryInfo.category = downloadInfo.category;
galleryInfo.posted = downloadInfo.posted;
galleryInfo.uploader = downloadInfo.uploader;
galleryInfo.rating = downloadInfo.rating;
galleryInfo.setGid(downloadInfo.getGid());
galleryInfo.setToken(downloadInfo.getToken());
galleryInfo.setTitle(downloadInfo.getTitle());
galleryInfo.setThumb(downloadInfo.getThumb());
galleryInfo.setCategory(downloadInfo.getCategory());
galleryInfo.setPosted(downloadInfo.getPosted());
galleryInfo.setUploader(downloadInfo.getUploader());
galleryInfo.setRating(downloadInfo.getRating());
UniFile downloadDir = SpiderDen.getGalleryDownloadDir(galleryInfo.gid);
UniFile downloadDir = SpiderDen.getGalleryDownloadDir(galleryInfo.getGid());
if (downloadDir == null) {
continue;
}
@@ -618,14 +618,14 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
// No ensureDownload
private DownloadInfo stopDownloadInternal(long gid) {
// Check current task
if (mCurrentTask != null && mCurrentTask.gid == gid) {
if (mCurrentTask != null && mCurrentTask.getGid() == gid) {
// Stop current
return stopCurrentDownloadInternal();
}
for (Iterator<DownloadInfo> iterator = mWaitList.iterator(); iterator.hasNext(); ) {
DownloadInfo info = iterator.next();
if (info.gid == gid) {
if (info.getGid() == gid) {
// Remove from wait list
iterator.remove();
// Update state
@@ -677,7 +677,7 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
}
} else {
// Check current task
if (mCurrentTask != null && gidList.contains(mCurrentTask.gid)) {
if (mCurrentTask != null && gidList.contains(mCurrentTask.getGid())) {
// Stop current
stopCurrentDownloadInternal();
}
@@ -685,7 +685,7 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
// Check all in wait list
for (Iterator<DownloadInfo> iterator = mWaitList.iterator(); iterator.hasNext(); ) {
DownloadInfo info = iterator.next();
if (gidList.contains(info.gid)) {
if (gidList.contains(info.getGid())) {
// Remove from wait list
iterator.remove();
// Update state
@@ -71,7 +71,7 @@ public class EhPageLoader extends PageLoader2 implements SpiderQueen.OnSpiderLis
@NonNull
@Override
public String getImageFilename(int index) {
return String.format(Locale.US, "%d-%s-%08d", mGalleryInfo.gid, mGalleryInfo.token, index + 1);
return String.format(Locale.US, "%d-%s-%08d", mGalleryInfo.getGid(), mGalleryInfo.getToken(), index + 1);
}
@NonNull
@@ -80,10 +80,10 @@ public class EhPageLoader extends PageLoader2 implements SpiderQueen.OnSpiderLis
if (null != mSpiderQueen) {
String extension = mSpiderQueen.getExtension(index);
if (extension != null) {
return String.format(Locale.US, "%d-%s-%08d.%s", mGalleryInfo.gid, mGalleryInfo.token, index + 1, extension);
return String.format(Locale.US, "%d-%s-%08d.%s", mGalleryInfo.getGid(), mGalleryInfo.getToken(), index + 1, extension);
}
}
return String.format(Locale.US, "%d-%s-%08d", mGalleryInfo.gid, mGalleryInfo.token, index + 1);
return String.format(Locale.US, "%d-%s-%08d", mGalleryInfo.getGid(), mGalleryInfo.getToken(), index + 1);
}
@Override
@@ -56,8 +56,8 @@ public final class SpiderDen {
public SpiderDen(GalleryInfo galleryInfo) {
mGalleryInfo = galleryInfo;
mGid = galleryInfo.gid;
mDownloadDir = getGalleryDownloadDir(galleryInfo.gid);
mGid = galleryInfo.getGid();
mDownloadDir = getGalleryDownloadDir(galleryInfo.getGid());
}
public static void initialize(Context context) {
@@ -179,10 +179,10 @@ public final class SpiderQueen implements Runnable {
public static SpiderQueen obtainSpiderQueen(@NonNull GalleryInfo galleryInfo, @Mode int mode) {
OSUtils.checkMainLoop();
SpiderQueen queen = sQueenMap.get(galleryInfo.gid);
SpiderQueen queen = sQueenMap.get(galleryInfo.getGid());
if (queen == null) {
queen = new SpiderQueen(galleryInfo);
sQueenMap.put(galleryInfo.gid, queen);
sQueenMap.put(galleryInfo.getGid(), queen);
// Set mode
queen.setMode(mode);
queen.start();
@@ -203,7 +203,7 @@ public final class SpiderQueen implements Runnable {
if (queen.mReadReference == 0 && queen.mDownloadReference == 0) {
// Stop and remove if there is no reference
queen.stop();
sQueenMap.remove(queen.mGalleryInfo.gid);
sQueenMap.remove(queen.mGalleryInfo.getGid());
}
}
@@ -697,19 +697,19 @@ public final class SpiderQueen implements Runnable {
if (downloadDir != null) {
UniFile file = downloadDir.findFile(SPIDER_INFO_FILENAME);
spiderInfo = SpiderInfo.read(file);
if (spiderInfo != null && spiderInfo.gid == mGalleryInfo.gid &&
spiderInfo.token.equals(mGalleryInfo.token)) {
if (spiderInfo != null && spiderInfo.gid == mGalleryInfo.getGid() &&
spiderInfo.token.equals(mGalleryInfo.getToken())) {
return spiderInfo;
}
}
// Read from cache
var entry = mSpiderInfoCache.get(Long.toString(mGalleryInfo.gid));
var entry = mSpiderInfoCache.get(Long.toString(mGalleryInfo.getGid()));
if (entry == null) return null;
try (entry; InputStream is = new FileInputStream(entry.getData().toFile())) {
spiderInfo = SpiderInfo.read(is);
if (spiderInfo != null && spiderInfo.gid == mGalleryInfo.gid &&
spiderInfo.token.equals(mGalleryInfo.token)) {
if (spiderInfo != null && spiderInfo.gid == mGalleryInfo.getGid() &&
spiderInfo.token.equals(mGalleryInfo.getToken())) {
return spiderInfo;
}
} catch (IOException e) {
@@ -744,11 +744,11 @@ public final class SpiderQueen implements Runnable {
private SpiderInfo readSpiderInfoFromInternet() {
SpiderInfo spiderInfo = new SpiderInfo();
spiderInfo.gid = mGalleryInfo.gid;
spiderInfo.token = mGalleryInfo.token;
spiderInfo.gid = mGalleryInfo.getGid();
spiderInfo.token = mGalleryInfo.getToken();
Request request = new EhRequestBuilder(EhUrl.getGalleryDetailUrl(
mGalleryInfo.gid, mGalleryInfo.token, 0, false), EhUrl.getReferer()).build();
mGalleryInfo.getGid(), mGalleryInfo.getToken(), 0, false), EhUrl.getReferer()).build();
try (Response response = mHttpClient.newCall(request).execute()) {
String body = response.body().string();
@@ -769,7 +769,7 @@ public final class SpiderQueen implements Runnable {
}
String url = EhUrl.getGalleryMultiPageViewerUrl(
mGalleryInfo.gid, mGalleryInfo.token);
mGalleryInfo.getGid(), mGalleryInfo.getToken());
if (DEBUG_PTOKEN) {
Log.d(TAG, "getPTokenFromMultiPageViewer index " + index + ", url " + url);
}
@@ -815,7 +815,7 @@ public final class SpiderQueen implements Runnable {
}
String url = EhUrl.getGalleryDetailUrl(
mGalleryInfo.gid, mGalleryInfo.token, previewIndex, false);
mGalleryInfo.getGid(), mGalleryInfo.getToken(), previewIndex, false);
String referer = EhUrl.getReferer();
if (DEBUG_PTOKEN) {
Log.d(TAG, "index " + index + ", previewIndex " + previewIndex +
@@ -861,7 +861,7 @@ public final class SpiderQueen implements Runnable {
}
// Write to cache
var editor = mSpiderInfoCache.edit(Long.toString(mGalleryInfo.gid));
var editor = mSpiderInfoCache.edit(Long.toString(mGalleryInfo.getGid()));
if (editor == null) return;
try (OutputStream os = new FileOutputStream(editor.getData().toFile())) {
spiderInfo.write(os);
@@ -1097,7 +1097,7 @@ public final class SpiderQueen implements Runnable {
private final long mGid;
public SpiderWorker() {
mGid = mGalleryInfo.gid;
mGid = mGalleryInfo.getGid();
}
private String getPageUrl(long gid, int index, String pToken,
@@ -1115,7 +1115,7 @@ public final class SpiderQueen implements Runnable {
}
private GalleryPageParser.Result fetchPageResultFromHtml(int index, String pageUrl) throws Throwable {
GalleryPageParser.Result result = EhEngine.getGalleryPage(mHttpClient, pageUrl, mGalleryInfo.gid, mGalleryInfo.token);
GalleryPageParser.Result result = EhEngine.getGalleryPage(mHttpClient, pageUrl, mGalleryInfo.getGid(), mGalleryInfo.getToken());
if (StringUtils.endsWith(result.imageUrl, URL_509_SUFFIX_ARRAY)) {
// Get 509
// Notify listeners
@@ -56,7 +56,7 @@ public final class CommonOperations {
EhClient client = EhClient.INSTANCE;
EhRequest request = new EhRequest();
request.setMethod(EhClient.METHOD_ADD_FAVORITES);
request.setArgs(galleryInfo.gid, galleryInfo.token, slot, "");
request.setArgs(galleryInfo.getGid(), galleryInfo.getToken(), slot, "");
request.setCallback(listener);
request.enqueue(activity);
} else {
@@ -99,11 +99,11 @@ public final class CommonOperations {
public static void removeFromFavorites(Activity activity, GalleryInfo galleryInfo,
final EhClient.Callback<Void> listener) {
EhDB.removeLocalFavorites(galleryInfo.gid);
EhDB.removeLocalFavorites(galleryInfo.getGid());
EhClient client = EhClient.INSTANCE;
EhRequest request = new EhRequest();
request.setMethod(EhClient.METHOD_ADD_FAVORITES);
request.setArgs(galleryInfo.gid, galleryInfo.token, -1, "");
request.setArgs(galleryInfo.getGid(), galleryInfo.getToken(), -1, "");
request.setCallback(new DelegateFavoriteCallback(listener, galleryInfo, null, -2));
request.enqueue(activity);
}
@@ -125,8 +125,8 @@ public final class CommonOperations {
LongList toStart = new LongList();
List<GalleryInfo> toAdd = new ArrayList<>();
for (GalleryInfo gi : galleryInfos) {
if (dm.containDownloadInfo(gi.gid)) {
toStart.add(gi.gid);
if (dm.containDownloadInfo(gi.getGid())) {
toStart.add(gi.getGid());
} else {
toAdd.add(gi);
}
@@ -259,10 +259,10 @@ public final class CommonOperations {
@Override
public void onSuccess(Void result) {
info.favoriteName = newFavoriteName;
info.favoriteSlot = slot;
info.setFavoriteName(newFavoriteName);
info.setFavoriteSlot(slot);
delegate.onSuccess(result);
EhApplication.getFavouriteStatusRouter().modifyFavourites(info.gid, slot);
EhApplication.getFavouriteStatusRouter().modifyFavourites(info.getGid(), slot);
}
@Override
@@ -464,7 +464,7 @@ public class DownloadsScene extends BaseToolbarScene
for (int i = list.size() - 1; i > -1; i--) {
DownloadInfo info = list.get(i);
if (info.state != DownloadInfo.STATE_FINISH) {
gidList.add(info.gid);
gidList.add(info.getGid());
}
}
Intent intent = new Intent(activity, DownloadService.class);
@@ -652,7 +652,7 @@ public class DownloadsScene extends BaseToolbarScene
downloadInfoList.add(info);
}
if (collectGid) {
gidList.add(info.gid);
gidList.add(info.getGid());
}
}
}
@@ -995,9 +995,9 @@ public class DownloadsScene extends BaseToolbarScene
int i = 0;
for (DownloadInfo info : mDownloadInfoList) {
// Put file
files[i] = SpiderDen.getGalleryDownloadDir(info.gid);
files[i] = SpiderDen.getGalleryDownloadDir(info.getGid());
// Remove download path
EhDB.removeDownloadDirname(info.gid);
EhDB.removeDownloadDirname(info.getGid());
i++;
}
// Delete file
@@ -1106,7 +1106,7 @@ public class DownloadsScene extends BaseToolbarScene
ContextCompat.startForegroundService(activity, intent);
} else if (stop == v) {
if (null != mDownloadManager) {
mDownloadManager.stopDownload(list.get(index).gid);
mDownloadManager.stopDownload(list.get(index).getGid());
}
}
}
@@ -1133,7 +1133,7 @@ public class DownloadsScene extends BaseToolbarScene
if (mList == null || position < 0 || position >= mList.size()) {
return 0;
}
return mList.get(position).gid;
return mList.get(position).getGid();
}
@NonNull
@@ -1155,22 +1155,22 @@ public class DownloadsScene extends BaseToolbarScene
return;
}
DownloadInfo info = mList.get(position);
if (info.thumb != null) {
holder.thumb.load(EhCacheKeyFactory.getThumbKey(info.gid), info.thumb);
if (info.getThumb() != null) {
holder.thumb.load(EhCacheKeyFactory.getThumbKey(info.getGid()), info.getThumb());
}
holder.title.setText(EhUtils.getSuitableTitle(info));
holder.uploader.setText(info.uploader);
holder.rating.setRating(info.rating);
holder.uploader.setText(info.getUploader());
holder.rating.setRating(info.getRating());
TextView category = holder.category;
String newCategoryText = EhUtils.getCategory(info.category);
String newCategoryText = EhUtils.getCategory(info.getCategory());
if (!newCategoryText.contentEquals(category.getText())) {
category.setText(newCategoryText);
category.setBackgroundColor(EhUtils.getCategoryColor(info.category));
category.setBackgroundColor(EhUtils.getCategoryColor(info.getCategory()));
}
bindForState(holder, info);
// Update transition name
ViewCompat.setTransitionName(holder.thumb, TransitionNameFactory.getThumbTransitionName(info.gid));
ViewCompat.setTransitionName(holder.thumb, TransitionNameFactory.getThumbTransitionName(info.getGid()));
holder.itemView.setOnClickListener(v -> onItemClick(position));
holder.itemView.setOnLongClickListener(v -> onItemLongClick(position));
@@ -905,7 +905,7 @@ public class FavoritesScene extends SearchBarScene implements
if (mUrlBuilder.getFavCat() == FavListUrlBuilder.FAV_CAT_LOCAL) { // Delete local fav
long[] gidArray = new long[mModifyGiList.size()];
for (int i = 0, n = mModifyGiList.size(); i < n; i++) {
gidArray[i] = mModifyGiList.get(i).gid;
gidArray[i] = mModifyGiList.get(i).getGid();
}
EhDB.removeLocalFavorites(gidArray);
mModifyGiList.clear();
@@ -948,7 +948,7 @@ public class FavoritesScene extends SearchBarScene implements
if (srcCat == FavListUrlBuilder.FAV_CAT_LOCAL) { // Move from local to cloud
long[] gidArray = new long[mModifyGiList.size()];
for (int i = 0, n = mModifyGiList.size(); i < n; i++) {
gidArray[i] = mModifyGiList.get(i).gid;
gidArray[i] = mModifyGiList.get(i).getGid();
}
EhDB.removeLocalFavorites(gidArray);
mEnableModify = true;
@@ -1031,8 +1031,8 @@ public class FavoritesScene extends SearchBarScene implements
String[] tokenArray = new String[mModifyGiList.size()];
for (int i = 0, n = mModifyGiList.size(); i < n; i++) {
GalleryInfo gi = mModifyGiList.get(i);
gidArray[i] = gi.gid;
tokenArray[i] = gi.token;
gidArray[i] = gi.getGid();
tokenArray[i] = gi.getToken();
}
List<GalleryInfo> modifyGiListBackup = new ArrayList<>(mModifyGiList);
mModifyGiList.clear();
@@ -1046,7 +1046,7 @@ public class FavoritesScene extends SearchBarScene implements
request.enqueue(FavoritesScene.this);
} else {
for (int i = 0, n = mModifyGiList.size(); i < n; i++) {
gidArray[i] = mModifyGiList.get(i).gid;
gidArray[i] = mModifyGiList.get(i).getGid();
}
mModifyGiList.clear();
@@ -1115,7 +1115,7 @@ public class FavoritesScene extends SearchBarScene implements
@Override
protected boolean isDuplicate(GalleryInfo d1, GalleryInfo d2) {
return d1.gid == d2.gid;
return d1.getGid() == d2.getGid();
}
@Override
@@ -189,53 +189,53 @@ abstract class GalleryAdapter extends RecyclerView.Adapter<GalleryHolder> {
switch (mType) {
case TYPE_LIST -> {
holder.thumb.load(EhCacheKeyFactory.getThumbKey(gi.gid), gi.thumb);
holder.thumb.load(EhCacheKeyFactory.getThumbKey(gi.getGid()), gi.getThumb());
holder.title.setText(EhUtils.getSuitableTitle(gi));
holder.uploader.setText(gi.uploader);
holder.uploader.setAlpha(gi.disowned ? .5f : 1f);
holder.rating.setRating(gi.rating);
holder.uploader.setText(gi.getUploader());
holder.uploader.setAlpha(gi.getDisowned() ? .5f : 1f);
holder.rating.setRating(gi.getRating());
TextView category = holder.category;
String newCategoryText = EhUtils.getCategory(gi.category);
String newCategoryText = EhUtils.getCategory(gi.getCategory());
if (!newCategoryText.equals(category.getText().toString())) {
category.setText(newCategoryText);
category.setBackgroundColor(EhUtils.getCategoryColor(gi.category));
category.setBackgroundColor(EhUtils.getCategoryColor(gi.getCategory()));
}
holder.posted.setText(gi.posted);
if (gi.pages == 0 || !Settings.getShowGalleryPages()) {
holder.posted.setText(gi.getPosted());
if (gi.getPages() == 0 || !Settings.getShowGalleryPages()) {
holder.pages.setText(null);
holder.pages.setVisibility(View.GONE);
} else {
holder.pages.setText(gi.pages + "P");
holder.pages.setText(gi.getPages() + "P");
holder.pages.setVisibility(View.VISIBLE);
}
if (TextUtils.isEmpty(gi.simpleLanguage)) {
if (TextUtils.isEmpty(gi.getSimpleLanguage())) {
holder.simpleLanguage.setText(null);
holder.simpleLanguage.setVisibility(View.GONE);
} else {
holder.simpleLanguage.setText(gi.simpleLanguage);
holder.simpleLanguage.setText(gi.getSimpleLanguage());
holder.simpleLanguage.setVisibility(View.VISIBLE);
}
holder.favourited.setVisibility((mShowFavourited && gi.favoriteSlot >= -1 && gi.favoriteSlot <= 10) ? View.VISIBLE : View.GONE);
holder.downloaded.setVisibility(mDownloadManager.containDownloadInfo(gi.gid) ? View.VISIBLE : View.GONE);
holder.favourited.setVisibility((mShowFavourited && gi.getFavoriteSlot() >= -1 && gi.getFavoriteSlot() <= 10) ? View.VISIBLE : View.GONE);
holder.downloaded.setVisibility(mDownloadManager.containDownloadInfo(gi.getGid()) ? View.VISIBLE : View.GONE);
}
case TYPE_GRID -> {
((TileThumb) holder.thumb).setThumbSize(gi.thumbWidth, gi.thumbHeight);
holder.thumb.load(EhCacheKeyFactory.getThumbKey(gi.gid), gi.thumb);
((TileThumb) holder.thumb).setThumbSize(gi.getThumbWidth(), gi.getThumbHeight());
holder.thumb.load(EhCacheKeyFactory.getThumbKey(gi.getGid()), gi.getThumb());
View category = holder.category;
Drawable drawable = category.getBackground();
int color = EhUtils.getCategoryColor(gi.category);
int color = EhUtils.getCategoryColor(gi.getCategory());
if (!(drawable instanceof TriangleDrawable)) {
drawable = new TriangleDrawable(color);
category.setBackground(drawable);
} else {
((TriangleDrawable) drawable).setColor(color);
}
holder.simpleLanguage.setText(gi.simpleLanguage);
holder.simpleLanguage.setText(gi.getSimpleLanguage());
}
}
// Update transition name
ViewCompat.setTransitionName(holder.thumb, TransitionNameFactory.getThumbTransitionName(gi.gid));
ViewCompat.setTransitionName(holder.thumb, TransitionNameFactory.getThumbTransitionName(gi.getGid()));
}
@IntDef({TYPE_LIST, TYPE_GRID})
@@ -312,7 +312,7 @@ public final class GalleryCommentsScene extends BaseToolbarScene
EhRequest request = new EhRequest()
.setMethod(EhClient.METHOD_VOTE_COMMENT)
.setArgs(mGalleryDetail.apiUid, mGalleryDetail.apiKey, mGalleryDetail.gid, mGalleryDetail.token, id, vote)
.setArgs(mGalleryDetail.apiUid, mGalleryDetail.apiKey, mGalleryDetail.getGid(), mGalleryDetail.getToken(), id, vote)
.setCallback(new VoteCommentListener(context,
activity.getStageId(), getTag()));
request.enqueue(this);
@@ -599,8 +599,8 @@ public final class GalleryCommentsScene extends BaseToolbarScene
@Nullable
private String getGalleryDetailUrl() {
if (mGalleryDetail != null && mGalleryDetail.gid != -1 && mGalleryDetail.token != null) {
return EhUrl.getGalleryDetailUrl(mGalleryDetail.gid, mGalleryDetail.token, 0, mShowAllComments);
if (mGalleryDetail != null && mGalleryDetail.getGid() != -1 && mGalleryDetail.getToken() != null) {
return EhUrl.getGalleryDetailUrl(mGalleryDetail.getGid(), mGalleryDetail.getToken(), 0, mShowAllComments);
} else {
return null;
}
@@ -335,11 +335,11 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
long gid;
String token;
if (mGalleryDetail != null) {
gid = mGalleryDetail.gid;
token = mGalleryDetail.token;
gid = mGalleryDetail.getGid();
token = mGalleryDetail.getToken();
} else if (mGalleryInfo != null) {
gid = mGalleryInfo.gid;
token = mGalleryInfo.token;
gid = mGalleryInfo.getGid();
token = mGalleryInfo.getToken();
} else if (ACTION_GID_TOKEN.equals(mAction)) {
gid = mGid;
token = mToken;
@@ -352,9 +352,9 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
// -1 for error
private long getGid() {
if (mGalleryDetail != null) {
return mGalleryDetail.gid;
return mGalleryDetail.getGid();
} else if (mGalleryInfo != null) {
return mGalleryInfo.gid;
return mGalleryInfo.getGid();
} else if (ACTION_GID_TOKEN.equals(mAction)) {
return mGid;
} else {
@@ -364,9 +364,9 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
private String getUploader() {
if (mGalleryDetail != null) {
return mGalleryDetail.uploader;
return mGalleryDetail.getUploader();
} else if (mGalleryInfo != null) {
return mGalleryInfo.uploader;
return mGalleryInfo.getUploader();
} else {
return null;
}
@@ -380,9 +380,9 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
// -1 for error
private int getCategory() {
if (mGalleryDetail != null) {
return mGalleryDetail.category;
return mGalleryDetail.getCategory();
} else if (mGalleryInfo != null) {
return mGalleryInfo.category;
return mGalleryInfo.getCategory();
} else {
return -1;
}
@@ -776,12 +776,12 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
if (ACTION_GALLERY_INFO.equals(mAction) && mGalleryInfo != null) {
GalleryInfo gi = mGalleryInfo;
mThumb.load(EhCacheKeyFactory.getThumbKey(gi.gid), gi.thumb);
mThumb.load(EhCacheKeyFactory.getThumbKey(gi.getGid()), gi.getThumb());
setTitle(EhUtils.getSuitableTitle(gi));
mUploader.setText(gi.uploader);
mUploader.setAlpha(gi.disowned ? .5f : 1f);
mCategory.setText(EhUtils.getCategory(gi.category));
mCategory.setTextColor(EhUtils.getCategoryColor(gi.category));
mUploader.setText(gi.getUploader());
mUploader.setAlpha(gi.getDisowned() ? .5f : 1f);
mCategory.setText(EhUtils.getCategory(gi.getCategory()));
mCategory.setTextColor(EhUtils.getCategoryColor(gi.getCategory()));
updateDownloadText();
}
}
@@ -795,12 +795,12 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
return;
}
if (gd.isFavorited || EhDB.containLocalFavorites(gd.gid)) {
if (gd.isFavorited || EhDB.containLocalFavorites(gd.getGid())) {
mHeart.setVisibility(View.VISIBLE);
if (gd.favoriteName == null) {
if (gd.getFavoriteName() == null) {
mHeart.setText(R.string.local_favorites);
} else {
mHeart.setText(gd.favoriteName);
mHeart.setText(gd.getFavoriteName());
}
mHeartOutline.setVisibility(View.GONE);
} else {
@@ -833,26 +833,26 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
Resources resources = getResources();
mThumb.load(EhCacheKeyFactory.getThumbKey(gd.gid), gd.thumb, true);
mThumb.load(EhCacheKeyFactory.getThumbKey(gd.getGid()), gd.getThumb(), true);
setTitle(EhUtils.getSuitableTitle(gd));
mUploader.setText(gd.uploader);
mUploader.setAlpha(gd.disowned ? .5f : 1f);
mCategory.setText(EhUtils.getCategory(gd.category));
mCategory.setTextColor(EhUtils.getCategoryColor(gd.category));
mUploader.setText(gd.getUploader());
mUploader.setAlpha(gd.getDisowned() ? .5f : 1f);
mCategory.setText(EhUtils.getCategory(gd.getCategory()));
mCategory.setTextColor(EhUtils.getCategoryColor(gd.getCategory()));
updateDownloadText();
mLanguage.setText(gd.language);
mPages.setText(resources.getQuantityString(
R.plurals.page_count, gd.pages, gd.pages));
R.plurals.page_count, gd.getPages(), gd.getPages()));
mSize.setText(gd.size);
mPosted.setText(gd.posted);
mPosted.setText(gd.getPosted());
mFavoredTimes.setText(resources.getString(R.string.favored_times, gd.favoriteCount));
if (gd.newerVersions != null && gd.newerVersions.size() != 0) {
mNewerVersion.setVisibility(View.VISIBLE);
}
mRatingText.setText(getAllRatingText(gd.rating, gd.ratingCount));
mRating.setRating(gd.rating);
mRatingText.setText(getAllRatingText(gd.getRating(), gd.ratingCount));
mRating.setRating(gd.getRating());
updateFavoriteDrawable();
@@ -985,7 +985,7 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
mGridLayout.addView(view);
LoadImageView image = view.findViewById(R.id.image);
previewSet.load(image, gd.gid, i);
previewSet.load(image, gd.getGid(), i);
image.setTag(R.id.index, i);
image.setOnClickListener(this);
TextView text = view.findViewById(R.id.text);
@@ -1002,7 +1002,7 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
if (null == gd) {
return;
}
String keyword = EhUtils.extractTitle(gd.title);
String keyword = EhUtils.extractTitle(gd.getTitle());
if (null != keyword) {
ListUrlBuilder lub = new ListUrlBuilder();
lub.setMode(ListUrlBuilder.MODE_NORMAL);
@@ -1018,10 +1018,10 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
GalleryListScene.startScene(this, lub);
return;
}
if (null != gd.uploader) {
if (null != gd.getUploader()) {
ListUrlBuilder lub = new ListUrlBuilder();
lub.setMode(ListUrlBuilder.MODE_UPLOADER);
lub.setKeyword(gd.uploader);
lub.setKeyword(gd.getUploader());
GalleryListScene.startScene(this, lub);
}
}
@@ -1080,11 +1080,11 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
} else if (mDownload == v) {
GalleryInfo galleryInfo = getGalleryInfo();
if (galleryInfo != null) {
if (EhApplication.getDownloadManager().getDownloadState(galleryInfo.gid) == DownloadInfo.STATE_INVALID) {
if (EhApplication.getDownloadManager().getDownloadState(galleryInfo.getGid()) == DownloadInfo.STATE_INVALID) {
CommonOperations.startDownload(activity, galleryInfo, false);
} else {
CheckBoxDialogBuilder builder = new CheckBoxDialogBuilder(context,
getString(R.string.download_remove_dialog_message, galleryInfo.title),
getString(R.string.download_remove_dialog_message, galleryInfo.getTitle()),
getString(R.string.download_remove_dialog_check_text),
Settings.getRemoveImageFiles());
DeleteDialogHelper helper = new DeleteDialogHelper(
@@ -1111,15 +1111,15 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
if (mGalleryDetail != null) {
ArrayList<CharSequence> titles = new ArrayList<>();
for (GalleryInfo newerVersion : mGalleryDetail.newerVersions) {
titles.add(getString(R.string.newer_version_title, newerVersion.title, newerVersion.posted));
titles.add(getString(R.string.newer_version_title, newerVersion.getTitle(), newerVersion.getPosted()));
}
new BaseDialogBuilder(requireContext())
.setItems(titles.toArray(new CharSequence[0]), (dialog, which) -> {
GalleryInfo newerVersion = mGalleryDetail.newerVersions.get(which);
Bundle args = new Bundle();
args.putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GID_TOKEN);
args.putLong(GalleryDetailScene.KEY_GID, newerVersion.gid);
args.putString(GalleryDetailScene.KEY_TOKEN, newerVersion.token);
args.putLong(GalleryDetailScene.KEY_GID, newerVersion.getGid());
args.putString(GalleryDetailScene.KEY_TOKEN, newerVersion.getToken());
startScene(new Announcer(GalleryDetailScene.class).setArgs(args));
})
.show();
@@ -1131,7 +1131,7 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
} else if (mHeart == v || mHeartOutline == v) {
if (mGalleryDetail != null && !mModifyingFavorites) {
boolean remove = false;
if (EhDB.containLocalFavorites(mGalleryDetail.gid) || mGalleryDetail.isFavorited) {
if (EhDB.containLocalFavorites(mGalleryDetail.getGid()) || mGalleryDetail.isFavorited) {
mModifyingFavorites = true;
CommonOperations.removeFromFavorites(activity, mGalleryDetail,
new ModifyFavoritesListener(context,
@@ -1197,7 +1197,7 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(android.R.string.ok, helper)
.show();
helper.setDialog(dialog, mGalleryDetail.rating);
helper.setDialog(dialog, mGalleryDetail.getRating());
} else if (mSimilar == v) {
showSimilarGalleryList();
} else if (mSearchCover == v) {
@@ -1209,8 +1209,8 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
Bundle args = new Bundle();
args.putLong(GalleryCommentsScene.KEY_API_UID, mGalleryDetail.apiUid);
args.putString(GalleryCommentsScene.KEY_API_KEY, mGalleryDetail.apiKey);
args.putLong(GalleryCommentsScene.KEY_GID, mGalleryDetail.gid);
args.putString(GalleryCommentsScene.KEY_TOKEN, mGalleryDetail.token);
args.putLong(GalleryCommentsScene.KEY_GID, mGalleryDetail.getGid());
args.putString(GalleryCommentsScene.KEY_TOKEN, mGalleryDetail.getToken());
args.putParcelable(GalleryCommentsScene.KEY_COMMENT_LIST, mGalleryDetail.comments);
args.putParcelable(GalleryCommentsScene.KEY_GALLERY_DETAIL, mGalleryDetail);
startScene(new Announcer(GalleryCommentsScene.class)
@@ -1353,7 +1353,7 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
EhRequest request = new EhRequest()
.setMethod(EhClient.METHOD_VOTE_TAG)
.setArgs(mGalleryDetail.apiUid, mGalleryDetail.apiKey, mGalleryDetail.gid, mGalleryDetail.token, tag, vote)
.setArgs(mGalleryDetail.apiUid, mGalleryDetail.apiKey, mGalleryDetail.getGid(), mGalleryDetail.getToken(), tag, vote)
.setCallback(new VoteTagListener(context,
activity.getStageId(), getTag()));
request.enqueue(this);
@@ -1380,7 +1380,7 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
} else if (mHeart == v || mHeartOutline == v) {
if (mGalleryDetail != null && !mModifyingFavorites) {
boolean remove = false;
if (EhDB.containLocalFavorites(mGalleryDetail.gid) || mGalleryDetail.isFavorited) {
if (EhDB.containLocalFavorites(mGalleryDetail.getGid()) || mGalleryDetail.isFavorited) {
mModifyingFavorites = true;
CommonOperations.removeFromFavorites(activity, mGalleryDetail,
new ModifyFavoritesListener(activity,
@@ -1510,7 +1510,7 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
private void onRateGallerySuccess(RateGalleryParser.Result result) {
if (mGalleryDetail != null) {
mGalleryDetail.rating = result.rating;
mGalleryDetail.setRating(result.rating);
mGalleryDetail.ratingCount = result.ratingCount;
}
@@ -1524,7 +1524,7 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
private void onModifyFavoritesSuccess(boolean addOrRemove) {
mModifyingFavorites = false;
if (mGalleryDetail != null) {
mGalleryDetail.isFavorited = !addOrRemove && mGalleryDetail.favoriteName != null;
mGalleryDetail.isFavorited = !addOrRemove && mGalleryDetail.getFavoriteName() != null;
updateFavoriteDrawable();
}
}
@@ -1563,7 +1563,7 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
getApplication().removeGlobalStuff(this);
// Put gallery detail to cache
EhApplication.getGalleryDetailCache().put(result.gid, result);
EhApplication.getGalleryDetailCache().put(result.getGid(), result);
// Add history
EhDB.putHistoryInfo(result);
@@ -1645,7 +1645,7 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
// Update rating in cache
GalleryDetail gd = EhApplication.getGalleryDetailCache().get(mGid);
if (gd != null) {
gd.rating = result.rating;
gd.setRating(result.rating);
gd.ratingCount = result.ratingCount;
}
}
@@ -1727,7 +1727,7 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
if (result != null) {
// TODO: Don't use buggy system download service
DownloadManager.Request r = new DownloadManager.Request(Uri.parse(result));
var name = mGalleryInfo.gid + "-" + EhUtils.getSuitableTitle(mGalleryInfo) + ".zip";
var name = mGalleryInfo.getGid() + "-" + EhUtils.getSuitableTitle(mGalleryInfo) + ".zip";
r.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS,
FileUtils.sanitizeFilename(name));
r.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
@@ -1783,15 +1783,15 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
// Delete
if (null != mDownloadManager) {
mDownloadManager.deleteDownload(mGalleryInfo.gid);
mDownloadManager.deleteDownload(mGalleryInfo.getGid());
}
// Delete image files
boolean checked = mBuilder.isChecked();
Settings.putRemoveImageFiles(checked);
if (checked) {
UniFile file = SpiderDen.getGalleryDownloadDir(mGalleryInfo.gid);
EhDB.removeDownloadDirname(mGalleryInfo.gid);
UniFile file = SpiderDen.getGalleryDownloadDir(mGalleryInfo.getGid());
EhDB.removeDownloadDirname(mGalleryInfo.getGid());
deleteFileAsync(file);
}
}
@@ -1861,7 +1861,7 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
boolean isHAtH = mArchiveList.get(position).isHAtH();
EhRequest request = new EhRequest();
request.setMethod(EhClient.METHOD_DOWNLOAD_ARCHIVE);
request.setArgs(mGalleryDetail.gid, mGalleryDetail.token, mArchiveFormParamOr, res, isHAtH);
request.setArgs(mGalleryDetail.getGid(), mGalleryDetail.getToken(), mArchiveFormParamOr, res, isHAtH);
request.setCallback(new DownloadArchiveListener(context, activity.getStageId(), getTag(), mGalleryDetail));
request.enqueue(GalleryDetailScene.this);
}
@@ -2071,9 +2071,9 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
EhRequest request = new EhRequest()
.setMethod(EhClient.METHOD_GET_RATE_GALLERY)
.setArgs(mGalleryDetail.apiUid, mGalleryDetail.apiKey,
mGalleryDetail.gid, mGalleryDetail.token, mRatingBar.getRating())
mGalleryDetail.getGid(), mGalleryDetail.getToken(), mRatingBar.getRating())
.setCallback(new RateGalleryListener(context,
activity.getStageId(), getTag(), mGalleryDetail.gid));
activity.getStageId(), getTag(), mGalleryDetail.getGid()));
request.enqueue(GalleryDetailScene.this);
}
}
@@ -671,7 +671,7 @@ public final class GalleryListScene extends SearchBarScene
}
var gi = mHelper.getFirstVisibleItem();
var next = gi != null ? "@" + (gi.gid + 1) : null;
var next = gi != null ? "@" + (gi.getGid() + 1) : null;
// Check duplicate
for (QuickSearch q : mQuickSearchList) {
@@ -933,8 +933,8 @@ public final class GalleryListScene extends SearchBarScene
return true;
}
boolean downloaded = mDownloadManager.getDownloadState(gi.gid) != DownloadInfo.STATE_INVALID;
boolean favourited = gi.favoriteSlot != -2;
boolean downloaded = mDownloadManager.getDownloadState(gi.getGid()) != DownloadInfo.STATE_INVALID;
boolean favourited = gi.getFavoriteSlot() != -2;
CharSequence[] items = downloaded ? new CharSequence[]{
context.getString(R.string.read),
@@ -972,8 +972,8 @@ public final class GalleryListScene extends SearchBarScene
if (downloaded) {
new BaseDialogBuilder(context)
.setTitle(R.string.download_remove_dialog_title)
.setMessage(getString(R.string.download_remove_dialog_message, gi.title))
.setPositiveButton(android.R.string.ok, (dialog1, which1) -> mDownloadManager.deleteDownload(gi.gid))
.setMessage(getString(R.string.download_remove_dialog_message, gi.getTitle()))
.setPositiveButton(android.R.string.ok, (dialog1, which1) -> mDownloadManager.deleteDownload(gi.getGid()))
.show();
} else {
CommonOperations.startDownload(activity, gi, false);
@@ -1387,7 +1387,7 @@ public final class GalleryListScene extends SearchBarScene
}
DownloadManager downloadManager = EhApplication.getDownloadManager();
DownloadInfo downloadInfo = downloadManager.getDownloadInfo(mGi.gid);
DownloadInfo downloadInfo = downloadManager.getDownloadInfo(mGi.getGid());
if (downloadInfo == null) {
return;
}
@@ -1632,7 +1632,7 @@ public final class GalleryListScene extends SearchBarScene
@Override
protected boolean isDuplicate(GalleryInfo d1, GalleryInfo d2) {
return d1.gid == d2.gid;
return d1.getGid() == d2.getGid();
}
@Override
@@ -238,7 +238,7 @@ public class GalleryPreviewsScene extends BaseToolbarScene {
int size = previewSet.size();
ArrayList<GalleryPreview> list = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
list.add(previewSet.getGalleryPreview(mGalleryInfo.gid, i));
list.add(previewSet.getGalleryPreview(mGalleryInfo.getGid(), i));
}
mHelper.onGetPageData(taskId, result.second, 0, null, null, list);
@@ -344,7 +344,7 @@ public class GalleryPreviewsScene extends BaseToolbarScene {
return;
}
String url = EhUrl.getGalleryDetailUrl(mGalleryInfo.gid, mGalleryInfo.token, page, false);
String url = EhUrl.getGalleryDetailUrl(mGalleryInfo.getGid(), mGalleryInfo.getToken(), page, false);
EhRequest request = new EhRequest();
request.setMethod(EhClient.METHOD_GET_PREVIEW_SET);
request.setCallback(new GetPreviewSetListener(getContext(),