|
@@ -261,6 +261,7 @@ class ReaderViewModel(private val pdfSdkLicense: String, private val pdfSdkRsaMs
|
|
}
|
|
}
|
|
|
|
|
|
fun setReaderView(readerView: KMPDFReaderView) {
|
|
fun setReaderView(readerView: KMPDFReaderView) {
|
|
|
|
+ val isFirst = kmpdfFactory?.readerView == null
|
|
kmpdfFactory?.readerView = readerView
|
|
kmpdfFactory?.readerView = readerView
|
|
kmpdfDocumentController = kmpdfFactory?.getController(KMPDFFactory.ControllerType.DOCUMENT) as KMPDFDocumentController
|
|
kmpdfDocumentController = kmpdfFactory?.getController(KMPDFFactory.ControllerType.DOCUMENT) as KMPDFDocumentController
|
|
updateViewDirection()
|
|
updateViewDirection()
|
|
@@ -288,10 +289,31 @@ class ReaderViewModel(private val pdfSdkLicense: String, private val pdfSdkRsaMs
|
|
kmpdfFactory?.kmpdfAnnotEditModeChangeListener = KMPDFAnnotEditModeChangeListener {
|
|
kmpdfFactory?.kmpdfAnnotEditModeChangeListener = KMPDFAnnotEditModeChangeListener {
|
|
annotationEitModeLiveData.postValue(it)
|
|
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() {
|
|
fun saveModifyingAnnotationBeforeDestroy() {
|
|
- stopAnnotationMode()
|
|
|
|
|
|
+ kmpdfFactory?.setAnnotationEditMode(KMPDFAnnotationBean.AnnotationType.NULL)
|
|
}
|
|
}
|
|
|
|
|
|
fun setPageIndex(pageIndex: Int){
|
|
fun setPageIndex(pageIndex: Int){
|