diff --git a/app/build.gradle b/app/build.gradle index 261373de..eb79c856 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -65,7 +65,7 @@ android { dependencies { implementation 'com.github.SimpleMobileTools:Simple-Commons:b452494768' - implementation 'com.github.tibbi:PdfViewPager:1bc22f031a' + implementation 'com.github.tibbi:PdfViewPager:6f9641fd2c' implementation 'com.github.Stericson:RootTools:df729dcb13' implementation 'com.github.Stericson:RootShell:1.6' implementation 'com.alexvasilkov:gesture-views:2.5.2' diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/PDFViewerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/PDFViewerActivity.kt index 16a2b1de..6b4884e1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/PDFViewerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/PDFViewerActivity.kt @@ -6,8 +6,10 @@ import android.graphics.Color import android.os.Bundle import android.print.PrintAttributes import android.print.PrintManager +import android.view.View import android.view.WindowManager import android.widget.RelativeLayout +import androidx.viewpager2.widget.ViewPager2 import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.REAL_FILE_PATH import com.simplemobiletools.commons.helpers.isPiePlus @@ -15,14 +17,13 @@ import com.simplemobiletools.filemanager.pro.R import com.simplemobiletools.filemanager.pro.extensions.hideSystemUI import com.simplemobiletools.filemanager.pro.extensions.showSystemUI import com.simplemobiletools.filemanager.pro.helpers.PdfDocumentAdapter -import es.voghdev.pdfviewpager.library.adapter.BasePDFPagerAdapter import es.voghdev.pdfviewpager.library.adapter.PDFPagerAdapter +import es.voghdev.pdfviewpager.library.adapter.PdfErrorHandler import kotlinx.android.synthetic.main.activity_pdf_viewer.* class PDFViewerActivity : SimpleActivity() { private var realFilePath = "" private var isFullScreen = false - private var adapter: BasePDFPagerAdapter? = null override fun onCreate(savedInstanceState: Bundle?) { showTransparentTop = true @@ -56,11 +57,6 @@ class PDFViewerActivity : SimpleActivity() { window.navigationBarColor = Color.TRANSPARENT } - override fun onDestroy() { - super.onDestroy() - adapter?.close() - } - private fun setupMenu() { (pdf_viewer_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight pdf_viewer_toolbar.menu.apply { @@ -99,19 +95,16 @@ class PDFViewerActivity : SimpleActivity() { return } + pdf_viewer.orientation = ViewPager2.ORIENTATION_VERTICAL pdf_viewer.setBackgroundColor(getProperBackgroundColor()) - adapter = PDFPagerAdapter.Builder(this) - .setPdfPath(uri.toString()) - .setOnPageClickListener { - toggleFullScreen() - } - .setErrorHandler { throwable -> - showErrorToast(throwable.toString()) - } - .create() + val clickListener = View.OnClickListener { + toggleFullScreen() + } - pdf_viewer.adapter = adapter + val errorHandler = PdfErrorHandler { throwable -> showErrorToast(throwable.toString()) } + + pdf_viewer.adapter = PDFPagerAdapter(this, clickListener, errorHandler, uri.toString()) showSystemUI(true) diff --git a/app/src/main/res/layout/activity_pdf_viewer.xml b/app/src/main/res/layout/activity_pdf_viewer.xml index a8b95e51..93244f33 100644 --- a/app/src/main/res/layout/activity_pdf_viewer.xml +++ b/app/src/main/res/layout/activity_pdf_viewer.xml @@ -6,7 +6,7 @@ android:layout_height="wrap_content" app:layout_behavior="@string/appbar_scrolling_view_behavior"> -