修复bug

This commit is contained in:
ocean 2025-12-15 10:11:43 +08:00
parent 82f37cc4c8
commit 5bd33845e1
5 changed files with 18 additions and 9 deletions

View File

@ -42,8 +42,8 @@
# 保留所有 Parcelable
-keep class * implements android.os.Parcelable { *; }
# 保留所有 Parcelable CREATOR 字段
-keep @kotlinx.parcelize.Parcelize class *
-keepclassmembers class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}

View File

@ -39,6 +39,7 @@ class MergePdfActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
intent.extras?.classLoader = PdfDocumentEntity::class.java.classLoader
binding = ActivityPdfMergeBinding.inflate(layoutInflater)
setContentView(binding.root)
AnalyticsUtils.logEvent(AnalyticsUtils.Event.MERGE_SHOW)
@ -210,6 +211,7 @@ class MergePdfActivity : BaseActivity() {
*/
@Suppress("DEPRECATION")
private inline fun <reified T : Parcelable> requireParcelableArrayList(key: String): ArrayList<T> {
intent.extras?.classLoader = T::class.java.classLoader
val result: ArrayList<T>? = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
intent.getParcelableArrayListExtra(key, T::class.java)
} else {

View File

@ -42,6 +42,7 @@ class PdfPickerActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
intent.extras?.classLoader = PdfDocumentEntity::class.java.classLoader
binding = ActivityPdfPickerBinding.inflate(layoutInflater)
setContentView(binding.root)
source = getSerializableOrDefault(EXTRA_SOURCE, PdfPickerSource.NONE)
@ -334,6 +335,7 @@ class PdfPickerActivity : BaseActivity() {
@Suppress("DEPRECATION")
private inline fun <reified T : Parcelable> requireParcelableArrayList(key: String): ArrayList<T> {
intent.extras?.classLoader = T::class.java.classLoader
val result: ArrayList<T>? = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
intent.getParcelableArrayListExtra(key, T::class.java)
} else {

View File

@ -557,12 +557,16 @@ class PdfResultActivity : BaseActivity() {
@Suppress("DEPRECATION")
private inline fun <reified T : Parcelable> requireParcelableArrayList(key: String): ArrayList<T> {
val result: ArrayList<T>? = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
intent.getParcelableArrayListExtra(key, T::class.java)
} else {
intent.getParcelableArrayListExtra(key)
intent.extras?.classLoader = T::class.java.classLoader
return try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
intent.getParcelableArrayListExtra(key, T::class.java)
} else {
intent.getParcelableArrayListExtra(key)
} ?: arrayListOf()
} catch (e: Throwable) {
arrayListOf()
}
return result ?: arrayListOf()
}
private fun requireStringArrayList(key: String): ArrayList<String> {

View File

@ -2,6 +2,7 @@ package com.all.pdfreader.pdf.reader.util
import android.util.Log
import com.github.barteksc.pdfviewer.PDFView
import com.tom_roush.pdfbox.io.MemoryUsageSetting
import com.tom_roush.pdfbox.pdmodel.PDDocument
import com.tom_roush.pdfbox.pdmodel.PDPage
import com.tom_roush.pdfbox.text.PDFTextStripper
@ -76,9 +77,9 @@ class PDFSearchManager(private val pdfView: PDFView) {
// 如果是新的文件,则关闭旧文档
cachedDoc?.close()
cachedDoc = if (!password.isNullOrEmpty()) {
PDDocument.load(file, password)
PDDocument.load(file, password, MemoryUsageSetting.setupTempFileOnly())
} else {
PDDocument.load(file)
PDDocument.load(file, MemoryUsageSetting.setupTempFileOnly())
}
cachedPath = file.absolutePath