mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-27 14:40:22 +00:00
Rewrite in-app-payment flows to prepare for backups support.
This commit is contained in:
committed by
Cody Henthorne
parent
b36b00a11c
commit
d719edf104
@@ -88,7 +88,7 @@ fun Cursor.readToSingleLong(defaultValue: Long = 0): Long {
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> Cursor.readToSingleObject(serializer: Serializer<T, Cursor>): T? {
|
||||
fun <T> Cursor.readToSingleObject(serializer: BaseSerializer<T, Cursor, *>): T? {
|
||||
return use {
|
||||
if (it.moveToFirst()) {
|
||||
serializer.deserialize(it)
|
||||
|
||||
@@ -1,12 +1,25 @@
|
||||
package org.signal.core.util
|
||||
|
||||
import android.content.ContentValues
|
||||
import android.database.Cursor
|
||||
|
||||
/**
|
||||
* Generalized serializer for finer control
|
||||
*/
|
||||
interface BaseSerializer<Data, Input, Output> {
|
||||
fun serialize(data: Data): Output
|
||||
fun deserialize(input: Input): Data
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic serialization interface for use with database and store operations.
|
||||
*/
|
||||
interface Serializer<T, R> {
|
||||
fun serialize(data: T): R
|
||||
fun deserialize(data: R): T
|
||||
}
|
||||
interface Serializer<T, R> : BaseSerializer<T, R, R>
|
||||
|
||||
/**
|
||||
* Serializer specifically for working with SQLite
|
||||
*/
|
||||
interface DatabaseSerializer<Data> : BaseSerializer<Data, Cursor, ContentValues>
|
||||
|
||||
interface StringSerializer<T> : Serializer<T, String>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user