|
@@ -3,14 +3,16 @@ package com.kdanmobile.reader
|
|
import android.arch.lifecycle.MutableLiveData
|
|
import android.arch.lifecycle.MutableLiveData
|
|
import android.arch.lifecycle.ViewModel
|
|
import android.arch.lifecycle.ViewModel
|
|
import android.content.Context
|
|
import android.content.Context
|
|
|
|
+import android.graphics.Bitmap
|
|
import android.net.Uri
|
|
import android.net.Uri
|
|
import com.kdanmobile.kmpdfkit.annotation.bean.*
|
|
import com.kdanmobile.kmpdfkit.annotation.bean.*
|
|
import com.kdanmobile.kmpdfkit.globaldata.Config
|
|
import com.kdanmobile.kmpdfkit.globaldata.Config
|
|
import com.kdanmobile.kmpdfkit.manager.KMPDFFactory
|
|
import com.kdanmobile.kmpdfkit.manager.KMPDFFactory
|
|
import com.kdanmobile.kmpdfkit.manager.controller.KMPDFDocumentController
|
|
import com.kdanmobile.kmpdfkit.manager.controller.KMPDFDocumentController
|
|
import com.kdanmobile.kmpdfkit.pdfcommon.KMPDFReaderView
|
|
import com.kdanmobile.kmpdfkit.pdfcommon.KMPDFReaderView
|
|
|
|
+import com.kdanmobile.reader.screen.view.ThumbnailHandler
|
|
|
|
|
|
-class ReaderViewModel(private val pdfSdkLicense: String, private val pdfSdkRsaMsg: String) : ViewModel() {
|
|
|
|
|
|
+class ReaderViewModel(private val pdfSdkLicense: String, private val pdfSdkRsaMsg: String) : ViewModel(), ThumbnailHandler {
|
|
enum class ViewDirection(val mode: Config.PDFViewMode) {
|
|
enum class ViewDirection(val mode: Config.PDFViewMode) {
|
|
VerticalSinglePageContinues(Config.PDFViewMode.VERTICAL_SINGLE_PAGE_CONTINUES),
|
|
VerticalSinglePageContinues(Config.PDFViewMode.VERTICAL_SINGLE_PAGE_CONTINUES),
|
|
VerticalSinglePage(Config.PDFViewMode.VERTICAL_SINGLE_PAGE),
|
|
VerticalSinglePage(Config.PDFViewMode.VERTICAL_SINGLE_PAGE),
|
|
@@ -160,4 +162,26 @@ class ReaderViewModel(private val pdfSdkLicense: String, private val pdfSdkRsaMs
|
|
refresh(false)
|
|
refresh(false)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // ====================================================================
|
|
|
|
+ // implement ThumbnailHandler
|
|
|
|
+ // ====================================================================
|
|
|
|
+
|
|
|
|
+ override fun getPdfPageCount(): Int? {
|
|
|
|
+ return kmpdfDocumentController?.getDocumentPageCount(false)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun getCurrentPage(): Int? {
|
|
|
|
+ return kmpdfDocumentController?.currentPageNum
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun setCurrentPage(page: Int): Boolean? {
|
|
|
|
+ return kmpdfDocumentController?.gotoPage(page)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun getPdfBitmap(position: Int, picWidth: Int, mode: Int, isDrawAnnot: Boolean): Bitmap? {
|
|
|
|
+ return kmpdfDocumentController?.covertPDFToBitmap(position, picWidth, mode, isDrawAnnot)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // ====================================================================
|
|
}
|
|
}
|