修复bug
This commit is contained in:
parent
82f37cc4c8
commit
5bd33845e1
4
app/proguard-rules.pro
vendored
4
app/proguard-rules.pro
vendored
@ -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 *;
|
||||
}
|
||||
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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.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> {
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user