From fa3898f8f44d0967dae26230a8f3ea4082628cac Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Wed, 5 Nov 2014 19:11:34 +0200 Subject: [PATCH] Fixed crash in FolderObserver if folder can't be accessed (fixes #180). --- .../nutomic/syncthingandroid/util/FolderObserver.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/nutomic/syncthingandroid/util/FolderObserver.java b/src/main/java/com/nutomic/syncthingandroid/util/FolderObserver.java index 130bfe8c..6cb65550 100644 --- a/src/main/java/com/nutomic/syncthingandroid/util/FolderObserver.java +++ b/src/main/java/com/nutomic/syncthingandroid/util/FolderObserver.java @@ -22,7 +22,7 @@ public class FolderObserver extends FileObserver { private final String mPath; - private final ArrayList mChilds; + private final ArrayList mChilds = new ArrayList<>(); public interface OnFolderFileChangeListener { public void onFolderFileChange(String folderId, String relativePath); @@ -74,9 +74,10 @@ public class FolderObserver extends FileObserver { } }); - mChilds = new ArrayList<>(); - for (File f : directories) { - mChilds.add(new FolderObserver(mListener, mFolder, path + "/" + f.getName())); + if (directories != null) { + for (File f : directories) { + mChilds.add(new FolderObserver(mListener, mFolder, path + "/" + f.getName())); + } } }