From 2fa0a19d3b3aa2753e9fc1492bc7394e214b382d Mon Sep 17 00:00:00 2001 From: tarsin Date: Thu, 5 Jan 2023 18:45:45 +0800 Subject: [PATCH] Convert DAO to kotlin, step 1 --- .../main/java/com/hippo/ehviewer/EhDB.java | 12 +- .../com/hippo/ehviewer/dao/BookmarkInfo.kt | 135 +--------- .../com/hippo/ehviewer/dao/DownloadDirname.kt | 33 +-- .../com/hippo/ehviewer/dao/DownloadInfo.kt | 253 ++++-------------- .../java/com/hippo/ehviewer/dao/Filter.kt | 77 ++---- .../com/hippo/ehviewer/dao/HistoryInfo.kt | 150 +++-------- .../hippo/ehviewer/dao/LocalFavoriteInfo.kt | 132 ++------- .../com/hippo/ehviewer/dao/QuickSearch.kt | 129 ++------- .../ehviewer/ui/fragment/FilterFragment.kt | 4 +- .../ehviewer/ui/scene/DownloadsScene.java | 2 +- .../ehviewer/ui/scene/GalleryListScene.java | 14 +- 11 files changed, 190 insertions(+), 751 deletions(-) diff --git a/app/src/main/java/com/hippo/ehviewer/EhDB.java b/app/src/main/java/com/hippo/ehviewer/EhDB.java index f8ca2d32e..d9c5ff8c6 100644 --- a/app/src/main/java/com/hippo/ehviewer/EhDB.java +++ b/app/src/main/java/com/hippo/ehviewer/EhDB.java @@ -281,9 +281,9 @@ public class EhDB { public static synchronized void insertQuickSearch(QuickSearch quickSearch) { QuickSearchDao dao = db.quickSearchDao(); - quickSearch.id = null; - quickSearch.time = System.currentTimeMillis(); - quickSearch.id = dao.insert(quickSearch); + quickSearch.setId(null); + quickSearch.setTime(System.currentTimeMillis()); + quickSearch.setId(dao.insert(quickSearch)); } public static synchronized void importQuickSearch(List quickSearchList) { @@ -386,7 +386,7 @@ public class EhDB { } public static synchronized void triggerFilter(Filter filter) { - filter.setEnable(!filter.enable); + filter.enable = !filter.enable; db.filterDao().update(filter); } @@ -521,9 +521,9 @@ public class EhDB { List currentQuickSearchList = db.quickSearchDao().list(); List importList = new ArrayList<>(); for (QuickSearch quickSearch : quickSearchList) { - String name = quickSearch.name; + String name = quickSearch.getName(); for (QuickSearch q : currentQuickSearchList) { - if (ObjectUtils.equal(q.name, name)) { + if (ObjectUtils.equal(q.getName(), name)) { // The same name name = null; break; diff --git a/app/src/main/java/com/hippo/ehviewer/dao/BookmarkInfo.kt b/app/src/main/java/com/hippo/ehviewer/dao/BookmarkInfo.kt index f55495324..9389190d0 100644 --- a/app/src/main/java/com/hippo/ehviewer/dao/BookmarkInfo.kt +++ b/app/src/main/java/com/hippo/ehviewer/dao/BookmarkInfo.kt @@ -1,129 +1,16 @@ -package com.hippo.ehviewer.dao; +package com.hippo.ehviewer.dao -import androidx.room.ColumnInfo; -import androidx.room.Entity; - -import com.hippo.ehviewer.client.data.GalleryInfo; +import androidx.room.ColumnInfo +import androidx.room.Entity +import com.hippo.ehviewer.client.data.GalleryInfo @Entity(tableName = "BOOKMARKS") -public class BookmarkInfo extends GalleryInfo { +class BookmarkInfo : GalleryInfo() { + @JvmField @ColumnInfo(name = "PAGE") - public int page; + var page = 0 + + @JvmField @ColumnInfo(name = "TIME") - public long time; - - public BookmarkInfo(GalleryInfo galleryInfo) { - this.gid = galleryInfo.gid; - this.token = galleryInfo.token; - this.title = galleryInfo.title; - this.titleJpn = galleryInfo.titleJpn; - this.thumb = galleryInfo.thumb; - this.category = galleryInfo.category; - this.posted = galleryInfo.posted; - this.uploader = galleryInfo.uploader; - this.rating = galleryInfo.rating; - this.simpleTags = galleryInfo.simpleTags; - this.simpleLanguage = galleryInfo.simpleLanguage; - } - - public BookmarkInfo(int page, long time) { - this.page = page; - this.time = time; - } - - public long getGid() { - return gid; - } - - public void setGid(long gid) { - this.gid = gid; - } - - public String getToken() { - return token; - } - - public void setToken(String token) { - this.token = token; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getTitleJpn() { - return titleJpn; - } - - public void setTitleJpn(String titleJpn) { - this.titleJpn = titleJpn; - } - - public String getThumb() { - return thumb; - } - - public void setThumb(String thumb) { - this.thumb = thumb; - } - - public int getCategory() { - return category; - } - - public void setCategory(int category) { - this.category = category; - } - - public String getPosted() { - return posted; - } - - public void setPosted(String posted) { - this.posted = posted; - } - - public String getUploader() { - return uploader; - } - - public void setUploader(String uploader) { - this.uploader = uploader; - } - - public float getRating() { - return rating; - } - - public void setRating(float rating) { - this.rating = rating; - } - - public String getSimpleLanguage() { - return simpleLanguage; - } - - public void setSimpleLanguage(String simpleLanguage) { - this.simpleLanguage = simpleLanguage; - } - - public int getPage() { - return page; - } - - public void setPage(int page) { - this.page = page; - } - - public long getTime() { - return time; - } - - public void setTime(long time) { - this.time = time; - } -} + var time: Long = 0 +} \ No newline at end of file diff --git a/app/src/main/java/com/hippo/ehviewer/dao/DownloadDirname.kt b/app/src/main/java/com/hippo/ehviewer/dao/DownloadDirname.kt index 049c4d7cd..d442f511a 100644 --- a/app/src/main/java/com/hippo/ehviewer/dao/DownloadDirname.kt +++ b/app/src/main/java/com/hippo/ehviewer/dao/DownloadDirname.kt @@ -1,30 +1,15 @@ -package com.hippo.ehviewer.dao; +package com.hippo.ehviewer.dao -import androidx.room.ColumnInfo; -import androidx.room.Entity; -import androidx.room.PrimaryKey; +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.PrimaryKey @Entity(tableName = "DOWNLOAD_DIRNAME") -public class DownloadDirname { +class DownloadDirname { @PrimaryKey @ColumnInfo(name = "GID") - private long gid; + var gid: Long = 0 + @ColumnInfo(name = "DIRNAME") - private String dirname; - - public long getGid() { - return gid; - } - - public void setGid(long gid) { - this.gid = gid; - } - - public String getDirname() { - return dirname; - } - - public void setDirname(String dirname) { - this.dirname = dirname; - } -} + var dirname: String? = null +} \ No newline at end of file diff --git a/app/src/main/java/com/hippo/ehviewer/dao/DownloadInfo.kt b/app/src/main/java/com/hippo/ehviewer/dao/DownloadInfo.kt index 64084f446..ff361df9a 100644 --- a/app/src/main/java/com/hippo/ehviewer/dao/DownloadInfo.kt +++ b/app/src/main/java/com/hippo/ehviewer/dao/DownloadInfo.kt @@ -1,217 +1,68 @@ -package com.hippo.ehviewer.dao; +package com.hippo.ehviewer.dao -import androidx.room.ColumnInfo; -import androidx.room.Entity; -import androidx.room.Ignore; - -import com.hippo.ehviewer.client.data.GalleryInfo; +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.Ignore +import com.hippo.ehviewer.client.data.GalleryInfo @Entity(tableName = "DOWNLOADS") -public class DownloadInfo extends GalleryInfo { - public static final int STATE_INVALID = -1; - public static final int STATE_NONE = 0; - public static final int STATE_WAIT = 1; - public static final int STATE_DOWNLOAD = 2; - public static final int STATE_FINISH = 3; - public static final int STATE_FAILED = 4; +class DownloadInfo() : GalleryInfo() { + @JvmField @ColumnInfo(name = "STATE") - public int state; + var state = 0 + + @JvmField @ColumnInfo(name = "LEGACY") - public int legacy; + var legacy = 0 + + @JvmField @ColumnInfo(name = "TIME") - public long time; + var time: Long = 0 + + @JvmField @ColumnInfo(name = "LABEL") - public String label; + var label: String? = null + + @JvmField @Ignore - public long speed; + var speed: Long = 0 + + @JvmField @Ignore - public long remaining; + var remaining: Long = 0 + + @JvmField @Ignore - public int finished; + var finished = 0 + + @JvmField @Ignore - public int downloaded; + var downloaded = 0 + + @JvmField @Ignore - public int total; + var total = 0 - DownloadInfo() { + constructor(galleryInfo: GalleryInfo) : this() { + gid = galleryInfo.gid + token = galleryInfo.token + title = galleryInfo.title + titleJpn = galleryInfo.titleJpn + thumb = galleryInfo.thumb + this.category = galleryInfo.category + posted = galleryInfo.posted + uploader = galleryInfo.uploader + rating = galleryInfo.rating + simpleTags = galleryInfo.simpleTags + simpleLanguage = galleryInfo.simpleLanguage } - public DownloadInfo(GalleryInfo galleryInfo) { - this.gid = galleryInfo.gid; - this.token = galleryInfo.token; - this.title = galleryInfo.title; - this.titleJpn = galleryInfo.titleJpn; - this.thumb = galleryInfo.thumb; - this.category = galleryInfo.category; - this.posted = galleryInfo.posted; - this.uploader = galleryInfo.uploader; - this.rating = galleryInfo.rating; - this.simpleTags = galleryInfo.simpleTags; - this.simpleLanguage = galleryInfo.simpleLanguage; + companion object { + const val STATE_INVALID = -1 + const val STATE_NONE = 0 + const val STATE_WAIT = 1 + const val STATE_DOWNLOAD = 2 + const val STATE_FINISH = 3 + const val STATE_FAILED = 4 } - - public DownloadInfo(int state, int legacy, long time, String label, long speed, long remaining, - int finished, int downloaded, int total) { - this.state = state; - this.legacy = legacy; - this.time = time; - this.label = label; - this.speed = speed; - this.remaining = remaining; - this.finished = finished; - this.downloaded = downloaded; - this.total = total; - } - - public long getGid() { - return gid; - } - - public void setGid(long gid) { - this.gid = gid; - } - - public String getToken() { - return token; - } - - public void setToken(String token) { - this.token = token; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getTitleJpn() { - return titleJpn; - } - - public void setTitleJpn(String titleJpn) { - this.titleJpn = titleJpn; - } - - public String getThumb() { - return thumb; - } - - public void setThumb(String thumb) { - this.thumb = thumb; - } - - public int getCategory() { - return category; - } - - public void setCategory(int category) { - this.category = category; - } - - public String getPosted() { - return posted; - } - - public void setPosted(String posted) { - this.posted = posted; - } - - public String getUploader() { - return uploader; - } - - public void setUploader(String uploader) { - this.uploader = uploader; - } - - public float getRating() { - return rating; - } - - public void setRating(float rating) { - this.rating = rating; - } - - public String getSimpleLanguage() { - return simpleLanguage; - } - - public void setSimpleLanguage(String simpleLanguage) { - this.simpleLanguage = simpleLanguage; - } - - public int getState() { - return state; - } - - public void setState(int state) { - this.state = state; - } - - public int getLegacy() { - return legacy; - } - - public void setLegacy(int legacy) { - this.legacy = legacy; - } - - public long getTime() { - return time; - } - - public void setTime(long time) { - this.time = time; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public long getSpeed() { - return this.speed; - } - - public void setSpeed(long speed) { - this.speed = speed; - } - - public long getRemaining() { - return this.remaining; - } - - public void setRemaining(long remaining) { - this.remaining = remaining; - } - - public int getFinished() { - return this.finished; - } - - public void setFinished(int finished) { - this.finished = finished; - } - - public int getDownloaded() { - return this.downloaded; - } - - public void setDownloaded(int downloaded) { - this.downloaded = downloaded; - } - - public int getTotal() { - return this.total; - } - - public void setTotal(int total) { - this.total = total; - } -} +} \ No newline at end of file diff --git a/app/src/main/java/com/hippo/ehviewer/dao/Filter.kt b/app/src/main/java/com/hippo/ehviewer/dao/Filter.kt index 6128f8c1c..40b60ac6a 100644 --- a/app/src/main/java/com/hippo/ehviewer/dao/Filter.kt +++ b/app/src/main/java/com/hippo/ehviewer/dao/Filter.kt @@ -1,66 +1,35 @@ -package com.hippo.ehviewer.dao; +package com.hippo.ehviewer.dao -import androidx.room.ColumnInfo; -import androidx.room.Entity; -import androidx.room.PrimaryKey; - -import com.hippo.util.HashCodeUtils; -import com.hippo.yorozuya.ObjectUtils; +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.PrimaryKey +import com.hippo.util.HashCodeUtils @Entity(tableName = "FILTER") -public class Filter { +class Filter { + @JvmField @ColumnInfo(name = "MODE") - public int mode; + var mode = 0 + + @JvmField @ColumnInfo(name = "TEXT") - public String text; + var text: String? = null + + @JvmField @ColumnInfo(name = "ENABLE") - public Boolean enable; + var enable: Boolean? = null + @PrimaryKey @ColumnInfo(name = "_id") - private Long id; - - public Long getId() { - return id; + var id: Long? = null + override fun hashCode(): Int { + return HashCodeUtils.hashCode(mode, text) } - public void setId(Long id) { - this.id = id; - } - - public int getMode() { - return mode; - } - - public void setMode(int mode) { - this.mode = mode; - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - public Boolean getEnable() { - return enable; - } - - public void setEnable(Boolean enable) { - this.enable = enable; - } - - @Override - public int hashCode() { - return HashCodeUtils.hashCode(mode, text); - } - - @Override - public boolean equals(Object o) { - if (!(o instanceof Filter filter)) { - return false; + override fun equals(other: Any?): Boolean { + if (other !is Filter) { + return false } - return filter.mode == mode && ObjectUtils.equal(filter.text, text); + return other.mode == mode && other.text == text } -} +} \ No newline at end of file diff --git a/app/src/main/java/com/hippo/ehviewer/dao/HistoryInfo.kt b/app/src/main/java/com/hippo/ehviewer/dao/HistoryInfo.kt index a03ad3909..11a223ace 100644 --- a/app/src/main/java/com/hippo/ehviewer/dao/HistoryInfo.kt +++ b/app/src/main/java/com/hippo/ehviewer/dao/HistoryInfo.kt @@ -1,131 +1,41 @@ -package com.hippo.ehviewer.dao; +package com.hippo.ehviewer.dao -import androidx.room.ColumnInfo; -import androidx.room.Entity; - -import com.hippo.ehviewer.client.data.GalleryInfo; +import androidx.room.ColumnInfo +import androidx.room.Entity +import com.hippo.ehviewer.client.data.GalleryInfo @Entity(tableName = "HISTORY") -public class HistoryInfo extends GalleryInfo { +class HistoryInfo() : GalleryInfo() { + @JvmField @ColumnInfo(name = "TIME") - public long time; - // Use MODE for favoriteSlot + var time: Long = 0 + + // Trick: Use MODE for favoriteSlot + // Shadow its accessors @ColumnInfo(name = "MODE") - private int mode; + private val mode: Int = 0 - public HistoryInfo(GalleryInfo galleryInfo) { - this.gid = galleryInfo.gid; - this.token = galleryInfo.token; - this.title = galleryInfo.title; - this.titleJpn = galleryInfo.titleJpn; - this.thumb = galleryInfo.thumb; - this.category = galleryInfo.category; - this.posted = galleryInfo.posted; - this.uploader = galleryInfo.uploader; - this.rating = galleryInfo.rating; - this.simpleTags = galleryInfo.simpleTags; - this.simpleLanguage = galleryInfo.simpleLanguage; - this.favoriteSlot = galleryInfo.favoriteSlot; + fun getMode(): Int { + return favoriteSlot + 2 } - public HistoryInfo(int mode, long time) { - this.favoriteSlot = mode - 2; - this.time = time; + fun setMode(mode: Int) { + favoriteSlot = mode - 2 } + // Trick end - public long getGid() { - return gid; + constructor(galleryInfo: GalleryInfo) : this() { + gid = galleryInfo.gid + token = galleryInfo.token + title = galleryInfo.title + titleJpn = galleryInfo.titleJpn + thumb = galleryInfo.thumb + this.category = galleryInfo.category + posted = galleryInfo.posted + uploader = galleryInfo.uploader + rating = galleryInfo.rating + simpleTags = galleryInfo.simpleTags + simpleLanguage = galleryInfo.simpleLanguage + favoriteSlot = galleryInfo.favoriteSlot } - - public void setGid(long gid) { - this.gid = gid; - } - - public String getToken() { - return token; - } - - public void setToken(String token) { - this.token = token; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getTitleJpn() { - return titleJpn; - } - - public void setTitleJpn(String titleJpn) { - this.titleJpn = titleJpn; - } - - public String getThumb() { - return thumb; - } - - public void setThumb(String thumb) { - this.thumb = thumb; - } - - public int getCategory() { - return category; - } - - public void setCategory(int category) { - this.category = category; - } - - public String getPosted() { - return posted; - } - - public void setPosted(String posted) { - this.posted = posted; - } - - public String getUploader() { - return uploader; - } - - public void setUploader(String uploader) { - this.uploader = uploader; - } - - public float getRating() { - return rating; - } - - public void setRating(float rating) { - this.rating = rating; - } - - public String getSimpleLanguage() { - return simpleLanguage; - } - - public void setSimpleLanguage(String simpleLanguage) { - this.simpleLanguage = simpleLanguage; - } - - public int getMode() { - return favoriteSlot + 2; - } - - public void setMode(int mode) { - this.favoriteSlot = mode - 2; - } - - public long getTime() { - return time; - } - - public void setTime(long time) { - this.time = time; - } -} +} \ No newline at end of file diff --git a/app/src/main/java/com/hippo/ehviewer/dao/LocalFavoriteInfo.kt b/app/src/main/java/com/hippo/ehviewer/dao/LocalFavoriteInfo.kt index 567909899..8f76077af 100644 --- a/app/src/main/java/com/hippo/ehviewer/dao/LocalFavoriteInfo.kt +++ b/app/src/main/java/com/hippo/ehviewer/dao/LocalFavoriteInfo.kt @@ -1,118 +1,30 @@ -package com.hippo.ehviewer.dao; +package com.hippo.ehviewer.dao -import androidx.room.ColumnInfo; -import androidx.room.Entity; - -import com.hippo.ehviewer.client.data.GalleryInfo; +import androidx.room.ColumnInfo +import androidx.room.Entity +import com.hippo.ehviewer.client.data.GalleryInfo @Entity(tableName = "LOCAL_FAVORITES") -public class LocalFavoriteInfo extends GalleryInfo { +class LocalFavoriteInfo() : GalleryInfo() { + @JvmField @ColumnInfo(name = "TIME") - public long time; + var time: Long = 0 - public LocalFavoriteInfo(GalleryInfo galleryInfo) { - this.gid = galleryInfo.gid; - this.token = galleryInfo.token; - this.title = galleryInfo.title; - this.titleJpn = galleryInfo.titleJpn; - this.thumb = galleryInfo.thumb; - this.category = galleryInfo.category; - this.posted = galleryInfo.posted; - this.uploader = galleryInfo.uploader; - this.rating = galleryInfo.rating; - this.simpleTags = galleryInfo.simpleTags; - this.simpleLanguage = galleryInfo.simpleLanguage; + constructor(galleryInfo: GalleryInfo) : this() { + gid = galleryInfo.gid + token = galleryInfo.token + title = galleryInfo.title + titleJpn = galleryInfo.titleJpn + thumb = galleryInfo.thumb + this.category = galleryInfo.category + posted = galleryInfo.posted + uploader = galleryInfo.uploader + rating = galleryInfo.rating + simpleTags = galleryInfo.simpleTags + simpleLanguage = galleryInfo.simpleLanguage } - public LocalFavoriteInfo() { - this.favoriteSlot = -1; + init { + favoriteSlot = -1 } - - public long getGid() { - return gid; - } - - public void setGid(long gid) { - this.gid = gid; - } - - public String getToken() { - return token; - } - - public void setToken(String token) { - this.token = token; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getTitleJpn() { - return titleJpn; - } - - public void setTitleJpn(String titleJpn) { - this.titleJpn = titleJpn; - } - - public String getThumb() { - return thumb; - } - - public void setThumb(String thumb) { - this.thumb = thumb; - } - - public int getCategory() { - return category; - } - - public void setCategory(int category) { - this.category = category; - } - - public String getPosted() { - return posted; - } - - public void setPosted(String posted) { - this.posted = posted; - } - - public String getUploader() { - return uploader; - } - - public void setUploader(String uploader) { - this.uploader = uploader; - } - - public float getRating() { - return rating; - } - - public void setRating(float rating) { - this.rating = rating; - } - - public String getSimpleLanguage() { - return simpleLanguage; - } - - public void setSimpleLanguage(String simpleLanguage) { - this.simpleLanguage = simpleLanguage; - } - - public long getTime() { - return time; - } - - public void setTime(long time) { - this.time = time; - } -} +} \ No newline at end of file diff --git a/app/src/main/java/com/hippo/ehviewer/dao/QuickSearch.kt b/app/src/main/java/com/hippo/ehviewer/dao/QuickSearch.kt index d2b42e848..655dc011a 100644 --- a/app/src/main/java/com/hippo/ehviewer/dao/QuickSearch.kt +++ b/app/src/main/java/com/hippo/ehviewer/dao/QuickSearch.kt @@ -1,117 +1,42 @@ -package com.hippo.ehviewer.dao; +package com.hippo.ehviewer.dao -import androidx.annotation.NonNull; -import androidx.room.ColumnInfo; -import androidx.room.Entity; -import androidx.room.PrimaryKey; +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.PrimaryKey @Entity(tableName = "QUICK_SEARCH") -public class QuickSearch { +class QuickSearch { @PrimaryKey @ColumnInfo(name = "_id") - public Long id; + var id: Long? = null + @ColumnInfo(name = "NAME") - public String name; + var name: String? = null + @ColumnInfo(name = "MODE") - public int mode; + var mode = 0 + @ColumnInfo(name = "CATEGORY") - public int category; + var category = 0 + @ColumnInfo(name = "KEYWORD") - public String keyword; + var keyword: String? = null + @ColumnInfo(name = "ADVANCE_SEARCH") - public int advanceSearch; + var advanceSearch = 0 + @ColumnInfo(name = "MIN_RATING") - public int minRating; + var minRating = 0 + @ColumnInfo(name = "PAGE_FROM") - public int pageFrom; + var pageFrom = 0 + @ColumnInfo(name = "PAGE_TO") - public int pageTo; + var pageTo = 0 + @ColumnInfo(name = "TIME") - public long time; - - public Long getId() { - return id; + var time: Long = 0 + override fun toString(): String { + return name!! } - - public void setId(Long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getMode() { - return mode; - } - - public void setMode(int mode) { - this.mode = mode; - } - - public int getCategory() { - return category; - } - - public void setCategory(int category) { - this.category = category; - } - - public String getKeyword() { - return keyword; - } - - public void setKeyword(String keyword) { - this.keyword = keyword; - } - - public int getAdvanceSearch() { - return advanceSearch; - } - - public void setAdvanceSearch(int advanceSearch) { - this.advanceSearch = advanceSearch; - } - - public int getMinRating() { - return minRating; - } - - public void setMinRating(int minRating) { - this.minRating = minRating; - } - - public int getPageFrom() { - return pageFrom; - } - - public void setPageFrom(int pageFrom) { - this.pageFrom = pageFrom; - } - - public int getPageTo() { - return pageTo; - } - - public void setPageTo(int pageTo) { - this.pageTo = pageTo; - } - - public long getTime() { - return time; - } - - public void setTime(long time) { - this.time = time; - } - - @NonNull - @Override - public String toString() { - return name; - } -} +} \ No newline at end of file diff --git a/app/src/main/java/com/hippo/ehviewer/ui/fragment/FilterFragment.kt b/app/src/main/java/com/hippo/ehviewer/ui/fragment/FilterFragment.kt index f80e9e540..c2bf2a0c9 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/fragment/FilterFragment.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/fragment/FilterFragment.kt @@ -233,7 +233,7 @@ class FilterFragment : BaseFragment() { holder.text?.text = filter.text } else { holder.checkbox?.text = filter.text - holder.checkbox?.isChecked = filter.enable + holder.checkbox?.isChecked = filter.enable!! holder.itemView.setOnClickListener { mFilterList.trigger(filter) @@ -252,7 +252,7 @@ class FilterFragment : BaseFragment() { return run { val filter = mFilterList[position] if (filter.id != null) { - (filter.text.hashCode() shr filter.mode) + filter.id + (filter.text.hashCode() shr filter.mode) + filter.id!! } else (filter.text.hashCode() shr filter.mode).toLong() } } diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/DownloadsScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/DownloadsScene.java index cfdca0512..e6d5fadb3 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/DownloadsScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/DownloadsScene.java @@ -184,7 +184,7 @@ public class DownloadsScene extends BaseToolbarScene if (null != mDownloadManager && -1L != (gid = args.getLong(KEY_GID, -1L))) { DownloadInfo info = mDownloadManager.getDownloadInfo(gid); if (null != info) { - mLabel = info.getLabel(); + mLabel = info.label; updateForLabel(); updateView(); diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java index 9aff19ab0..06561072d 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java @@ -676,9 +676,9 @@ public final class GalleryListScene extends SearchBarScene // Check duplicate for (QuickSearch q : mQuickSearchList) { if (urlBuilder.equalsQuickSearch(q)) { - var i = q.name.lastIndexOf("@"); - if (i != -1 && q.name.substring(i).equals(next)) { - showTip(getString(R.string.duplicate_quick_search, q.name), LENGTH_LONG); + var i = q.getName().lastIndexOf("@"); + if (i != -1 && q.getName().substring(i).equals(next)) { + showTip(getString(R.string.duplicate_quick_search, q.getName()), LENGTH_LONG); return; } } @@ -711,7 +711,7 @@ public final class GalleryListScene extends SearchBarScene // Check name duplicate for (QuickSearch q : mQuickSearchList) { - if (text.equals(q.name)) { + if (text.equals(q.getName())) { builder.setError(getString(R.string.duplicate_name)); return; } @@ -720,7 +720,7 @@ public final class GalleryListScene extends SearchBarScene builder.setError(null); dialog.dismiss(); QuickSearch quickSearch = urlBuilder.toQuickSearch(); - quickSearch.name = text; + quickSearch.setName(text); EhDB.insertQuickSearch(quickSearch); mQuickSearchList.add(quickSearch); adapter.notifyItemInserted(mQuickSearchList.size() - 1); @@ -1425,8 +1425,8 @@ public final class GalleryListScene extends SearchBarScene var q = mQuickSearchList.get(position); mUrlBuilder.set(q); onUpdateUrlBuilder(); - var i = q.name.lastIndexOf("@"); - mHelper.goTo(i != -1 ? q.name.substring(i + 1) : null, true); + var i = q.getName().lastIndexOf("@"); + mHelper.goTo(i != -1 ? q.getName().substring(i + 1) : null, true); setState(STATE_NORMAL); closeDrawer(GravityCompat.END); });