Commit 6698b57f authored by 周文华's avatar 周文华

【修复】修复pdf加锁问题

parent 0005e831
......@@ -121,11 +121,11 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
SearchTaskResult.set(null)
if (muPDFCore?.needsPassword() == true) {
val pwd = intent.extras?.getString("pwd") ?: ""
//val pwd = intent.extras?.getString("pwd") ?: ""
val flag = muPDFCore?.authenticatePassword(pwd) ?: false
if (flag) {
pdfPresenter.password = pwd
pdfPageAdapter.setPassword(pwd)
// pdfPageAdapter.setPassword(pwd)
createPdfUI()
muPDFCore?.countPages()?.let {
//pdfPresenter.iniPdfPage(it)
......@@ -351,7 +351,7 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
}
private fun initAdapter() {
pdfPageAdapter = PdfPagerAdapter(path, uri){
pdfPageAdapter = PdfPagerAdapter(path, uri, mPassword = pwd){
iniSetVerticalSeekbar(it)
}
pdfPageAdapter.clickAction = { pageIndex ->
......
......@@ -15,6 +15,7 @@ import com.tom_roush.pdfbox.pdmodel.PDPage
import com.tom_roush.pdfbox.pdmodel.PDPageContentStream
import com.tom_roush.pdfbox.pdmodel.common.PDRectangle
import com.tom_roush.pdfbox.pdmodel.encryption.AccessPermission
import com.tom_roush.pdfbox.pdmodel.encryption.InvalidPasswordException
import com.tom_roush.pdfbox.pdmodel.encryption.StandardProtectionPolicy
import com.tom_roush.pdfbox.pdmodel.graphics.image.PDImageXObject
import com.tom_roush.pdfbox.rendering.ImageType
......@@ -90,6 +91,9 @@ object PdfBoxUtils {
state = 0
}
}
}catch (e: InvalidPasswordException){
e.printStackTrace()
state = 1
} catch (e: IOException) {
e.printStackTrace()
state = -1
......
......@@ -27,10 +27,10 @@ class PdfPagerAdapter(
val uri: String? = null,
val itemLayout: Int = R.layout.item_pdf_pager,
private val previewScale: Float = 1f,
private val mPassword: String? = null,
initCallBack: ((itemCount: Int) -> Unit)? = null
) : BaseQuickAdapter<PdfPageBean, PdfPagerAdapter.PdfPagerViewHolder>() {
var mPassword: String? = null
var selectAction: ((enable: Boolean, allSelect: Boolean) -> Unit)? = null
var clickAction: ((pageIndex: Int) -> Unit)? = null
......@@ -183,12 +183,6 @@ class PdfPagerAdapter(
notifyDataSetChanged()
}
@SuppressLint("NotifyDataSetChanged")
fun setPassword(password: String) {
mPassword = password
notifyDataSetChanged()
}
fun release() {
scope.cancel()
pdfRender = null
......
......@@ -70,8 +70,7 @@ class PdfSplitActivity : BaseActivity<ActivityPdfSplitBinding>(), PdfView {
}
private fun initAdapter() {
pdfPagerAdapter = PdfPagerAdapter(path, null, R.layout.item_pdf_pager_split, 1.5f)
pdfPagerAdapter.mPassword = pwd
pdfPagerAdapter = PdfPagerAdapter(path, null, R.layout.item_pdf_pager_split, 1.5f, mPassword = pwd)
pdfPagerAdapter.selectAction = { enable, allSelect ->
binding.tvBtnSplit.isEnabled = enable
binding.ivSelector.isSelected = allSelect
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment