From 87c2e44ab8c6d40d4b98e0fcf9fefa4ee6956bc3 Mon Sep 17 00:00:00 2001 From: tzugen Date: Wed, 13 Oct 2021 08:42:09 +0200 Subject: [PATCH] Fix NPE --- .../java/org/moire/ultrasonic/util/PermissionUtil.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ultrasonic/src/main/java/org/moire/ultrasonic/util/PermissionUtil.java b/ultrasonic/src/main/java/org/moire/ultrasonic/util/PermissionUtil.java index 8ac36b07..cbf82fa7 100644 --- a/ultrasonic/src/main/java/org/moire/ultrasonic/util/PermissionUtil.java +++ b/ultrasonic/src/main/java/org/moire/ultrasonic/util/PermissionUtil.java @@ -7,8 +7,8 @@ import android.content.Intent; import android.net.Uri; import android.os.Handler; import android.os.Looper; -import timber.log.Timber; +import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; import androidx.core.content.PermissionChecker; @@ -24,6 +24,8 @@ import org.moire.ultrasonic.R; import java.util.List; +import timber.log.Timber; + import static androidx.core.content.PermissionChecker.PERMISSION_DENIED; @@ -59,7 +61,7 @@ public class PermissionUtil { * * @param callback callback function to execute after the permission request is finished */ - public void handlePermissionFailed(final PermissionRequestFinishedCallback callback) { + public void handlePermissionFailed(@Nullable final PermissionRequestFinishedCallback callback) { String currentCachePath = Settings.getPreferences().getString(Constants.PREFERENCES_KEY_CACHE_LOCATION, FileUtil.getDefaultMusicDirectory().getPath()); String defaultCachePath = FileUtil.getDefaultMusicDirectory().getPath(); @@ -84,7 +86,9 @@ public class PermissionUtil { } }); } - callback.onPermissionRequestFinished(false); + if (callback != null) { + callback.onPermissionRequestFinished(false); + } } }