From 957fd3d9928ed86cee22dd97f0ac56ef98eecd2b Mon Sep 17 00:00:00 2001 From: cyBerta Date: Wed, 1 Nov 2017 14:26:45 +0100 Subject: fix instantiation of custom providers to avoid NPEs --- app/src/main/java/se/leap/bitmaskclient/ProviderManager.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'app') diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderManager.java b/app/src/main/java/se/leap/bitmaskclient/ProviderManager.java index 13ef9b80..abbdeb66 100644 --- a/app/src/main/java/se/leap/bitmaskclient/ProviderManager.java +++ b/app/src/main/java/se/leap/bitmaskclient/ProviderManager.java @@ -26,16 +26,15 @@ public class ProviderManager implements AdapteeCollection { public static ProviderManager getInstance(AssetManager assets_manager, File external_files_dir) { if (instance == null) - instance = new ProviderManager(assets_manager); + instance = new ProviderManager(assets_manager, external_files_dir); - if(external_files_dir != null) - instance.addCustomProviders(external_files_dir); return instance; } - public ProviderManager(AssetManager assets_manager) { + public ProviderManager(AssetManager assets_manager, File external_files_dir) { this.assets_manager = assets_manager; addDefaultProviders(assets_manager); + addCustomProviders(external_files_dir); } private void addDefaultProviders(AssetManager assets_manager) { @@ -67,7 +66,7 @@ public class ProviderManager implements AdapteeCollection { private void addCustomProviders(File external_files_dir) { this.external_files_dir = external_files_dir; - custom_providers = external_files_dir.isDirectory() ? + custom_providers = external_files_dir != null && external_files_dir.isDirectory() ? providersFromFiles(external_files_dir.list()) : new HashSet(); } -- cgit v1.2.3