Skip to content

Instantly share code, notes, and snippets.

View marcelpallares's full-sized avatar

Marcel marcelpallares

View GitHub Profile
@marcelpallares
marcelpallares / AuthCredentialsManager.kt
Last active March 21, 2022 22:26
Emitting and collecting on a SharedFlow to answer on a Reddit thread: https://www.reddit.com/r/androiddev/comments/tirxqq/help_with_auth0/
// Add into class AuthCredentialsManager
private val mutableCredentialsFlow = MutableSharedFlow<Credentials>()
val credentialsFlow = mutableCredentialsFlow.asSharedFlow()
suspend fun emitCredentials(credentials: Credentials) {
mutableCredentialsFlow.emit(credentials)
}
fun getCredentials() {
manager.getCredentials(object : Callback<Credentials, CredentialsManagerException> {
@marcelpallares
marcelpallares / OrderedListTextView.kt
Last active December 8, 2021 12:12
Creates a custom TextView to display ordered lists in a straightforward way. This is a modified solution from https://stackoverflow.com/a/27541189 to account for custom fonts and line spacing extra.
import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.text.Layout
import android.text.SpannableStringBuilder
import android.text.style.LeadingMarginSpan
import android.util.AttributeSet
import android.widget.TextView
import androidx.appcompat.widget.AppCompatTextView