Convert bookmarks package to kotlin (#6387)

* Convert BookmarkItemsController to kotlin

* Split BookmarkItemsDao apart and converted to Kotlin

* Convert and cleanup content providers

* Convert BookmarkItemsFragment to kotlin

* Convert BookmarkPicturesFragment to kotlin

* Convert BookmarkPicturesDao to kotlin and share some useful DB methods

* Convert BookmarkPicturesController to kotlin

* Convert BookmarkFragment to kotlin

* Convert BookmarksPagerAdapter to kotlin

* Convert BookmarkListRootFragment to kotlin
This commit is contained in:
Paul Hawke 2025-07-31 18:26:16 -05:00 committed by GitHub
parent 869371b485
commit 8de57304bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
44 changed files with 1738 additions and 1988 deletions

View file

@ -0,0 +1,32 @@
package fr.free.nrw.commons.utils
import android.annotation.SuppressLint
import android.database.Cursor
fun Cursor.getStringArray(name: String): List<String> =
stringToArray(getString(name))
@SuppressLint("Range")
fun Cursor.getString(name: String): String =
getString(getColumnIndex(name))
/**
* Converts string to List
* @param listString comma separated single string from of list items
* @return List of string
*/
fun stringToArray(listString: String?): List<String> {
if (listString.isNullOrEmpty()) return emptyList();
val elements = listString.split(",".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
return listOf(*elements)
}
/**
* Converts string to List
* @param list list of items
* @return string comma separated single string of items
*/
fun arrayToString(list: List<String?>?): String? {
return list?.joinToString(",")
}