This commit is contained in:
Jobobby04 2020-10-31 22:06:32 -04:00
parent 8f1f6d5a97
commit 7cbd7bd419
12 changed files with 40 additions and 56 deletions

View File

@ -7,7 +7,7 @@ import uy.kohesive.injekt.injectLazy
class MigrationSourceAdapter(
var items: List<MigrationSourceItem>,
val controllerPre: PreMigrationController
controllerPre: PreMigrationController
) : FlexibleAdapter<MigrationSourceItem>(
items,
controllerPre,
@ -30,8 +30,8 @@ class MigrationSourceAdapter(
val sourceManager: SourceManager by injectLazy()
savedInstanceState.getParcelableArrayList<MigrationSourceItem.ParcelableSI>(
SELECTED_SOURCES_KEY
)?.let {
updateDataSet(it.map { MigrationSourceItem.fromParcelable(sourceManager, it) })
)?.let { selectedSources ->
updateDataSet(selectedSources.map { MigrationSourceItem.fromParcelable(sourceManager, it) })
}
super.onRestoreInstanceState(savedInstanceState)

View File

@ -12,7 +12,6 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.cancel
import kotlinx.coroutines.withContext
import uy.kohesive.injekt.injectLazy
import java.util.Date
class MigrationProcessAdapter(
val controller: MigrationListController
@ -142,7 +141,7 @@ class MigrationProcessAdapter(
prevManga.date_added = 0
db.updateMangaFavorite(prevManga).executeAsBlocking()
} else {
manga.date_added = Date().time
manga.date_added = System.currentTimeMillis()
}
manga.favorite = true

View File

@ -16,7 +16,6 @@ import rx.android.schedulers.AndroidSchedulers
import rx.schedulers.Schedulers
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import java.util.Date
class MigrationMangaPresenter(
private val sourceId: Long,
@ -113,7 +112,7 @@ class MigrationMangaPresenter(
prevManga.date_added = 0
db.updateMangaFavorite(prevManga).executeAsBlocking()
} else {
manga.date_added = Date().time
manga.date_added = System.currentTimeMillis()
}
// Set extra data

View File

@ -432,7 +432,7 @@ class MangaPresenter(
viewer = originalManga.viewer
chapter_flags = originalManga.chapter_flags
sorting = Manga.SORTING_NUMBER
date_added = Date().time
date_added = System.currentTimeMillis()
}
var existingManga = db.getManga(mergedManga.url, mergedManga.source).await()
while (existingManga != null) {

View File

@ -50,7 +50,6 @@ import exh.util.floor
import exh.util.nullIfBlank
import exh.util.trans
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.take
@ -277,7 +276,7 @@ class SettingsEhController : SettingsController() {
val binding = EhDialogLanguagesBinding.bind(customView)
val languages = with(binding) {
listOfNotNull(
listOf(
"${japaneseOriginal.isChecked}*${japaneseTranslated.isChecked}*${japaneseRewrite.isChecked}",
"${englishOriginal.isChecked}*${englishTranslated.isChecked}*${englishRewrite.isChecked}",
"${chineseOriginal.isChecked}*${chineseTranslated.isChecked}*${chineseRewrite.isChecked}",
@ -416,8 +415,8 @@ class SettingsEhController : SettingsController() {
.title(R.string.frong_page_categories)
.message(R.string.fromt_page_categories_summary)
.customView(R.layout.eh_dialog_categories, scrollable = true)
.positiveButton {
val customView = it.view.contentLayout.customView!!
.positiveButton { dialog ->
val customView = dialog.view.contentLayout.customView!!
val binding = EhDialogCategoriesBinding.bind(customView)
with(binding) {
@ -631,7 +630,7 @@ class SettingsEhController : SettingsController() {
progress.show()
@OptIn(ExperimentalTime::class)
GlobalScope.launch(Dispatchers.IO) {
scope.launch(Dispatchers.IO) {
val updateInfo = try {
val stats =
preferences.eh_autoUpdateStats().get().nullIfBlank()?.let {

View File

@ -14,7 +14,6 @@ import exh.source.getMainSource
import exh.util.await
import exh.util.awaitSingle
import uy.kohesive.injekt.injectLazy
import java.util.Date
class GalleryAdder {
@ -107,7 +106,7 @@ class GalleryAdder {
if (fav) {
manga.favorite = true
manga.date_added = Date().time
manga.date_added = System.currentTimeMillis()
}
db.insertManga(manga).await()

View File

@ -12,7 +12,6 @@ import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
import uy.kohesive.injekt.injectLazy
import java.io.File
import java.util.Date
data class ChapterChain(val manga: Manga, val chapters: List<Chapter>)
@ -69,7 +68,7 @@ class EHentaiUpdateHelper(context: Context) {
it.manga.date_added = 0
}
accepted.manga.favorite = true
accepted.manga.date_added = Date().time
accepted.manga.date_added = System.currentTimeMillis()
val newAccepted = ChapterChain(accepted.manga, newChapters)
val rootsToMutate = toDiscard + newAccepted

View File

@ -9,7 +9,6 @@ import exh.metadata.metadata.EHentaiSearchMetadata
import io.realm.Realm
import io.realm.RealmConfiguration
import uy.kohesive.injekt.injectLazy
import java.util.Date
class LocalFavoritesStorage {
private val db: DatabaseHelper by injectLazy()
@ -42,7 +41,7 @@ class LocalFavoritesStorage {
it.fav,
it.manga.apply {
favorite = true
date_added = Date().time
date_added = System.currentTimeMillis()
}
)
}

View File

@ -7,7 +7,6 @@ import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonPrimitive
import okhttp3.Response
import java.util.Date
class ApiChapterParser {
fun pageListParse(response: Response): List<Page> {
@ -22,7 +21,7 @@ class ApiChapterParser {
pageArray.forEach {
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

View File

@ -26,7 +26,6 @@ import rx.Completable
import rx.Single
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import java.util.Date
class ApiMangaParser(private val langs: List<String>) {
val db: DatabaseHelper get() = Injekt.get()
@ -207,9 +206,8 @@ class ApiMangaParser(private val langs: List<String>) {
}
fun chapterListParse(jsonData: String): List<SChapter> {
val now = Date().time
val networkApiManga =
MdUtil.jsonParser.decodeFromString(ApiMangaSerializer.serializer(), jsonData)
val now = System.currentTimeMillis()
val networkApiManga = MdUtil.jsonParser.decodeFromString(ApiMangaSerializer.serializer(), jsonData)
val networkManga = networkApiManga.manga
val networkChapters = networkApiManga.chapter
if (networkChapters.isNullOrEmpty()) {

View File

@ -45,25 +45,22 @@ class FollowsHandler(val client: OkHttpClient, val headers: Headers, val prefere
* used when multiple follows
*/
private fun followsParseMangaPage(response: Response, forceHd: Boolean = false): MetadataMangasPage {
var followsPageResult: FollowsPageResult? = null
try {
followsPageResult =
val followsPageResult = try {
MdUtil.jsonParser.decodeFromString(
FollowsPageResult.serializer(),
response.body!!.string()
response.body?.string() ?: ""
)
} catch (e: Exception) {
XLog.e("error parsing follows", e)
FollowsPageResult(emptyList())
}
val empty = followsPageResult?.result?.isEmpty()
if (empty == null || empty) {
return MetadataMangasPage(mutableListOf(), false, mutableListOf())
if (followsPageResult.result.isEmpty()) {
return MetadataMangasPage(emptyList(), false, emptyList())
}
val lowQualityCovers = if (forceHd) false else useLowQualityCovers
val follows = followsPageResult!!.result.map {
val follows = followsPageResult.result.map {
followFromElement(it, lowQualityCovers)
}
@ -79,25 +76,22 @@ class FollowsHandler(val client: OkHttpClient, val headers: Headers, val prefere
*/
private fun followStatusParse(response: Response): Track {
var followsPageResult: FollowsPageResult? = null
try {
followsPageResult =
val followsPageResult = try {
MdUtil.jsonParser.decodeFromString(
FollowsPageResult.serializer(),
response.body!!.string()
response.body?.string() ?: ""
)
} catch (e: Exception) {
XLog.e("error parsing follows", e)
FollowsPageResult(emptyList())
}
val track = Track.create(TrackManager.MDLIST)
val result = followsPageResult?.result
if (result.isNullOrEmpty()) {
if (followsPageResult.result.isEmpty()) {
track.status = FollowStatus.UNFOLLOWED.int
} else {
val follow = result.first()
val follow = followsPageResult.result.first()
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.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.thumbnail_url = MdUtil.formThumbUrl(manga.url, lowQualityCovers)
return manga to MangaDexSearchMetadata().apply {
title = MdUtil.cleanString(result.title)
mdUrl = "/manga/${result.manga_id}/"
thumbnail_url = MdUtil.formThumbUrl(manga.url, lowQualityCovers)
title = manga.title
mdUrl = manga.url
thumbnail_url = manga.thumbnail_url
follow_status = FollowStatus.fromInt(result.follow_type)?.int
}
}
@ -156,7 +150,7 @@ class FollowsHandler(val client: OkHttpClient, val headers: Headers, val prefere
.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()
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()
withContext(Dispatchers.IO) { response.body!!.string().isEmpty() }
withContext(Dispatchers.IO) { response.body?.string().isNullOrEmpty() }
}
}

View File

@ -47,7 +47,6 @@ fun Manga.mangaType(): MangaType {
* read types
*/
fun Manga.defaultReaderType(): Int? {
// val sourceName = Injekt.get<SourceManager>().getOrStub(source).name
val type = mangaType()
return if (type == MangaType.TYPE_MANHWA || type == MangaType.TYPE_WEBTOON) {
ReaderActivity.WEBTOON