Commit 473e0762 authored by wanglei's avatar wanglei

...提交部分ui...

parent 68f0c62e
......@@ -57,5 +57,7 @@ dependencies {
implementation 'com.github.bumptech.glide:glide:4.16.0'
//pdf浏览
//https://github.com/DImuthuUpe/AndroidPdfViewer
implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'
implementation 'com.github.barteksc:pdfium-android:1.7.1'
}
\ No newline at end of file
......@@ -18,4 +18,6 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
\ No newline at end of file
#-renamesourcefileattribute SourceFile
-keep class com.shockwave.**
\ No newline at end of file
package com.base.superpdfreader.activity
import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.base.superpdfreader.R
import com.base.superpdfreader.databinding.ActivityPdfBrowserBinding
import com.base.superpdfreader.helps.BaseActivity
import com.github.barteksc.pdfviewer.scroll.DefaultScrollHandle
import java.io.File
class PdfBrowserActivity : BaseActivity<ActivityPdfBrowserBinding>() {
var pageNumber = 0
override val binding: ActivityPdfBrowserBinding by lazy {
ActivityPdfBrowserBinding.inflate(layoutInflater)
}
override fun initView() {
val path = intent.extras?.getString("Path") ?: ""
val file = File(path)
if (file.exists()) {
binding.pdfview.fromFile(file)
.defaultPage(pageNumber)
.enableAnnotationRendering(true)
.scrollHandle(object : DefaultScrollHandle(this) {})
.spacing(10)
.onPageError { page, t -> }
.load()
}
}
}
\ No newline at end of file
......@@ -46,7 +46,13 @@ class DocumentAdapter(val itemClick: (bean: DocumentBean) -> Unit) : RecyclerVie
list.forEach { file ->
val flag = hasData.add(file)
if (flag) {
val bean = DocumentBean(drawable, file.name, file.lastModified(), file.length(), type)
val bean = DocumentBean(
drawable,
file.name,
file.lastModified(),
file.length(),
file.absolutePath, type
)
docList.add(bean)
}
}
......
......@@ -10,6 +10,7 @@ data class DocumentBean(
val name: String = "",
val time: Long = 0,
val size: Long = 0,
val path: String = "",
val type: String = "",
) {
@SuppressLint("SimpleDateFormat")
......
......@@ -68,7 +68,9 @@ object DocumentDetailDialog {
}
}
binding.llOpen.setOnClickListener {
startActivity(Intent(this, PdfBrowserActivity::class.java))
startActivity(Intent(this, PdfBrowserActivity::class.java).apply {
putExtra("Path", bean.path)
})
}
}
}
\ No newline at end of file
......@@ -7,10 +7,17 @@
android:layout_height="match_parent"
tools:context=".activity.PdfBrowserActivity">
<com.github.barteksc.pdfviewer.PDFView
android:id="@+id/pdfview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/ll_tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
......
......@@ -20,4 +20,5 @@ kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
\ No newline at end of file
android.nonTransitiveRClass=true
android.enableJetifier=true
\ No newline at end of file
......@@ -14,8 +14,9 @@ pluginManagement {
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
google()
jcenter()
maven { url 'https://jitpack.io' }
maven { url "https://android-sdk.is.com" }
maven { url "https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea" }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment