I hereby claim:
- I am nhaarman on github.
- I am nhaarman (https://keybase.io/nhaarman) on keybase.
- I have a public key whose fingerprint is B50E 6209 DFFC 8D41 017D 7148 9AB1 2E03 91A2 FE24
To claim this, I am signing this object:
package com.nhaarman.test; | |
import android.animation.ObjectAnimator; | |
import android.animation.ValueAnimator; | |
import android.content.Context; | |
import android.graphics.Canvas; | |
import android.graphics.Color; | |
import android.graphics.Paint; | |
import android.graphics.Path; | |
import android.graphics.RadialGradient; |
I hereby claim:
To claim this, I am signing this object:
sealed class Distance : Comparable<Distance> { | |
data class DistanceMeters(val value: Float) : Distance() | |
data class DistanceFeet(val value: Float) : Distance() | |
fun toMeters() = when (this) { | |
is DistanceMeters -> this | |
is DistanceFeet -> DistanceMeters(value * .3048f) | |
} | |
fun toFeet() = when (this) { |
fun <T, R> Observable<Command<T>>.undoRedo(initialValue: R, accumulator: (R, T) -> R): Observable<R> { | |
return this | |
.scan(UndoRedoStack.create<T>()) { stack, command -> | |
when (command) { | |
is Command.Do -> stack.push(command.action) | |
is Command.Undo -> stack.undo() | |
is Command.Redo -> stack.redo() | |
} | |
} | |
.map { stack -> |
data class Device( | |
val name: String | |
) | |
interface DeviceScanner { | |
/** Emits a Device opon each new discovery event */ | |
fun devices() : Observable<Device> | |
} | |
class BluetoothDeviceScanner( |
interface Screen<V : Container> { | |
fun onStart() {} | |
fun attach(v: V) {} | |
fun detach(v: V) {} | |
fun onStop() {} | |
fun onDestroy() {} | |
interface SimpleContainer { | |
var text: String | |
} | |
class SimpleScreen( | |
val name: String | |
) : Screen<SimpleContainer> { | |
override fun attach(v: SimpleContainer) { | |
v.text = "Hello, $name!" |
class SelectPictureScreen( | |
private val listener: Events | |
) : Screen<SelectPictureContainer> { | |
override fun attach(c: SelectPictureContainer) { | |
c.setOnPictureClickListener { listener.onPictureSelected(it.id) } | |
} | |
interface Events { | |
fun onPictureSelected(id: Long) |