Commit 9964ecd4 authored by wanglei's avatar wanglei

...提交部分功能...

parent 3ad487b9
......@@ -52,8 +52,10 @@ class PdfBrowserActivity : BaseActivity<ActivityPdfBrowserBinding>() {
finishToMain()
}, ok = { password ->
var pdDocument: PDDocument? = null
runCatching {
pdDocument = PDDocument.load(file, password)
pdDocument = try {
PDDocument.load(file, password)
} catch (e: Exception) {
null
}
if (pdDocument != null) {
dialog?.dismiss()
......
......@@ -120,26 +120,28 @@ object DialogViews {
val dialog = AlertDialog.Builder(this)
.setView(view)
.setPositiveButton("OK")
{ dialog, which ->
val pwd = binding.editPassword.text.toString()
if (pwd.isEmpty()) {
Toast.makeText(this, "Password cannot be empty", Toast.LENGTH_SHORT).show()
return@setPositiveButton
}
ok.invoke(pwd)
}.setNegativeButton("CANCEL")
.setPositiveButton("OK", null)
.setNegativeButton("CANCEL")
{ dialog, which ->
dialog.dismiss()
cancel.invoke()
}.create()
dialog.setCancelable(false)
dialog.setCanceledOnTouchOutside(false)
dialog.show()
val pButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE)
val nButton = dialog.getButton(AlertDialog.BUTTON_NEGATIVE)
pButton.setOnClickListener {
val pwd = binding.editPassword.text.toString()
if (pwd.isEmpty()) {
Toast.makeText(this, "Password cannot be empty", Toast.LENGTH_SHORT).show()
return@setOnClickListener
}
ok.invoke(pwd)
}
pButton.textSize = 16f
pButton.setTextColor(ContextCompat.getColor(this, R.color.color_pdf))
nButton.textSize = 16f
......
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