mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 09:20:19 +01:00
Update website build to use PackageInstaller.
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Copyright 2023 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.signal.core.util
|
||||
|
||||
import android.app.DownloadManager
|
||||
import android.content.Context
|
||||
|
||||
fun Context.getDownloadManager(): DownloadManager {
|
||||
return this.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
|
||||
}
|
||||
@@ -181,6 +181,10 @@ inline fun Cursor.forEach(operation: (Cursor) -> Unit) {
|
||||
}
|
||||
}
|
||||
|
||||
fun Cursor.iterable(): Iterable<Cursor> {
|
||||
return CursorIterable(this)
|
||||
}
|
||||
|
||||
fun Boolean.toInt(): Int = if (this) 1 else 0
|
||||
|
||||
/**
|
||||
@@ -202,3 +206,23 @@ fun Cursor.rowToString(): String {
|
||||
|
||||
return builder.toString()
|
||||
}
|
||||
|
||||
private class CursorIterable(private val cursor: Cursor) : Iterable<Cursor> {
|
||||
override fun iterator(): Iterator<Cursor> {
|
||||
return CursorIterator(cursor)
|
||||
}
|
||||
}
|
||||
|
||||
private class CursorIterator(private val cursor: Cursor) : Iterator<Cursor> {
|
||||
override fun hasNext(): Boolean {
|
||||
return !cursor.isClosed && cursor.count > 0 && !cursor.isLast && !cursor.isAfterLast
|
||||
}
|
||||
|
||||
override fun next(): Cursor {
|
||||
return if (cursor.moveToNext()) {
|
||||
cursor
|
||||
} else {
|
||||
throw NoSuchElementException()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user