From bcd411d0c313716acbeda4449c5040260a3826b1 Mon Sep 17 00:00:00 2001 From: Ahmed El-Helw Date: Thu, 31 Dec 2020 12:35:04 +0400 Subject: [PATCH] Fix since getExternalFilesDirs may return null --- .../java/com/quran/labs/androidquran/QuranDataActivity.kt | 4 ++-- .../labs/androidquran/presenter/data/QuranDataPresenter.kt | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/quran/labs/androidquran/QuranDataActivity.kt b/app/src/main/java/com/quran/labs/androidquran/QuranDataActivity.kt index 5e73d6ae2f..f5eb3ead5f 100644 --- a/app/src/main/java/com/quran/labs/androidquran/QuranDataActivity.kt +++ b/app/src/main/java/com/quran/labs/androidquran/QuranDataActivity.kt @@ -174,8 +174,8 @@ class QuranDataActivity : Activity(), SimpleDownloadListener, OnRequestPermissio val fallbackFile = filesDir val usesInternalDir = path != null && path == fallbackFile.absolutePath val usesExternalFileDir = path != null && - ContextCompat.getExternalFilesDirs(this, null).any { - it.absolutePath == path + ContextCompat.getExternalFilesDirs(this, null).any { file: File? -> + file != null && file.absolutePath == path } if (path == null) { diff --git a/app/src/main/java/com/quran/labs/androidquran/presenter/data/QuranDataPresenter.kt b/app/src/main/java/com/quran/labs/androidquran/presenter/data/QuranDataPresenter.kt index 35f104f535..923fc2c660 100644 --- a/app/src/main/java/com/quran/labs/androidquran/presenter/data/QuranDataPresenter.kt +++ b/app/src/main/java/com/quran/labs/androidquran/presenter/data/QuranDataPresenter.kt @@ -17,7 +17,6 @@ import com.quran.data.source.PageProvider import com.quran.data.upgrade.LocalDataUpgrade import com.quran.labs.androidquran.QuranDataActivity import com.quran.labs.androidquran.data.Constants -import com.quran.labs.androidquran.data.QuranFileConstants import com.quran.labs.androidquran.presenter.Presenter import com.quran.labs.androidquran.util.QuranFileUtils import com.quran.labs.androidquran.util.QuranScreenInfo