Cleanup code
This commit is contained in:
1 parent
e0797cd519
commit
78d8ed922c
2 files changed
+14
-25
No files matched your search
@@ -50,7 +50,6 @@ import com.hippo.ehviewer.EhDB
|
||||
import com.hippo.ehviewer.R
|
||||
import com.hippo.ehviewer.Settings
|
||||
import com.hippo.ehviewer.WindowInsetsAnimationHelper
|
||||
import com.hippo.ehviewer.client.EhClient
|
||||
import com.hippo.ehviewer.client.EhEngine
|
||||
import com.hippo.ehviewer.client.EhUrl
|
||||
import com.hippo.ehviewer.client.data.FavListUrlBuilder
|
||||
@@ -101,8 +100,6 @@ class FavoritesScene :
|
||||
|
||||
private var mDrawerAdapter: FavDrawerAdapter? = null
|
||||
|
||||
private var mClient: EhClient? = null
|
||||
|
||||
private var mFavCatArray: Array<String>? = Settings.favCat
|
||||
|
||||
private var mFavCountArray: IntArray? = Settings.favCount
|
||||
@@ -138,7 +135,6 @@ class FavoritesScene :
|
||||
private var mModifyAdd = false
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
mClient = EhClient
|
||||
mFavLocalCount = Settings.favLocalCount
|
||||
mFavCountSum = Settings.favCloudCount
|
||||
if (savedInstanceState == null) {
|
||||
@@ -181,7 +177,6 @@ class FavoritesScene :
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mClient = null
|
||||
mFavCatArray = null
|
||||
mFavCountArray = null
|
||||
mFavCountSum = 0
|
||||
@@ -860,7 +855,7 @@ class FavoritesScene :
|
||||
isNext: Boolean,
|
||||
) {
|
||||
val activity = mainActivity
|
||||
if (null == activity || null == mUrlBuilder || null == mClient) {
|
||||
if (null == activity || null == mUrlBuilder) {
|
||||
return
|
||||
}
|
||||
if (mEnableModify) {
|
||||
|
||||
@@ -126,7 +126,6 @@ import com.hippo.ehviewer.UrlOpener
|
||||
import com.hippo.ehviewer.client.EhCookieStore
|
||||
import com.hippo.ehviewer.client.EhEngine
|
||||
import com.hippo.ehviewer.client.EhFilter
|
||||
import com.hippo.ehviewer.client.EhRequest
|
||||
import com.hippo.ehviewer.client.EhTagDatabase
|
||||
import com.hippo.ehviewer.client.EhTagDatabase.isTranslatable
|
||||
import com.hippo.ehviewer.client.EhTagDatabase.namespaceToPrefix
|
||||
@@ -178,6 +177,7 @@ import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.lang.withUIContext
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.Job
|
||||
import moe.tarsin.coroutines.runSuspendCatching
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import kotlin.math.roundToInt
|
||||
@@ -1562,13 +1562,11 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener {
|
||||
}
|
||||
}
|
||||
|
||||
private inner class ArchiveListDialogHelper :
|
||||
AdapterView.OnItemClickListener,
|
||||
DialogInterface.OnDismissListener {
|
||||
private inner class ArchiveListDialogHelper : AdapterView.OnItemClickListener, DialogInterface.OnDismissListener {
|
||||
private var mProgressView: CircularProgressIndicator? = null
|
||||
private var mJob: Job? = null
|
||||
private var mErrorText: TextView? = null
|
||||
private var mListView: ListView? = null
|
||||
private var mRequest: EhRequest? = null
|
||||
private var mDialog: Dialog? = null
|
||||
fun setDialog(dialog: Dialog?, url: String?) {
|
||||
mDialog = dialog
|
||||
@@ -1667,7 +1665,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener {
|
||||
val res = mArchiveList!![position].res
|
||||
val isHAtH = mArchiveList!![position].isHAtH
|
||||
composeBindingGD?.run {
|
||||
lifecycleScope.launchIO {
|
||||
mJob = lifecycleScope.launchIO {
|
||||
runSuspendCatching {
|
||||
EhEngine.downloadArchive(gid, token, mArchiveFormParamOr, res, isHAtH)
|
||||
}.onSuccess { result ->
|
||||
@@ -1688,6 +1686,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener {
|
||||
showTip(R.string.download_archive_failure, LENGTH_LONG)
|
||||
}
|
||||
}
|
||||
mJob = null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1698,10 +1697,8 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener {
|
||||
}
|
||||
|
||||
override fun onDismiss(dialog: DialogInterface) {
|
||||
if (mRequest != null) {
|
||||
mRequest!!.cancel()
|
||||
mRequest = null
|
||||
}
|
||||
mJob?.cancel()
|
||||
mJob = null
|
||||
mDialog = null
|
||||
mProgressView = null
|
||||
mErrorText = null
|
||||
@@ -1709,13 +1706,11 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener {
|
||||
}
|
||||
}
|
||||
|
||||
private inner class TorrentListDialogHelper :
|
||||
AdapterView.OnItemClickListener,
|
||||
DialogInterface.OnDismissListener {
|
||||
private inner class TorrentListDialogHelper : AdapterView.OnItemClickListener, DialogInterface.OnDismissListener {
|
||||
private var mProgressView: CircularProgressIndicator? = null
|
||||
private var mErrorText: TextView? = null
|
||||
private var mListView: ListView? = null
|
||||
private var mRequest: EhRequest? = null
|
||||
private var mJob: Job? = null
|
||||
private var mDialog: Dialog? = null
|
||||
fun setDialog(dialog: Dialog?, url: String?) {
|
||||
mDialog = dialog
|
||||
@@ -1728,7 +1723,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener {
|
||||
if (mTorrentList == null) {
|
||||
mErrorText!!.visibility = View.GONE
|
||||
mListView!!.visibility = View.GONE
|
||||
lifecycleScope.launchIO {
|
||||
mJob = lifecycleScope.launchIO {
|
||||
runSuspendCatching {
|
||||
EhEngine.getTorrentList(url!!, mGid, mToken)
|
||||
}.onSuccess {
|
||||
@@ -1744,6 +1739,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener {
|
||||
mErrorText?.text = ExceptionUtils.getReadableString(it)
|
||||
}
|
||||
}
|
||||
mJob = null
|
||||
}
|
||||
} else {
|
||||
bind(mTorrentList)
|
||||
@@ -1801,10 +1797,8 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener {
|
||||
}
|
||||
|
||||
override fun onDismiss(dialog: DialogInterface) {
|
||||
if (mRequest != null) {
|
||||
mRequest!!.cancel()
|
||||
mRequest = null
|
||||
}
|
||||
mJob?.cancel()
|
||||
mJob = null
|
||||
mDialog = null
|
||||
mProgressView = null
|
||||
mErrorText = null
|
||||
|
||||
Reference in new issue
Block a user