mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-01-04 04:49:58 +01:00
use ViewPager2 at pdf viewer
This commit is contained in:
parent
ab47bcadbe
commit
12aae27ccd
@ -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'
|
||||
|
@ -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)
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<es.voghdev.pdfviewpager.library.PDFViewPager
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/pdf_viewer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
Loading…
Reference in New Issue
Block a user