From 749fbe5eccb4407bf5ab7c648fc83a5c9e5afd37 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Thu, 13 Aug 2015 10:06:32 +0200 Subject: [PATCH] Pebble: fix crash with emply pbw cache --- .../gadgetbridge/activities/AppManagerActivity.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AppManagerActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AppManagerActivity.java index 6a53276a..25685417 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AppManagerActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AppManagerActivity.java @@ -68,10 +68,12 @@ public class AppManagerActivity extends Activity { try { File cachePath = new File(FileUtils.getExternalFilesDir().getPath() + "/pbw-cache"); File files[] = cachePath.listFiles(); - for (File file : files) { - if (file.getName().endsWith(".pbw")) { - UUID uuid = UUID.fromString(file.getName().substring(0, file.getName().length() - 4)); - cachedAppList.add(new GBDeviceApp(uuid, uuid.toString(), "N/A", "", GBDeviceApp.Type.UNKNOWN)); + if (files != null) { + for (File file : files) { + if (file.getName().endsWith(".pbw")) { + UUID uuid = UUID.fromString(file.getName().substring(0, file.getName().length() - 4)); + cachedAppList.add(new GBDeviceApp(uuid, uuid.toString(), "N/A", "", GBDeviceApp.Type.UNKNOWN)); + } } } } catch (IOException e) { @@ -102,7 +104,7 @@ public class AppManagerActivity extends Activity { }); registerForContextMenu(appListView); - + SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(GBApplication.getContext()); if (sharedPrefs.getBoolean("pebble_force_untested", false)) {