diff --git a/README.md b/README.md
index 34d8f86..aaf8fdd 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# PdfViewPager
-[ ](https://bintray.com/voghdev/maven/pdfviewpager/_latestVersion)
+[](https://jitpack.io/#voghDev/PdfViewPager)
[](https://android-arsenal.com/details/1/3155)
[](https://travis-ci.org/voghDev/PdfViewPager)
@@ -11,97 +11,190 @@ See [Official doc][6] for details.
If you are targeting pre-Lollipop devices, have a look at the [legacy sample][7]
-Installation
-------------
+## Installation
-Add this line in your *app/build.gradle*
+### Using [JitPack](https://jitpack.io/#voghDev/PdfViewPager)
+1. Add this line in your project module `build.gradle` at the end of repositories:
+```gradle
+allprojects {
+ repositories {
+ ...
+ maven { url 'https://jitpack.io' }
+ }
+}
+```
+2. Add this line in your app module `build.gradle` (`app/build.gradle`):
+```gradle
+implementation 'com.github.voghDev:PdfViewPager:1.1.2'
+```
- implementation 'es.voghdev.pdfviewpager:library:1.1.2'
+### Using JCenter (Deprecated)
-If you want to use the old `android.support` instead of `androidx`, add this dependency
+> **Note**: JCenter has been deprecated and will be unavailable soon. Please use **JitPack** instead of.
+
+Add this line in your app module `build.gradle` (`app/build.gradle`):
+```gradle
+implementation 'es.voghdev.pdfviewpager:library:1.1.2'
+```
- implementation 'es.voghdev.pdfviewpager:library:1.0.6'
+If you want to use the old `android.support` instead of `androidx`, add this dependency
+```gradle
+implementation 'es.voghdev.pdfviewpager:library:1.0.6'
+```
-Usage
------
+## Usage
Use **PDFViewPager** class to load PDF files from assets or SD card
![Screenshot][localPDFScreenshot] ![Screenshot][zoomingScreenshot]
-1.- Copy your assets to cache directory if your PDF is located on assets directory
+1. Copy your assets to cache directory if your PDF is located on assets directory
+```java
+CopyAsset copyAsset = new CopyAssetThreadImpl(context, new Handler());
+copyAsset.copy(asset, new File(getCacheDir(), "sample.pdf").getAbsolutePath());
+```
- CopyAsset copyAsset = new CopyAssetThreadImpl(context, new Handler());
- copyAsset.copy(asset, new File(getCacheDir(), "sample.pdf").getAbsolutePath());
+
+Kotlin
+
+```kotlin
+val copyAsset: CopyAsset = CopyAssetThreadImpl(context, Handler())
+copyAsset.copy(asset, File(cacheDir, "sample.pdf").absolutePath)
+```
-2a.- Create your **PDFViewPager** passing your PDF file, located in *assets* (see [sample][8])
+
- pdfViewPager = new PDFViewPager(this, "sample.pdf");
+2a. Create your **PDFViewPager** passing your PDF file, located in *assets* (see [sample][8])
+```java
+pdfViewPager = new PDFViewPager(this, "sample.pdf");
+```
-2b.- Or directly, declare it on your XML layout
+
+Kotlin
+
+```kotlin
+pdfViewPager = PDFViewPager(this, "sample.pdf")
+```
+
+
-
+2b. Or directly, declare it on your XML layout
+```xml
+
+```
It will automatically have zooming and panning capability
-3.- Release adapter in *onDestroy*
+3. Release adapter in *onDestroy*
+```java
+@Override
+protected void onDestroy() {
+ super.onDestroy();
- @Override
- protected void onDestroy() {
- super.onDestroy();
+ ((PDFPagerAdapter) pdfViewPager.getAdapter()).close();
+}
+```
- ((PDFPagerAdapter) pdfViewPager.getAdapter()).close();
- }
+
+Kotlin
+
+```kotlin
+override fun onDestroy() {
+ super.onDestroy()
+ (pdfViewPager.adapter as PDFPagerAdapter).close()
+}
+```
-PDF's on SD card
-----------------
+
-1.- Create a **PDFViewPager** object, passing the file location in your SD card
- PDFViewPager pdfViewPager = new PDFViewPager(context, getPdfPathOnSDCard());
+### PDF's on SD card
- protected String getPdfPathOnSDCard() {
- File f = new File(getExternalFilesDir("pdf"), "adobe.pdf");
- return f.getAbsolutePath();
- }
+1. Create a **PDFViewPager** object, passing the file location in your SD card
+```java
+PDFViewPager pdfViewPager = new PDFViewPager(context, new File(getExternalFilesDir("pdf"), "adobe.pdf").getAbsolutePath());
+```
+
+
+Kotlin
+
+```kotlin
+val pdfViewPager = PDFViewPager(context, File(getExternalFilesDir("pdf"), "adobe.pdf").absolutePath)
+```
+
+
-2.- Don't forget to release the adapter in *onDestroy*
+2. Don't forget to release the adapter in *onDestroy*
+```java
+@Override
+protected void onDestroy() {
+ super.onDestroy();
+ ((PDFPagerAdapter) pdfViewPager.getAdapter()).close();
+}
+```
- @Override
- protected void onDestroy() {
- super.onDestroy();
+
+Kotlin
- ((PDFPagerAdapter) pdfViewPager.getAdapter()).close();
- }
+```kotlin
+override fun onDestroy() {
+ super.onDestroy()
+ (pdfViewPager!!.adapter as PDFPagerAdapter?)!!.close()
+}
+```
-Remote PDF's from a URL
------------------------
+
+
+### Remote PDF's from a URL
![Screenshot][remotePDFScreenshot]
-1.- Add `INTERNET`, `READ_EXTERNAL_STORAGE` and `WRITE_EXTERNAL_STORAGE` permissions on your AndroidManifest.xml
+1. Add `INTERNET`, `READ_EXTERNAL_STORAGE` and `WRITE_EXTERNAL_STORAGE` permissions on your AndroidManifest.xml
+```xml
+
+
+
+```
-
-
-
+2. Make your Activity or Fragment implement DownloadFile.Listener
+```java
+public class RemotePDFActivity extends AppCompatActivity implements DownloadFile.Listener {
+```
-2.- Make your Activity or Fragment implement DownloadFile.Listener
+
+Kotlin
- public class RemotePDFActivity extends AppCompatActivity implements DownloadFile.Listener {
+```kotlin
+class RemotePDFActivity: AppCompatActivity (), DownloadFile.Listener {
+```
-3.- Create a **RemotePDFViewPager** object
+
- String url = "http://www.cals.uidaho.edu/edComm/curricula/CustRel_curriculum/content/sample.pdf";
-
- RemotePDFViewPager remotePDFViewPager =
- new RemotePDFViewPager(context, url, this);
+3. Create a **RemotePDFViewPager** object
+```java
+String url = "http://www.cals.uidaho.edu/edComm/curricula/CustRel_curriculum/content/sample.pdf";
+
+RemotePDFViewPager remotePDFViewPager = new RemotePDFViewPager(context, url, this);
+```
+
+
+Kotlin
+
+```kotlin
+val url = "http://www.cals.uidaho.edu/edComm/curricula/CustRel_curriculum/content/sample.pdf"
+
+val remotePDFViewPager = RemotePDFViewPager(context, url, this)
+```
+
+
-4.- Configure the corresponding callbacks and they will be called on each situation.
+4. Configure the corresponding callbacks and they will be called on each situation.
+```java
@Override
public void onSuccess(String url, String destinationPath) {
// That's the positive case. PDF Download went fine
@@ -121,25 +214,61 @@ Remote PDF's from a URL
// You will get download progress here
// Always on UI Thread so feel free to update your views here
}
+```
-5.- Don't forget to close adapter in *onDestroy* to release all resources
+
+Kotlin
- @Override
- protected void onDestroy() {
- super.onDestroy();
+```kotlin
+override fun onSuccess(url: String?, destinationPath: String?) {
+ // That's the positive case. PDF Download went fine
- adapter.close();
- }
+ adapter = PDFPagerAdapter(this, "AdobeXMLFormsSamples.pdf")
+ remotePDFViewPager.setAdapter(adapter)
+ setContentView(remotePDFViewPager)
+}
+
+override fun onFailure(e: Exception?) {
+ // This will be called if download fails
+}
+
+override fun onProgressUpdate(progress: Int, total: Int) {
+ // You will get download progress here
+ // Always on UI Thread so feel free to update your views here
+}
+```
+
+
+
+5. Don't forget to close adapter in *onDestroy* to release all resources
+```java
+@Override
+protected void onDestroy() {
+ super.onDestroy();
-Usage in Kotlin
----------------
+ adapter.close();
+}
+```
-As you might figure out, the library is fully usable in Kotlin programming language. You can find example code [here][12].
+
+Kotlin
-Just import the library as a gradle dependency as you would do in Java.
+```kotlin
+override fun onDestroy() {
+ super.onDestroy()
-TODOs
------
+ adapter.close()
+}
+```
+
+
+
+
+### Usage in Kotlin
+
+This library is fully usable in Kotlin programming language. Equivalent to all codes in the Kotlin language noted and you can also find example code [here][12].
+
+## TODOs
- [X] Make initial Pdf scale setable by code *(requested by various users on issues)*
- [X] Load PDF documents from SD card
@@ -151,8 +280,32 @@ TODOs
See [changelog][4] for details
-Developed By
-------------
+## Contributing
+
+### For noobs (like me some months ago)
+
+1. Fork the project into your GitHub account
+2. Now clone your GitHub repo for this project
+3. Implement your changes
+4. Commit your changes, push them into your repo
+5. Review your code and send me a pull request if you consider it
+
+### For not-so-noobs
+
+Please make sure that your changes pass both checkstyle and UI tests before submitting them
+
+```shell
+./gradlew checkstyle
+
+./gradlew test
+```
+
+And with your Android device connected
+```shell
+./gradlew connectedCheck
+```
+
+## Developed By
* Olmo Gallegos Hernández - [voghDev][9] - [mobiledevstories.com][10]
@@ -163,14 +316,13 @@ Developed By
-Support
--------
+## Support
This repository has been supported by JetBrains with free licenses for all JetBrains products
-# License
+## License
Copyright 2016 Olmo Gallegos Hernández
@@ -186,29 +338,6 @@ This repository has been supported by JetBrains with free licenses for all JetBr
See the License for the specific language governing permissions and
limitations under the License.
-Contributing
-------------
-
-**For noobs (like me some months ago)**
-
- fork the project into your GitHub account
- now clone your GitHub repo for this project
- implement your changes
- commit your changes, push them into your repo
- review your code and send me a pull request if you consider it
-
-**For not-so-noobs**
-
-Please make sure that your changes pass both checkstyle and UI tests before submitting them
-
- ./gradlew checkstyle
-
- ./gradlew test
-
-And with your Android device connected
-
- ./gradlew connectedCheck
-
[remotePDFScreenshot]: ./screenshots/remote.gif
[localPDFScreenshot]: ./screenshots/local.gif
[sdcardPDFScreenshot]: ./screenshots/sdcard.gif