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