Skip to content

Instantly share code, notes, and snippets.

init {
lifecycleBind {
Event.START with { }
Event.RESUME with { }
Event.PAUSE with { }
Event.STOP with { }
}
.bindUntilEvent(this, ActivityEvent.DESTROY)
.subscribe()
}
internal class LifecycleBinding<T>(val event: Event<T>, val observer: (Any) -> Unit)
class LifecycleBinder {
internal val actions: MutableList<LifecycleBinding<*>> = mutableListOf()
/**
* Bind [Activity] or [Fragment] lifecycle events with custom actions
*/
infix fun <T : Any> Event<T>.with(observer: (t: T) -> Unit) {
actions.add(LifecycleBinding(this@with, {
@georgeci
georgeci / LSpiceManager.java
Last active August 29, 2015 14:25
Extension of SpiceManager could get Lambdas
package com.georgeci.utils;
import com.octo.android.robospice.SpiceManager;
import com.octo.android.robospice.SpiceService;
import com.octo.android.robospice.persistence.exception.SpiceException;
import com.octo.android.robospice.request.SpiceRequest;
import com.octo.android.robospice.request.listener.RequestListener;
public class LSpiceManager extends SpiceManager {