package com.base.pdfviewerscannerwhite.ui.document.pdf

import android.content.Context
import android.os.Environment
import android.os.Handler
import com.base.pdfviewerscannerwhite.bean.PdfPageBean
import com.base.pdfviewerscannerwhite.utils.PdfUtils
import com.base.pdfviewerscannerwhite.utils.ToastUtils.toast
import java.io.File


class PdfPresenter(val context: Context, val pdfView: PdfView) {

    var handler: Handler? = null

    fun splitPdf(pdfPath: String) = Thread {

        val drawableList = PdfUtils.getPdfDrawables(context, pdfPath)

        handler?.post {
            context.toast("size=${drawableList.size}")
        }

    }.start()

    fun iniPdfPage(filePath: String) {
        val list = arrayListOf<PdfPageBean>()
        val number = PdfUtils.getNumberOfPages(filePath)
        repeat(number) {
            list.add(PdfPageBean(it))
        }
        pdfView.initPdfPageRv(list)
    }
}