Skip to content

Instantly share code, notes, and snippets.

View zsmb13's full-sized avatar

Márton Braun zsmb13

View GitHub Profile
@zsmb13
zsmb13 / OnClickSpan.kt
Last active May 27, 2017 07:16
Some useful extension functions for Android development
import android.text.SpannableString
import android.text.Spanned
import android.text.method.LinkMovementMethod
import android.text.style.ClickableSpan
import android.view.View
import android.widget.TextView
/* Adds a [clickHandler] to the text starting at index [start] and ending at index [end] */
fun TextView.onClickSpan(start: Int, end: Int, clickHandler: () -> Unit) {
movementMethod = LinkMovementMethod.getInstance()
import android.support.annotation.NonNull;
import com.example.app.BuildConfig;
import okhttp3.Credentials;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;
public class BasicAuthInterceptor implements Interceptor {
@zsmb13
zsmb13 / DeferredCallAdapterFactory.kt
Created March 10, 2019 08:32
A variation of Jake Wharton's deferred call adapter that better supports `Unit` and `Void` return types
package co.zsmb.example
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.Deferred
import retrofit2.Call
import retrofit2.CallAdapter
import retrofit2.Callback
import retrofit2.HttpException
import retrofit2.Response
import retrofit2.Retrofit
@zsmb13
zsmb13 / doc_snippets.md
Last active September 21, 2020 14:57
Two documents for the new event API
@zsmb13
zsmb13 / publish-mavencentral.gradle
Last active April 21, 2021 07:25
Basic MavenCentral script
apply plugin: 'maven-publish'
apply plugin: 'signing'
task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
if (project.plugins.findPlugin("com.android.library")) {
from android.sourceSets.main.java.srcDirs
from android.sourceSets.main.kotlin.srcDirs
} else {
from sourceSets.main.java.srcDirs