Skip to content

Commit bb6349c

Browse files
committed
Analysis: Resolve variable initializer is redundant warning
Warning Message: "Variable 'cursor' initializer is redundant"
1 parent 53b180c commit bb6349c

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

WordPress/src/main/java/org/wordpress/android/ui/mediapicker/loader/DeviceMediaLoader.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package org.wordpress.android.ui.mediapicker.loader
22

33
import android.content.ContentResolver
44
import android.content.Context
5-
import android.database.Cursor
65
import android.net.Uri
76
import android.os.Build.VERSION
87
import android.os.Build.VERSION_CODES
@@ -42,7 +41,6 @@ class DeviceMediaLoader
4241
}
4342
val result = mutableListOf<DeviceMediaItem>()
4443
val projection = arrayOf(ID_COL, ID_DATE_MODIFIED, ID_TITLE)
45-
var cursor: Cursor? = null
4644
val dateCondition = if (limitDate != null && limitDate != 0L) {
4745
"$ID_DATE_MODIFIED <= \'$limitDate\'"
4846
} else {
@@ -55,11 +53,8 @@ class DeviceMediaLoader
5553
dateCondition ?: filterCondition
5654
}
5755

58-
cursor = getCursor(condition, pageSize, baseUri, projection)
56+
val cursor = getCursor(condition, pageSize, baseUri, projection) ?: return DeviceMediaList(listOf(), null)
5957

60-
if (cursor == null) {
61-
return DeviceMediaList(listOf(), null)
62-
}
6358
try {
6459
val idIndex = cursor.getColumnIndexOrThrow(ID_COL)
6560
val dateIndex = cursor.getColumnIndexOrThrow(ID_DATE_MODIFIED)

0 commit comments

Comments
 (0)