Skip to content

Instantly share code, notes, and snippets.

Angelo Marchesin arcadefire

  • Uber
  • Germany
View GitHub Profile
@arcadefire
arcadefire / build-times-json-format.json
Created May 16, 2019
Build times plugin JSON format
View build-times-json-format.json
{
"success": true,
"count": 663,
"measurements": [
{
"timestamp": 1558000984082,
"order": 0,
"task": ":clean",
"success": true,
"did_work": true,
View ReactiveBusHandle.kt
bus.get().subscribe { handle(it) }
private fun handle(it: UserEvent) =
when (it) {
is ButtonPressed -> println("Button pressed at ${it.timestamp}")
is TypingStarted -> println("Typing started with text ${it.inputText}")
}
View UserEvents.kt
sealed class UserEvent()
class ButtonPressed(val timestamp: Long) : UserEvent()
class TypingStarted(val inputText: String) : UserEvent()
View ReactiveBus.kt
class ReactiveBus<T> {
private val bus: PublishSubject<T> = PublishSubject.create()
fun post(item: T) {
bus.onNext(item)
}
fun get() = bus
}
@arcadefire
arcadefire / RecyclerViewExtension.kt
Last active Feb 25, 2020
Add addOnItemClickListener easily to a RecyclerView using Kotlin
View RecyclerViewExtension.kt
import android.support.v7.widget.RecyclerView
import android.view.View
interface OnItemClickListener {
fun onItemClicked(position: Int, view: View)
}
fun RecyclerView.addOnItemClickListener(onClickListener: OnItemClickListener) {
this.addOnChildAttachStateChangeListener(object: RecyclerView.OnChildAttachStateChangeListener {
override fun onChildViewDetachedFromWindow(view: View?) {
You can’t perform that action at this time.