mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-24 11:52:13 +00:00
Update: Release converters
This commit is contained in:
parent
05567cdedc
commit
af611cb49a
@ -1,6 +1,7 @@
|
||||
package com.looker.droidify.database
|
||||
|
||||
import androidx.room.TypeConverter
|
||||
import com.looker.droidify.entity.Release
|
||||
import com.looker.droidify.utility.jsonGenerate
|
||||
import com.looker.droidify.utility.jsonParse
|
||||
|
||||
@ -25,4 +26,17 @@ object Converters {
|
||||
@TypeConverter
|
||||
@JvmStatic
|
||||
fun toByteArray(product: com.looker.droidify.entity.Product) = jsonGenerate(product::serialize)
|
||||
|
||||
@TypeConverter
|
||||
@JvmStatic
|
||||
fun toReleases(byteArray: ByteArray): List<Release> {
|
||||
val string = byteArray.toString()
|
||||
return if (string == "") emptyList()
|
||||
else string.split(",").map { byteArray.jsonParse { Release.deserialize(it) } }
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
@JvmStatic
|
||||
fun toByteArray(releases: List<Release>) =
|
||||
jsonGenerate { releases.forEach { item -> item.serialize(it) }.toString().toByteArray() }
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user