This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun TextView.applySpanAnnotations() { | |
val annotations = (text as? SpannedString) | |
?.getSpans(0, text.length, Annotation::class.java) ?: return | |
text = SpannableString(text) | |
.apply { | |
loop@ for (annotation in annotations) { | |
when(annotation.key) { | |
"font" -> { | |
val fontName = annotation.value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
PaymentConfiguration.init("my_key") | |
CustomerSession.initCustomerSession(MyEphemeralKeyProvider()) | |
... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline fun <T> Call<T>.enqueue(crossinline onResult: Result<T>.() -> Unit) { | |
enqueue(object : Callback<T> { | |
override fun onFailure(call: Call<T>?, t: Throwable?) { | |
onResult(Result.Error(ApiError("Network error"))) | |
} | |
override fun onResponse(call: Call<T>?, response: Response<T>) { | |
onResult(response.result()) | |
} | |
}) |