mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 23:28:42 +03:00
codacy: Deeply nested if..then statements are hard to read
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
2dabd04aa9
commit
2ab45a72ac
1 changed files with 11 additions and 3 deletions
|
@ -119,7 +119,7 @@ public final class MediaProvider {
|
|||
MediaStore.MediaColumns.DATA));
|
||||
|
||||
// check if valid path and file exists
|
||||
if (filePath != null && filePath.lastIndexOf('/') > 0 && new File(filePath).exists()) {
|
||||
if (isValidAndExistingFilePath(filePath)) {
|
||||
mediaFolder.filePaths.add(filePath);
|
||||
mediaFolder.absolutePath = filePath.substring(0, filePath.lastIndexOf('/'));
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ public final class MediaProvider {
|
|||
cursorImages.close();
|
||||
|
||||
// only do further work if folder is not within the Nextcloud app itself
|
||||
if (mediaFolder.absolutePath != null && !mediaFolder.absolutePath.startsWith(dataPath)) {
|
||||
if (isFolderOutsideOfAppPath(dataPath, mediaFolder)) {
|
||||
|
||||
// count images
|
||||
Cursor count = contentResolver.query(
|
||||
|
@ -152,6 +152,14 @@ public final class MediaProvider {
|
|||
return mediaFolders;
|
||||
}
|
||||
|
||||
private static boolean isFolderOutsideOfAppPath(String dataPath, MediaFolder mediaFolder) {
|
||||
return mediaFolder.absolutePath != null && !mediaFolder.absolutePath.startsWith(dataPath);
|
||||
}
|
||||
|
||||
private static boolean isValidAndExistingFilePath(String filePath) {
|
||||
return filePath != null && filePath.lastIndexOf('/') > 0 && new File(filePath).exists();
|
||||
}
|
||||
|
||||
private static void checkPermissions(@Nullable Activity activity) {
|
||||
if (activity != null &&
|
||||
!PermissionUtil.checkSelfPermission(activity.getApplicationContext(),
|
||||
|
@ -229,7 +237,7 @@ public final class MediaProvider {
|
|||
cursorVideos.close();
|
||||
|
||||
// only do further work if folder is not within the Nextcloud app itself
|
||||
if (mediaFolder.absolutePath != null && !mediaFolder.absolutePath.startsWith(dataPath)) {
|
||||
if (isFolderOutsideOfAppPath(dataPath, mediaFolder)) {
|
||||
|
||||
// count images
|
||||
Cursor count = contentResolver.query(
|
||||
|
|
Loading…
Reference in a new issue