Skip to content

[Android] Fix NPE on mTempFiles #702

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

Merged
merged 6 commits into from
Apr 1, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,16 @@ public class DocumentView extends com.pdftron.pdf.controls.DocumentView2 {
private String mBase64Extension = ".pdf";
private String mDocumentExtension;

private ArrayList<File> mTempFiles = new ArrayList<>();
private final ArrayList<File> mTempFiles = new ArrayList<>();

private FragmentManager mFragmentManagerSave; // used to deal with lifecycle issue

private PDFViewCtrlConfig mPDFViewCtrlConfig;
private ToolManagerBuilder mToolManagerBuilder;
private ViewerConfig.Builder mBuilder;

private ArrayList<ToolManager.ToolMode> mDisabledTools = new ArrayList<>();
private ArrayList<ToolbarButtonType> mDisabledButtonTypes = new ArrayList<>(); // used to disabled button types that are with specific a with explicit tool type (e.g. checkmark, dot, cross stamps)
private final ArrayList<ToolManager.ToolMode> mDisabledTools = new ArrayList<>();
private final ArrayList<ToolbarButtonType> mDisabledButtonTypes = new ArrayList<>(); // used to disabled button types that are with specific a with explicit tool type (e.g. checkmark, dot, cross stamps)

private String mExportPath;
private String mOpenUrlPath;
Expand Down Expand Up @@ -2347,14 +2347,12 @@ protected void onDetachedFromWindow() {

getViewTreeObserver().removeOnGlobalLayoutListener(mOnGlobalLayoutListener);

if (mTempFiles != null) {
for (File file : mTempFiles) {
if (file != null && file.exists()) {
file.delete();
}
for (File file : mTempFiles) {
if (file != null && file.exists()) {
file.delete();
}
mTempFiles = null;
}
mTempFiles.clear();
}

public void onActivityResult(int requestCode, int resultCode, Intent data) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-native-pdftron",
"title": "React Native Pdftron",
"version": "3.0.4-14",
"version": "3.0.4-15",
"description": "React Native Pdftron",
"main": "./lib/index.js",
"typings": "index.ts",
Expand Down