Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
rishujam committed Sep 30, 2023
1 parent 3f30a93 commit bf7f1c4
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dependencies {
implementation 'com.github.rishujam:PdfViewer:1.3'
}
```
## Demo
## How to use

XML File
```
Expand All @@ -46,13 +46,36 @@ Fragment/Activity
```
companion object {
private const val PATH = "/data/data/com.example.pdfviewer/files/sample_pdf.pdf"
private const val INTERNET_PATH =
"https://research.nhm.org/pdfs/10840/10840-001.pdf"
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.docView.setData(PATH)
binding.docView.loadData(
uri = INTERNET_PATH,
fromInternet = true,
) //If the path specified is a url you must set fromInternet value to true else set it to false.
//You can set download progress listener using this function
binding.docView.setDownloadStateChangeListener {
when (it) {
is DownloadState.Error -> {
Toast.makeText(this, it.message, Toast.LENGTH_SHORT).show()
}
is DownloadState.Completed -> {
//Do something..
}
is DownloadState.InProgress -> {
val totalFileSizeInBytes = it.totalSize
val progress = it.progress
}
}
}
}
```

0 comments on commit bf7f1c4

Please sign in to comment.