Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d3de236

Browse files
committed
Merge pull request by skarempudi which fixes SDK 23 permission problems in sample app
Merge pull request by skarempudi for showing info on phones without file manager Add feature from 1.x - canvas is set to drawable from View#getBackground() Add info about new repo to README
1 parent 7052eda commit d3de236

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
# Android PdfViewer
44

5+
AndroidPdfViewer 1.x is available on [AndroidPdfViewerV1](https://github.com/barteksc/AndroidPdfViewerV1)
6+
repo, where can be developed independently.
7+
58
Library for displaying PDF documents on Android, with `animations`, `gestures`, `zoom` and `double tap` support.
69
It is based on [PdfiumAndroid](https://github.com/barteksc/PdfiumAndroid) for decoding PDF files. Works on API 11 and higher.
710
Licensed under Apache License 2.0.

android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/PDFView.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
import android.graphics.PointF;
2525
import android.graphics.Rect;
2626
import android.graphics.RectF;
27+
import android.graphics.drawable.Drawable;
2728
import android.net.Uri;
2829
import android.os.AsyncTask;
2930
import android.util.AttributeSet;
3031
import android.util.Log;
31-
import android.view.View;
3232
import android.widget.RelativeLayout;
3333

3434
import com.github.barteksc.pdfviewer.exception.FileNotFoundException;
@@ -529,7 +529,13 @@ protected void onDraw(Canvas canvas) {
529529
// abstraction of the screen position when rendering the parts.
530530

531531
// Draws background
532-
canvas.drawColor(Color.WHITE);
532+
533+
Drawable bg = getBackground();
534+
if (bg == null) {
535+
canvas.drawColor(Color.WHITE);
536+
} else {
537+
bg.draw(canvas);
538+
}
533539

534540
if (recycled) {
535541
return;

sample/src/main/java/com/github/barteksc/sample/PDFViewActivity.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import android.database.Cursor;
2222
import android.net.Uri;
2323
import android.provider.OpenableColumns;
24+
import android.support.annotation.NonNull;
2425
import android.support.v4.app.ActivityCompat;
2526
import android.support.v4.content.ContextCompat;
2627
import android.support.v7.app.AppCompatActivity;
@@ -31,7 +32,6 @@
3132
import com.github.barteksc.pdfviewer.listener.OnLoadCompleteListener;
3233
import com.github.barteksc.pdfviewer.listener.OnPageChangeListener;
3334
import com.github.barteksc.pdfviewer.scroll.DefaultScrollHandle;
34-
import com.github.barteksc.pdfviewer.scroll.ScrollHandle;
3535
import com.shockwave.pdfium.PdfDocument;
3636

3737
import org.androidannotations.annotations.AfterViews;
@@ -43,6 +43,7 @@
4343
import org.androidannotations.annotations.ViewById;
4444

4545
import java.util.List;
46+
4647
@EActivity(R.layout.activity_main)
4748
@OptionsMenu(R.menu.options)
4849
public class PDFViewActivity extends AppCompatActivity implements OnPageChangeListener, OnLoadCompleteListener {
@@ -89,8 +90,7 @@ void launchPicker() {
8990
intent.setType("application/pdf");
9091
try {
9192
startActivityForResult(intent, REQUEST_CODE);
92-
}
93-
catch (ActivityNotFoundException e) {
93+
} catch (ActivityNotFoundException e) {
9494
//alert user that file manager not working
9595
Toast.makeText(this, R.string.toast_pick_file_error, Toast.LENGTH_SHORT).show();
9696
}
@@ -193,13 +193,14 @@ public void printBookmarksTree(List<PdfDocument.Bookmark> tree, String sep) {
193193

194194
/**
195195
* Listener for response to user permission request
196-
* @param requestCode Check that permission request code matches
197-
* @param permissions Permissions that requested
196+
*
197+
* @param requestCode Check that permission request code matches
198+
* @param permissions Permissions that requested
198199
* @param grantResults Whether permissions granted
199200
*/
200201
@Override
201-
public void onRequestPermissionsResult(int requestCode, String permissions[],
202-
int[] grantResults) {
202+
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[],
203+
@NonNull int[] grantResults) {
203204
if (requestCode == PERMISSION_CODE) {
204205
if (grantResults.length > 0
205206
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {

0 commit comments

Comments
 (0)