Skip to content

Commit c3d844a

Browse files
[Android] Fix NPE on mTempFiles (#702)
* Fix NPE on mTempFiles * update version * Updating package version --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 0ce2935 commit c3d844a

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

android/src/main/java/com/pdftron/reactnative/views/DocumentView.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,16 @@ public class DocumentView extends com.pdftron.pdf.controls.DocumentView2 {
131131
private String mBase64Extension = ".pdf";
132132
private String mDocumentExtension;
133133

134-
private ArrayList<File> mTempFiles = new ArrayList<>();
134+
private final ArrayList<File> mTempFiles = new ArrayList<>();
135135

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

138138
private PDFViewCtrlConfig mPDFViewCtrlConfig;
139139
private ToolManagerBuilder mToolManagerBuilder;
140140
private ViewerConfig.Builder mBuilder;
141141

142-
private ArrayList<ToolManager.ToolMode> mDisabledTools = new ArrayList<>();
143-
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)
142+
private final ArrayList<ToolManager.ToolMode> mDisabledTools = new ArrayList<>();
143+
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)
144144

145145
private String mExportPath;
146146
private String mOpenUrlPath;
@@ -2347,14 +2347,12 @@ protected void onDetachedFromWindow() {
23472347

23482348
getViewTreeObserver().removeOnGlobalLayoutListener(mOnGlobalLayoutListener);
23492349

2350-
if (mTempFiles != null) {
2351-
for (File file : mTempFiles) {
2352-
if (file != null && file.exists()) {
2353-
file.delete();
2354-
}
2350+
for (File file : mTempFiles) {
2351+
if (file != null && file.exists()) {
2352+
file.delete();
23552353
}
2356-
mTempFiles = null;
23572354
}
2355+
mTempFiles.clear();
23582356
}
23592357

23602358
public void onActivityResult(int requestCode, int resultCode, Intent data) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-native-pdftron",
33
"title": "React Native Pdftron",
4-
"version": "3.0.4-14",
4+
"version": "3.0.4-15",
55
"description": "React Native Pdftron",
66
"main": "./lib/index.js",
77
"typings": "index.ts",

0 commit comments

Comments
 (0)