Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Commit

Permalink
Develop (#113)
Browse files Browse the repository at this point in the history
Co-authored-by: Eko Prasetyo <[email protected]>
Co-authored-by: Nicodème Stalder <[email protected]>
Co-authored-by: Ahmed Masoud <[email protected]>
Co-authored-by: Ahmed Masoud <[email protected]>
Co-authored-by: Enver ALTIN <[email protected]>
Co-authored-by: Robert Hillary <[email protected]>
Co-authored-by: Damodar Lohani <[email protected]>
Co-authored-by: ncdm-stldr <[email protected]>
Co-authored-by: matthitachi <[email protected]>
  • Loading branch information
9 people authored Aug 1, 2022
1 parent 43ae962 commit 4e5d96b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 2.0.2
* Bugfix crashing

## 2.0.1
* Bug fixes related to cache
* improvements
Expand Down Expand Up @@ -57,4 +60,4 @@

## 1.0.0
- First upgraded version after fork
- Cool new customization features
- Cool new customization features
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,14 @@ public void run() {
if (pageResult == null) {
Log.d(TAG, "Retrieving page failed.");
result.notImplemented();
}else {
mainThreadHandler.post(new Runnable() {
@Override
public void run() {
result.success(pageResult);
}
});
}
mainThreadHandler.post(new Runnable() {
@Override
public void run() {
result.success(pageResult);
}
});
break;
default:
result.notImplemented();
Expand Down Expand Up @@ -153,24 +154,29 @@ private String getFileNameFromPath(String name) {
}

private String createTempPreview(Bitmap bmp, String name, int page) {
if (context == null) {
if (context == null) {
Log.d(TAG, "createTempPreview: Context is null!");
return null;
}
String fileNameOnly = getFileNameFromPath(name);
File file;
File to;
try {
String fileName = String.format(Locale.US, "%s-%d.png", fileNameOnly, page);
file = File.createTempFile(fileName, null, context.getCacheDir());
FileOutputStream out = new FileOutputStream(file);
bmp.compress(Bitmap.CompressFormat.PNG, 100, out);
out.flush();
out.close();
//what you are renaming the file to
to = new File(context.getCacheDir(), fileName);
// //now rename
file.renameTo(to);
} catch (Exception e) {
e.printStackTrace();
return null;
}
return file.getAbsolutePath();
return to.getAbsolutePath();
}

private String getPage(String filePath, @Nullable Integer pageNumber) {
Expand Down Expand Up @@ -200,7 +206,6 @@ private String getPage(String filePath, @Nullable Integer pageNumber) {
ret = createTempPreview(bitmap, filePath, pageNumber);
} finally {
page.close();
renderer.close();
}
return ret;
} catch (Exception ex) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: advance_pdf_viewer
description: A flutter plugin for handling PDF files. Works on both Android & iOS
version: 2.0.1
version: 2.0.2
homepage: https://github.com/lohanidamodar/pdf_viewer

environment:
Expand Down

0 comments on commit 4e5d96b

Please sign in to comment.