mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-28 21:33:53 +01:00
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:
parent
869371b485
commit
8de57304bf
44 changed files with 1738 additions and 1988 deletions
32
app/src/main/java/fr/free/nrw/commons/utils/DatabaseUtils.kt
Normal file
32
app/src/main/java/fr/free/nrw/commons/utils/DatabaseUtils.kt
Normal 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(",")
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue