Skip to content

Commit d4cb463

Browse files
author
Widas_Manish
committed
Light Weight Pdf Renderer
0 parents  commit d4cb463

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2705
-0
lines changed

Diff for: .gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/libraries
5+
/.idea/modules.xml
6+
/.idea/workspace.xml
7+
.DS_Store
8+
/build
9+
/captures
10+
.externalNativeBuild

Diff for: .idea/caches/build_file_checksums.ser

604 Bytes
Binary file not shown.

Diff for: .idea/codeStyles/Project.xml

+29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/gradle.xml

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/misc.xml

+34
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/runConfigurations.xml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: android-pdf-viewer/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

Diff for: android-pdf-viewer/build.gradle

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apply plugin: 'com.android.library'
2+
3+
android {
4+
compileSdkVersion 28
5+
6+
7+
8+
defaultConfig {
9+
minSdkVersion 21
10+
targetSdkVersion 28
11+
versionCode 1
12+
versionName "1.0"
13+
14+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15+
16+
}
17+
18+
buildTypes {
19+
release {
20+
minifyEnabled false
21+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22+
}
23+
}
24+
25+
}
26+
27+
dependencies {
28+
implementation fileTree(dir: 'libs', include: ['*.jar'])
29+
30+
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
31+
testImplementation 'junit:junit:4.12'
32+
androidTestImplementation 'com.android.support.test:runner:1.0.2'
33+
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
34+
}

Diff for: android-pdf-viewer/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.github.pdfviewer;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumented test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("com.github.pdfviewer.test", appContext.getPackageName());
25+
}
26+
}

Diff for: android-pdf-viewer/src/main/AndroidManifest.xml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.github.pdfviewer" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.github.pdfviewer;
2+
3+
import android.graphics.Bitmap;
4+
5+
public interface IShowPage {
6+
7+
public Bitmap showPage(int index);
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.github.pdfviewer;
2+
3+
import android.content.Context;
4+
import android.support.annotation.NonNull;
5+
import android.support.v4.view.PagerAdapter;
6+
import android.view.LayoutInflater;
7+
import android.view.View;
8+
import android.view.ViewGroup;
9+
import android.widget.ImageView;
10+
import android.widget.LinearLayout;
11+
12+
public class PDFAdapter extends PagerAdapter {
13+
14+
private int page_count;
15+
private Context context;
16+
private IShowPage listener;
17+
18+
19+
public PDFAdapter(Context context, IShowPage listener, int page_count) {
20+
this.context = context;
21+
this.listener = listener;
22+
this.page_count = page_count;
23+
}
24+
25+
@Override
26+
public int getCount() {
27+
return page_count;
28+
}
29+
30+
@NonNull
31+
@Override
32+
public Object instantiateItem(@NonNull ViewGroup container, int position) {
33+
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
34+
35+
View itemView = inflater.inflate(R.layout.each_page, container, false);
36+
37+
PDFZoomImageView imageView = (PDFZoomImageView) itemView.findViewById(R.id.image);
38+
39+
imageView.setImageBitmap(listener.showPage(position));
40+
41+
container.addView(itemView);
42+
43+
return itemView;
44+
}
45+
46+
public void destroyItem(ViewGroup container, int position, Object object) {
47+
container.removeView((LinearLayout) object);
48+
}
49+
50+
public boolean isViewFromObject(View view, Object object) {
51+
return view == object;
52+
}
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package com.github.pdfviewer;
2+
3+
import android.os.Parcel;
4+
import android.os.Parcelable;
5+
6+
public class PDFConfig implements Parcelable {
7+
8+
public static final String EXTRA_CONFIG = "PDFConfig";
9+
10+
private String filepath;
11+
private int swipeorientation;
12+
13+
public PDFConfig() {
14+
15+
}
16+
17+
protected PDFConfig(Parcel in) {
18+
this.filepath = in.readString();
19+
this.swipeorientation = in.readInt();
20+
}
21+
22+
23+
public String getFilepath() {
24+
return filepath;
25+
}
26+
27+
public void setFilepath(String filepath) {
28+
this.filepath = filepath;
29+
}
30+
31+
public int getSwipeorientation() {
32+
return swipeorientation;
33+
}
34+
35+
public void setSwipeorientation(int swipeorientation) {
36+
this.swipeorientation = swipeorientation;
37+
}
38+
39+
@Override
40+
public void writeToParcel(Parcel dest, int flags) {
41+
dest.writeString(filepath);
42+
dest.writeInt(swipeorientation);
43+
44+
}
45+
46+
@Override
47+
public int describeContents() {
48+
return 0;
49+
}
50+
51+
public static final Creator<PDFConfig> CREATOR = new Creator<PDFConfig>() {
52+
@Override
53+
public PDFConfig createFromParcel(Parcel in) {
54+
return new PDFConfig(in);
55+
}
56+
57+
@Override
58+
public PDFConfig[] newArray(int size) {
59+
return new PDFConfig[size];
60+
}
61+
};
62+
}

0 commit comments

Comments
 (0)