Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for older Android APIs. #129

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion android-pdfview/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ android {
jniLibs.srcDirs = [ 'libs' ]
}
}
}
}

dependencies {
compile 'com.nineoldandroids:library:2.4.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@
*/
package com.joanzapata.pdfview;

import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.graphics.PointF;
import android.view.animation.DecelerateInterpolator;

import com.joanzapata.pdfview.PDFView;
import com.nineoldandroids.animation.Animator;
import com.nineoldandroids.animation.ValueAnimator;

/**
* @author Joan Zapata
Expand Down Expand Up @@ -88,7 +85,7 @@ public void stopAll() {
}
}

class XAnimation implements AnimatorUpdateListener {
class XAnimation implements ValueAnimator.AnimatorUpdateListener {

@Override
public void onAnimationUpdate(ValueAnimator animation) {
Expand All @@ -98,7 +95,7 @@ public void onAnimationUpdate(ValueAnimator animation) {

}

class YAnimation implements AnimatorUpdateListener {
class YAnimation implements ValueAnimator.AnimatorUpdateListener {

@Override
public void onAnimationUpdate(ValueAnimator animation) {
Expand All @@ -108,7 +105,7 @@ public void onAnimationUpdate(ValueAnimator animation) {

}

class ZoomAnimation implements AnimatorUpdateListener, AnimatorListener {
class ZoomAnimation implements ValueAnimator.AnimatorUpdateListener, Animator.AnimatorListener {

@Override
public void onAnimationUpdate(ValueAnimator animation) {
Expand Down Expand Up @@ -136,3 +133,4 @@ public void onAnimationStart(Animator animation) {
}

}

24 changes: 21 additions & 3 deletions android-pdfview/src/main/java/com/joanzapata/pdfview/PDFView.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@
package com.joanzapata.pdfview;

import android.content.Context;
import android.graphics.*;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.util.AttributeSet;
import android.view.SurfaceView;

import com.joanzapata.pdfview.exception.FileNotFoundException;
import com.joanzapata.pdfview.listener.OnDrawListener;
import com.joanzapata.pdfview.listener.OnLoadCompleteListener;
Expand All @@ -34,6 +42,7 @@
import com.joanzapata.pdfview.util.Constants;
import com.joanzapata.pdfview.util.FileUtils;
import com.joanzapata.pdfview.util.NumberUtils;

import org.vudroid.core.DecodeService;

import java.io.File;
Expand Down Expand Up @@ -230,10 +239,18 @@ private void load(Uri uri, OnLoadCompleteListener onLoadCompleteListener, int[]

// Start decoding document
decodingAsyncTask = new DecodingAsyncTask(uri, this);
decodingAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
decodingAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else {
decodingAsyncTask.execute();
}

renderingAsyncTask = new RenderingAsyncTask(this);
renderingAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
renderingAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else {
renderingAsyncTask.execute();
}
}

/**
Expand Down Expand Up @@ -1094,3 +1111,4 @@ public void setSwipeVertical(boolean swipeVertical) {
this.swipeVertical = swipeVertical;
}
}