Cleanup
This commit is contained in:
parent
8f1f6d5a97
commit
7cbd7bd419
@ -7,7 +7,7 @@ import uy.kohesive.injekt.injectLazy
|
|||||||
|
|
||||||
class MigrationSourceAdapter(
|
class MigrationSourceAdapter(
|
||||||
var items: List<MigrationSourceItem>,
|
var items: List<MigrationSourceItem>,
|
||||||
val controllerPre: PreMigrationController
|
controllerPre: PreMigrationController
|
||||||
) : FlexibleAdapter<MigrationSourceItem>(
|
) : FlexibleAdapter<MigrationSourceItem>(
|
||||||
items,
|
items,
|
||||||
controllerPre,
|
controllerPre,
|
||||||
@ -30,8 +30,8 @@ class MigrationSourceAdapter(
|
|||||||
val sourceManager: SourceManager by injectLazy()
|
val sourceManager: SourceManager by injectLazy()
|
||||||
savedInstanceState.getParcelableArrayList<MigrationSourceItem.ParcelableSI>(
|
savedInstanceState.getParcelableArrayList<MigrationSourceItem.ParcelableSI>(
|
||||||
SELECTED_SOURCES_KEY
|
SELECTED_SOURCES_KEY
|
||||||
)?.let {
|
)?.let { selectedSources ->
|
||||||
updateDataSet(it.map { MigrationSourceItem.fromParcelable(sourceManager, it) })
|
updateDataSet(selectedSources.map { MigrationSourceItem.fromParcelable(sourceManager, it) })
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onRestoreInstanceState(savedInstanceState)
|
super.onRestoreInstanceState(savedInstanceState)
|
||||||
|
@ -12,7 +12,6 @@ import kotlinx.coroutines.Dispatchers
|
|||||||
import kotlinx.coroutines.cancel
|
import kotlinx.coroutines.cancel
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.util.Date
|
|
||||||
|
|
||||||
class MigrationProcessAdapter(
|
class MigrationProcessAdapter(
|
||||||
val controller: MigrationListController
|
val controller: MigrationListController
|
||||||
@ -142,7 +141,7 @@ class MigrationProcessAdapter(
|
|||||||
prevManga.date_added = 0
|
prevManga.date_added = 0
|
||||||
db.updateMangaFavorite(prevManga).executeAsBlocking()
|
db.updateMangaFavorite(prevManga).executeAsBlocking()
|
||||||
} else {
|
} else {
|
||||||
manga.date_added = Date().time
|
manga.date_added = System.currentTimeMillis()
|
||||||
}
|
}
|
||||||
manga.favorite = true
|
manga.favorite = true
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ import rx.android.schedulers.AndroidSchedulers
|
|||||||
import rx.schedulers.Schedulers
|
import rx.schedulers.Schedulers
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import java.util.Date
|
|
||||||
|
|
||||||
class MigrationMangaPresenter(
|
class MigrationMangaPresenter(
|
||||||
private val sourceId: Long,
|
private val sourceId: Long,
|
||||||
@ -113,7 +112,7 @@ class MigrationMangaPresenter(
|
|||||||
prevManga.date_added = 0
|
prevManga.date_added = 0
|
||||||
db.updateMangaFavorite(prevManga).executeAsBlocking()
|
db.updateMangaFavorite(prevManga).executeAsBlocking()
|
||||||
} else {
|
} else {
|
||||||
manga.date_added = Date().time
|
manga.date_added = System.currentTimeMillis()
|
||||||
}
|
}
|
||||||
// Set extra data
|
// Set extra data
|
||||||
|
|
||||||
|
@ -432,7 +432,7 @@ class MangaPresenter(
|
|||||||
viewer = originalManga.viewer
|
viewer = originalManga.viewer
|
||||||
chapter_flags = originalManga.chapter_flags
|
chapter_flags = originalManga.chapter_flags
|
||||||
sorting = Manga.SORTING_NUMBER
|
sorting = Manga.SORTING_NUMBER
|
||||||
date_added = Date().time
|
date_added = System.currentTimeMillis()
|
||||||
}
|
}
|
||||||
var existingManga = db.getManga(mergedManga.url, mergedManga.source).await()
|
var existingManga = db.getManga(mergedManga.url, mergedManga.source).await()
|
||||||
while (existingManga != null) {
|
while (existingManga != null) {
|
||||||
|
@ -50,7 +50,6 @@ import exh.util.floor
|
|||||||
import exh.util.nullIfBlank
|
import exh.util.nullIfBlank
|
||||||
import exh.util.trans
|
import exh.util.trans
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.GlobalScope
|
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import kotlinx.coroutines.flow.take
|
import kotlinx.coroutines.flow.take
|
||||||
@ -277,7 +276,7 @@ class SettingsEhController : SettingsController() {
|
|||||||
val binding = EhDialogLanguagesBinding.bind(customView)
|
val binding = EhDialogLanguagesBinding.bind(customView)
|
||||||
|
|
||||||
val languages = with(binding) {
|
val languages = with(binding) {
|
||||||
listOfNotNull(
|
listOf(
|
||||||
"${japaneseOriginal.isChecked}*${japaneseTranslated.isChecked}*${japaneseRewrite.isChecked}",
|
"${japaneseOriginal.isChecked}*${japaneseTranslated.isChecked}*${japaneseRewrite.isChecked}",
|
||||||
"${englishOriginal.isChecked}*${englishTranslated.isChecked}*${englishRewrite.isChecked}",
|
"${englishOriginal.isChecked}*${englishTranslated.isChecked}*${englishRewrite.isChecked}",
|
||||||
"${chineseOriginal.isChecked}*${chineseTranslated.isChecked}*${chineseRewrite.isChecked}",
|
"${chineseOriginal.isChecked}*${chineseTranslated.isChecked}*${chineseRewrite.isChecked}",
|
||||||
@ -416,8 +415,8 @@ class SettingsEhController : SettingsController() {
|
|||||||
.title(R.string.frong_page_categories)
|
.title(R.string.frong_page_categories)
|
||||||
.message(R.string.fromt_page_categories_summary)
|
.message(R.string.fromt_page_categories_summary)
|
||||||
.customView(R.layout.eh_dialog_categories, scrollable = true)
|
.customView(R.layout.eh_dialog_categories, scrollable = true)
|
||||||
.positiveButton {
|
.positiveButton { dialog ->
|
||||||
val customView = it.view.contentLayout.customView!!
|
val customView = dialog.view.contentLayout.customView!!
|
||||||
val binding = EhDialogCategoriesBinding.bind(customView)
|
val binding = EhDialogCategoriesBinding.bind(customView)
|
||||||
|
|
||||||
with(binding) {
|
with(binding) {
|
||||||
@ -631,7 +630,7 @@ class SettingsEhController : SettingsController() {
|
|||||||
progress.show()
|
progress.show()
|
||||||
|
|
||||||
@OptIn(ExperimentalTime::class)
|
@OptIn(ExperimentalTime::class)
|
||||||
GlobalScope.launch(Dispatchers.IO) {
|
scope.launch(Dispatchers.IO) {
|
||||||
val updateInfo = try {
|
val updateInfo = try {
|
||||||
val stats =
|
val stats =
|
||||||
preferences.eh_autoUpdateStats().get().nullIfBlank()?.let {
|
preferences.eh_autoUpdateStats().get().nullIfBlank()?.let {
|
||||||
|
@ -14,7 +14,6 @@ import exh.source.getMainSource
|
|||||||
import exh.util.await
|
import exh.util.await
|
||||||
import exh.util.awaitSingle
|
import exh.util.awaitSingle
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.util.Date
|
|
||||||
|
|
||||||
class GalleryAdder {
|
class GalleryAdder {
|
||||||
|
|
||||||
@ -107,7 +106,7 @@ class GalleryAdder {
|
|||||||
|
|
||||||
if (fav) {
|
if (fav) {
|
||||||
manga.favorite = true
|
manga.favorite = true
|
||||||
manga.date_added = Date().time
|
manga.date_added = System.currentTimeMillis()
|
||||||
}
|
}
|
||||||
|
|
||||||
db.insertManga(manga).await()
|
db.insertManga(manga).await()
|
||||||
|
@ -12,7 +12,6 @@ import kotlinx.coroutines.flow.flowOf
|
|||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.Date
|
|
||||||
|
|
||||||
data class ChapterChain(val manga: Manga, val chapters: List<Chapter>)
|
data class ChapterChain(val manga: Manga, val chapters: List<Chapter>)
|
||||||
|
|
||||||
@ -69,7 +68,7 @@ class EHentaiUpdateHelper(context: Context) {
|
|||||||
it.manga.date_added = 0
|
it.manga.date_added = 0
|
||||||
}
|
}
|
||||||
accepted.manga.favorite = true
|
accepted.manga.favorite = true
|
||||||
accepted.manga.date_added = Date().time
|
accepted.manga.date_added = System.currentTimeMillis()
|
||||||
|
|
||||||
val newAccepted = ChapterChain(accepted.manga, newChapters)
|
val newAccepted = ChapterChain(accepted.manga, newChapters)
|
||||||
val rootsToMutate = toDiscard + newAccepted
|
val rootsToMutate = toDiscard + newAccepted
|
||||||
|
@ -9,7 +9,6 @@ import exh.metadata.metadata.EHentaiSearchMetadata
|
|||||||
import io.realm.Realm
|
import io.realm.Realm
|
||||||
import io.realm.RealmConfiguration
|
import io.realm.RealmConfiguration
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.util.Date
|
|
||||||
|
|
||||||
class LocalFavoritesStorage {
|
class LocalFavoritesStorage {
|
||||||
private val db: DatabaseHelper by injectLazy()
|
private val db: DatabaseHelper by injectLazy()
|
||||||
@ -42,7 +41,7 @@ class LocalFavoritesStorage {
|
|||||||
it.fav,
|
it.fav,
|
||||||
it.manga.apply {
|
it.manga.apply {
|
||||||
favorite = true
|
favorite = true
|
||||||
date_added = Date().time
|
date_added = System.currentTimeMillis()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import kotlinx.serialization.json.JsonObject
|
|||||||
import kotlinx.serialization.json.jsonArray
|
import kotlinx.serialization.json.jsonArray
|
||||||
import kotlinx.serialization.json.jsonPrimitive
|
import kotlinx.serialization.json.jsonPrimitive
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import java.util.Date
|
|
||||||
|
|
||||||
class ApiChapterParser {
|
class ApiChapterParser {
|
||||||
fun pageListParse(response: Response): List<Page> {
|
fun pageListParse(response: Response): List<Page> {
|
||||||
@ -22,7 +21,7 @@ class ApiChapterParser {
|
|||||||
|
|
||||||
pageArray.forEach {
|
pageArray.forEach {
|
||||||
val url = "$hash/${it.jsonPrimitive.content}"
|
val url = "$hash/${it.jsonPrimitive.content}"
|
||||||
pages.add(Page(pages.size, "$server,${response.request.url},${Date().time}", url))
|
pages.add(Page(pages.size, "$server,${response.request.url},${System.currentTimeMillis()}", url))
|
||||||
}
|
}
|
||||||
|
|
||||||
return pages
|
return pages
|
||||||
|
@ -26,7 +26,6 @@ import rx.Completable
|
|||||||
import rx.Single
|
import rx.Single
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import java.util.Date
|
|
||||||
|
|
||||||
class ApiMangaParser(private val langs: List<String>) {
|
class ApiMangaParser(private val langs: List<String>) {
|
||||||
val db: DatabaseHelper get() = Injekt.get()
|
val db: DatabaseHelper get() = Injekt.get()
|
||||||
@ -207,9 +206,8 @@ class ApiMangaParser(private val langs: List<String>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun chapterListParse(jsonData: String): List<SChapter> {
|
fun chapterListParse(jsonData: String): List<SChapter> {
|
||||||
val now = Date().time
|
val now = System.currentTimeMillis()
|
||||||
val networkApiManga =
|
val networkApiManga = MdUtil.jsonParser.decodeFromString(ApiMangaSerializer.serializer(), jsonData)
|
||||||
MdUtil.jsonParser.decodeFromString(ApiMangaSerializer.serializer(), jsonData)
|
|
||||||
val networkManga = networkApiManga.manga
|
val networkManga = networkApiManga.manga
|
||||||
val networkChapters = networkApiManga.chapter
|
val networkChapters = networkApiManga.chapter
|
||||||
if (networkChapters.isNullOrEmpty()) {
|
if (networkChapters.isNullOrEmpty()) {
|
||||||
|
@ -45,25 +45,22 @@ class FollowsHandler(val client: OkHttpClient, val headers: Headers, val prefere
|
|||||||
* used when multiple follows
|
* used when multiple follows
|
||||||
*/
|
*/
|
||||||
private fun followsParseMangaPage(response: Response, forceHd: Boolean = false): MetadataMangasPage {
|
private fun followsParseMangaPage(response: Response, forceHd: Boolean = false): MetadataMangasPage {
|
||||||
var followsPageResult: FollowsPageResult? = null
|
val followsPageResult = try {
|
||||||
|
MdUtil.jsonParser.decodeFromString(
|
||||||
try {
|
FollowsPageResult.serializer(),
|
||||||
followsPageResult =
|
response.body?.string() ?: ""
|
||||||
MdUtil.jsonParser.decodeFromString(
|
)
|
||||||
FollowsPageResult.serializer(),
|
|
||||||
response.body!!.string()
|
|
||||||
)
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
XLog.e("error parsing follows", e)
|
XLog.e("error parsing follows", e)
|
||||||
|
FollowsPageResult(emptyList())
|
||||||
}
|
}
|
||||||
val empty = followsPageResult?.result?.isEmpty()
|
|
||||||
|
|
||||||
if (empty == null || empty) {
|
if (followsPageResult.result.isEmpty()) {
|
||||||
return MetadataMangasPage(mutableListOf(), false, mutableListOf())
|
return MetadataMangasPage(emptyList(), false, emptyList())
|
||||||
}
|
}
|
||||||
val lowQualityCovers = if (forceHd) false else useLowQualityCovers
|
val lowQualityCovers = if (forceHd) false else useLowQualityCovers
|
||||||
|
|
||||||
val follows = followsPageResult!!.result.map {
|
val follows = followsPageResult.result.map {
|
||||||
followFromElement(it, lowQualityCovers)
|
followFromElement(it, lowQualityCovers)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,25 +76,22 @@ class FollowsHandler(val client: OkHttpClient, val headers: Headers, val prefere
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
private fun followStatusParse(response: Response): Track {
|
private fun followStatusParse(response: Response): Track {
|
||||||
var followsPageResult: FollowsPageResult? = null
|
val followsPageResult = try {
|
||||||
|
MdUtil.jsonParser.decodeFromString(
|
||||||
try {
|
FollowsPageResult.serializer(),
|
||||||
followsPageResult =
|
response.body?.string() ?: ""
|
||||||
MdUtil.jsonParser.decodeFromString(
|
)
|
||||||
FollowsPageResult.serializer(),
|
|
||||||
response.body!!.string()
|
|
||||||
)
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
XLog.e("error parsing follows", e)
|
XLog.e("error parsing follows", e)
|
||||||
|
FollowsPageResult(emptyList())
|
||||||
}
|
}
|
||||||
val track = Track.create(TrackManager.MDLIST)
|
val track = Track.create(TrackManager.MDLIST)
|
||||||
val result = followsPageResult?.result
|
if (followsPageResult.result.isEmpty()) {
|
||||||
if (result.isNullOrEmpty()) {
|
|
||||||
track.status = FollowStatus.UNFOLLOWED.int
|
track.status = FollowStatus.UNFOLLOWED.int
|
||||||
} else {
|
} else {
|
||||||
val follow = result.first()
|
val follow = followsPageResult.result.first()
|
||||||
track.status = follow.follow_type
|
track.status = follow.follow_type
|
||||||
if (result[0].chapter.isNotBlank()) {
|
if (followsPageResult.result[0].chapter.isNotBlank()) {
|
||||||
track.last_chapter_read = follow.chapter.toFloat().floor()
|
track.last_chapter_read = follow.chapter.toFloat().floor()
|
||||||
}
|
}
|
||||||
track.tracking_url = MdUtil.baseUrl + follow.manga_id.toString()
|
track.tracking_url = MdUtil.baseUrl + follow.manga_id.toString()
|
||||||
@ -122,9 +116,9 @@ class FollowsHandler(val client: OkHttpClient, val headers: Headers, val prefere
|
|||||||
manga.url = "/manga/${result.manga_id}/"
|
manga.url = "/manga/${result.manga_id}/"
|
||||||
manga.thumbnail_url = MdUtil.formThumbUrl(manga.url, lowQualityCovers)
|
manga.thumbnail_url = MdUtil.formThumbUrl(manga.url, lowQualityCovers)
|
||||||
return manga to MangaDexSearchMetadata().apply {
|
return manga to MangaDexSearchMetadata().apply {
|
||||||
title = MdUtil.cleanString(result.title)
|
title = manga.title
|
||||||
mdUrl = "/manga/${result.manga_id}/"
|
mdUrl = manga.url
|
||||||
thumbnail_url = MdUtil.formThumbUrl(manga.url, lowQualityCovers)
|
thumbnail_url = manga.thumbnail_url
|
||||||
follow_status = FollowStatus.fromInt(result.follow_type)?.int
|
follow_status = FollowStatus.fromInt(result.follow_type)?.int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,7 +150,7 @@ class FollowsHandler(val client: OkHttpClient, val headers: Headers, val prefere
|
|||||||
.await()
|
.await()
|
||||||
}
|
}
|
||||||
|
|
||||||
withContext(Dispatchers.IO) { response.body!!.string().isEmpty() }
|
withContext(Dispatchers.IO) { response.body?.string().isNullOrEmpty() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +176,7 @@ class FollowsHandler(val client: OkHttpClient, val headers: Headers, val prefere
|
|||||||
)
|
)
|
||||||
.await()
|
.await()
|
||||||
|
|
||||||
withContext(Dispatchers.IO) { response.body!!.string().isEmpty() }
|
withContext(Dispatchers.IO) { response.body?.string().isNullOrEmpty() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,7 +191,7 @@ class FollowsHandler(val client: OkHttpClient, val headers: Headers, val prefere
|
|||||||
)
|
)
|
||||||
.await()
|
.await()
|
||||||
|
|
||||||
withContext(Dispatchers.IO) { response.body!!.string().isEmpty() }
|
withContext(Dispatchers.IO) { response.body?.string().isNullOrEmpty() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,6 @@ fun Manga.mangaType(): MangaType {
|
|||||||
* read types
|
* read types
|
||||||
*/
|
*/
|
||||||
fun Manga.defaultReaderType(): Int? {
|
fun Manga.defaultReaderType(): Int? {
|
||||||
// val sourceName = Injekt.get<SourceManager>().getOrStub(source).name
|
|
||||||
val type = mangaType()
|
val type = mangaType()
|
||||||
return if (type == MangaType.TYPE_MANHWA || type == MangaType.TYPE_WEBTOON) {
|
return if (type == MangaType.TYPE_MANHWA || type == MangaType.TYPE_WEBTOON) {
|
||||||
ReaderActivity.WEBTOON
|
ReaderActivity.WEBTOON
|
||||||
|
Loading…
x
Reference in New Issue
Block a user