Skip to content

Instantly share code, notes, and snippets.

Osman Saral osrl

Block or report user

Report or block osrl

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View TextViewExtensions.kt
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
View LaunchActivity.kt
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
PaymentConfiguration.init("my_key")
CustomerSession.initCustomerSession(MyEphemeralKeyProvider())
...
}
@osrl
osrl / Call.kt
Last active Sep 26, 2019
A Kotlin extension function to Retrofit Call class
View Call.kt
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())
}
})
You can’t perform that action at this time.