Fix deprecated funcs

Only fix kotlin code, because JAVA SUCKS
This commit is contained in:
tarsin committed 2023-02-01 15:17:35 +08:00
1 parent fafe25fee4
commit 0895af0ecc
5 files changed
+24 -14

No files matched your search

@@ -38,6 +38,7 @@ import com.hippo.ehviewer.dao.DownloadInfo
import com.hippo.ehviewer.ui.MainActivity
import com.hippo.ehviewer.ui.scene.DownloadsScene
import com.hippo.util.ReadableTime
import com.hippo.util.getParcelableExtraCompat
import com.hippo.yorozuya.FileUtils
import com.hippo.yorozuya.SimpleHandler
import com.hippo.yorozuya.collect.LongList
@@ -98,13 +99,13 @@ class DownloadService : Service(), DownloadManager.DownloadListener {
action = intent.action
}
if (ACTION_START == action) {
val gi = intent!!.getParcelableExtra<GalleryInfo>(KEY_GALLERY_INFO)
val gi = intent!!.getParcelableExtraCompat<GalleryInfo>(KEY_GALLERY_INFO)
val label = intent.getStringExtra(KEY_LABEL)
if (gi != null && mDownloadManager != null) {
mDownloadManager!!.startDownload(gi, label)
}
} else if (ACTION_START_RANGE == action) {
val gidList = intent!!.getParcelableExtra<LongList>(KEY_GID_LIST)
val gidList = intent!!.getParcelableExtraCompat<LongList>(KEY_GID_LIST)
if (gidList != null && mDownloadManager != null) {
mDownloadManager!!.startRangeDownload(gidList)
}
@@ -122,7 +123,7 @@ class DownloadService : Service(), DownloadManager.DownloadListener {
mDownloadManager!!.stopCurrentDownload()
}
} else if (ACTION_STOP_RANGE == action) {
val gidList = intent!!.getParcelableExtra<LongList>(KEY_GID_LIST)
val gidList = intent!!.getParcelableExtraCompat<LongList>(KEY_GID_LIST)
if (gidList != null && mDownloadManager != null) {
mDownloadManager!!.stopRangeDownload(gidList)
}
@@ -136,7 +137,7 @@ class DownloadService : Service(), DownloadManager.DownloadListener {
mDownloadManager!!.deleteDownload(gid)
}
} else if (ACTION_DELETE_RANGE == action) {
val gidList = intent!!.getParcelableExtra<LongList>(KEY_GID_LIST)
val gidList = intent!!.getParcelableExtraCompat<LongList>(KEY_GID_LIST)
if (gidList != null && mDownloadManager != null) {
mDownloadManager!!.deleteRangeDownload(gidList)
}
@@ -73,6 +73,7 @@ import com.hippo.ehviewer.ui.scene.ProgressScene
import com.hippo.image.Image
import com.hippo.util.addTextToClipboard
import com.hippo.util.getClipboardManager
import com.hippo.util.getParcelableExtraCompat
import com.hippo.util.getUrlFromClipboard
import com.hippo.yorozuya.IOUtils
import eu.kanade.tachiyomi.util.lang.launchUI
@@ -181,7 +182,7 @@ class MainActivity : EhActivity() {
)
return true
} else if (type != null && type.startsWith("image/")) {
val uri = intent.getParcelableExtra<Uri>(Intent.EXTRA_STREAM)
val uri = intent.getParcelableExtraCompat<Uri>(Intent.EXTRA_STREAM)
if (null != uri) {
val temp = saveImageToTempFile(uri)
if (null != temp) {
@@ -1,8 +0,0 @@
package com.hippo.util
import android.os.Bundle
import androidx.core.os.BundleCompat
inline fun <reified T> Bundle.getParcelableCompat(key: String?): T? {
return BundleCompat.getParcelable(this, key, T::class.java)
}
@@ -0,0 +1,15 @@
package com.hippo.util
import android.content.Intent
import android.os.Bundle
import android.os.Parcelable
import androidx.core.content.IntentCompat
import androidx.core.os.BundleCompat
inline fun <reified T : Parcelable> Bundle.getParcelableCompat(key: String?): T? {
return BundleCompat.getParcelable(this, key, T::class.java)
}
inline fun <reified T : Parcelable> Intent.getParcelableExtraCompat(key: String?): T? {
return IntentCompat.getParcelableExtra(this, key, T::class.java)
}
@@ -76,6 +76,7 @@ import com.hippo.image.Image
import com.hippo.unifile.UniFile
import com.hippo.util.ExceptionUtils
import com.hippo.util.getParcelableCompat
import com.hippo.util.getParcelableExtraCompat
import com.hippo.yorozuya.FileUtils
import com.hippo.yorozuya.IOUtils
import dev.chrisbanes.insetter.applyInsetter
@@ -223,7 +224,7 @@ class ReaderActivity : EhActivity() {
mAction = intent.action
mFilename = intent.getStringExtra(KEY_FILENAME)
mUri = intent.data
mGalleryInfo = intent.getParcelableExtra(KEY_GALLERY_INFO)
mGalleryInfo = intent.getParcelableExtraCompat(KEY_GALLERY_INFO)
mPage = intent.getIntExtra(KEY_PAGE, -1)
buildProvider()
}