From fe6171571f0a443f6bfb1c15520970b7e9bbc5f3 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Thu, 20 Apr 2017 15:34:36 +0200 Subject: [PATCH] prevent NPE if trying to store grid preference for favorites/shared --- .../owncloud/android/ui/fragment/OCFileListFragment.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java b/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java index cdb7406abb..f432dffeb7 100644 --- a/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -1199,9 +1199,12 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi GRID_IS_PREFERED_PREFERENCE, Context.MODE_PRIVATE ); - SharedPreferences.Editor editor = setting.edit(); - editor.putBoolean(String.valueOf(mFile.getFileId()), setGrid); - editor.apply(); + // can be in case of favorites, shared + if (mFile != null) { + SharedPreferences.Editor editor = setting.edit(); + editor.putBoolean(String.valueOf(mFile.getFileId()), setGrid); + editor.apply(); + } } private void unsetAllMenuItems(final boolean unsetDrawer) {