|
@@ -261,6 +261,7 @@ class ReaderViewModel(private val pdfSdkLicense: String, private val pdfSdkRsaMs
|
|
|
}
|
|
|
|
|
|
fun setReaderView(readerView: KMPDFReaderView) {
|
|
|
+ val isFirst = kmpdfFactory?.readerView == null
|
|
|
kmpdfFactory?.readerView = readerView
|
|
|
kmpdfDocumentController = kmpdfFactory?.getController(KMPDFFactory.ControllerType.DOCUMENT) as KMPDFDocumentController
|
|
|
updateViewDirection()
|
|
@@ -288,10 +289,31 @@ class ReaderViewModel(private val pdfSdkLicense: String, private val pdfSdkRsaMs
|
|
|
kmpdfFactory?.kmpdfAnnotEditModeChangeListener = KMPDFAnnotEditModeChangeListener {
|
|
|
annotationEitModeLiveData.postValue(it)
|
|
|
}
|
|
|
+
|
|
|
+ if (!isFirst) {
|
|
|
+ restoreStateBeforeDestroy()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun restoreStateBeforeDestroy() {
|
|
|
+ if (isCopyModeLiveData.value == true) {
|
|
|
+ startCopyTextMode()
|
|
|
+ } else {
|
|
|
+ val annotationEditMode = when (annotationModeLiveData.value) {
|
|
|
+ AnnotationMode.None, null -> KMPDFAnnotationBean.AnnotationType.NULL
|
|
|
+ AnnotationMode.Highlight -> KMPDFAnnotationBean.AnnotationType.HIGH_LIGHT
|
|
|
+ AnnotationMode.Strike -> KMPDFAnnotationBean.AnnotationType.STRIKE_OUT
|
|
|
+ AnnotationMode.Underline -> KMPDFAnnotationBean.AnnotationType.UNDER_LINE
|
|
|
+ AnnotationMode.Ink -> KMPDFAnnotationBean.AnnotationType.INK
|
|
|
+ }
|
|
|
+ kmpdfFactory?.setAnnotationEditMode(annotationEditMode)
|
|
|
+ kmpdfFactory?.kmpdfAnnotEditMode?.pdfAnnotEditMode = KMPDFAnnotEditMode.Mode.NULL
|
|
|
+ annotationEitModeLiveData.postValue(KMPDFAnnotEditMode.Mode.NULL)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
fun saveModifyingAnnotationBeforeDestroy() {
|
|
|
- stopAnnotationMode()
|
|
|
+ kmpdfFactory?.setAnnotationEditMode(KMPDFAnnotationBean.AnnotationType.NULL)
|
|
|
}
|
|
|
|
|
|
fun setPageIndex(pageIndex: Int){
|