*Dao.kt: change some usages of getString()

Before this change, the getString() method in DatabaseUtils.kt was changed
to allow returning a null value upon method failure. All usages of getString()
were not changed.

This change updates all usages of getString() which require non null return
values. If null is returned, an empty string is used instead.
This commit is contained in:
Jason Whitmore 2025-10-08 20:26:52 -07:00
parent bf36dcb648
commit 5d128d0934
3 changed files with 29 additions and 8 deletions

View file

@ -144,8 +144,18 @@ class BookmarkItemsDao @Inject constructor(
*/ */
@SuppressLint("Range") @SuppressLint("Range")
fun fromCursor(cursor: Cursor) = with(cursor) { fun fromCursor(cursor: Cursor) = with(cursor) {
var name = getString(COLUMN_NAME)
if (name == null) {
name = ""
}
var id = getString(COLUMN_ID)
if (id == null) {
id = ""
}
DepictedItem( DepictedItem(
getString(COLUMN_NAME), name,
getString(COLUMN_DESCRIPTION), getString(COLUMN_DESCRIPTION),
getString(COLUMN_IMAGE), getString(COLUMN_IMAGE),
getStringArray(COLUMN_INSTANCE_LIST), getStringArray(COLUMN_INSTANCE_LIST),
@ -155,7 +165,7 @@ class BookmarkItemsDao @Inject constructor(
getStringArray(COLUMN_CATEGORIES_THUMBNAIL_LIST) getStringArray(COLUMN_CATEGORIES_THUMBNAIL_LIST)
), ),
getString(COLUMN_IS_SELECTED).toBoolean(), getString(COLUMN_IS_SELECTED).toBoolean(),
getString(COLUMN_ID) id
) )
} }

View file

@ -128,7 +128,10 @@ class BookmarkPicturesDao @Inject constructor(
} }
fun fromCursor(cursor: Cursor): Bookmark { fun fromCursor(cursor: Cursor): Bookmark {
val fileName = cursor.getString(COLUMN_MEDIA_NAME) var fileName = cursor.getString(COLUMN_MEDIA_NAME)
if (fileName == null) {
fileName = ""
}
return Bookmark( return Bookmark(
fileName, cursor.getString(COLUMN_CREATOR), uriForName(fileName) fileName, cursor.getString(COLUMN_CREATOR), uriForName(fileName)
) )

View file

@ -163,11 +163,19 @@ class RecentSearchesDao @Inject constructor(
* @param cursor * @param cursor
* @return RecentSearch object * @return RecentSearch object
*/ */
fun fromCursor(cursor: Cursor): RecentSearch = RecentSearch( fun fromCursor(cursor: Cursor): RecentSearch {
uriForId(cursor.getInt(COLUMN_ID)), var query = cursor.getString(COLUMN_NAME)
cursor.getString(COLUMN_NAME),
Date(cursor.getLong(COLUMN_LAST_USED)) if (query == null) {
) query = ""
}
return RecentSearch(
uriForId(cursor.getInt(COLUMN_ID)),
query,
Date(cursor.getLong(COLUMN_LAST_USED))
)
}
/** /**
* This class contains the database table architechture for recent searches, * This class contains the database table architechture for recent searches,