mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-09 16:11:20 +02:00
Basics for user prefs, logging in, etc
This commit is contained in:
parent
763521aabf
commit
76d78246db
15 changed files with 613 additions and 35 deletions
|
|
@ -0,0 +1,27 @@
|
|||
package com.github.damontecres.dolphin.preferences
|
||||
|
||||
import androidx.datastore.core.CorruptionException
|
||||
import androidx.datastore.core.Serializer
|
||||
import com.google.protobuf.InvalidProtocolBufferException
|
||||
import java.io.InputStream
|
||||
import java.io.OutputStream
|
||||
import javax.inject.Inject
|
||||
|
||||
class UserPreferencesSerializer
|
||||
@Inject
|
||||
constructor() : Serializer<UserPreferences> {
|
||||
override val defaultValue: UserPreferences = UserPreferences.getDefaultInstance()
|
||||
|
||||
override suspend fun readFrom(input: InputStream): UserPreferences {
|
||||
try {
|
||||
return UserPreferences.parseFrom(input)
|
||||
} catch (exception: InvalidProtocolBufferException) {
|
||||
throw CorruptionException("Cannot read proto.", exception)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun writeTo(
|
||||
t: UserPreferences,
|
||||
output: OutputStream,
|
||||
) = t.writeTo(output)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue