summaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2017-11-01 14:26:45 +0100
committercyBerta <cyberta@riseup.net>2017-11-01 14:26:45 +0100
commit957fd3d9928ed86cee22dd97f0ac56ef98eecd2b (patch)
treec4b1b3116a1be6f56ba2e3a3f347ca4a758bbad8 /app/src
parentdac004b0e2fcebe06f39b8d855d6cdae1c5764fa (diff)
fix instantiation of custom providers to avoid NPEs
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderManager.java9
1 files changed, 4 insertions, 5 deletions
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<Provider> {
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<Provider> {
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<Provider>();
}