Skip to content

Instantly share code, notes, and snippets.

Transition
.to(WaitingPaymentProvider())
.withSideEffect(EmitCommand(PaymentProvider.CreateOutgoingSCT(...)))
interface State {
fun onInput(input: Input, entity: Entity): Transition?
}
@JoanZapata
JoanZapata / MapsUtils.java
Created February 5, 2015 18:59
Util for using MapView instead of MapFragment and still avoid boilerplate code to delegate all the activity lifecycle (onCreate, onResume, onPause, onDestroy, etc...) to the MapView.
import android.app.Activity;
import android.app.Application;
import android.os.Bundle;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.MapsInitializer;
import static java.lang.String.format;
public class MapsUtils {
@JoanZapata
JoanZapata / Main.kt
Created February 1, 2015 18:44
Experimentation with Rx (2)
import rx.Observable
import java.io.File
import rx.schedulers.Schedulers
import java.util.concurrent.Executors
/** Make it true to show some logs during computation. */
val DEBUG = true
/** Basic data structure to add information to a file reference. */
data class FileInfo(val file: File, var bytes: Long = 0, var filesCount: Long = 1)
@JoanZapata
JoanZapata / Main.kt
Created February 1, 2015 12:31
Experimentation with Rx
import rx.Observable
import java.io.File
/** Basic data structure to add information to a file reference. */
data class FileInfo(val file: File, var bytes: Long = 0, var filesCount: Long = 1)
/** Main function. */
fun main(args: Array<String>) {
Observable.just(File("/Users/joan/Dropbox"))
.flatMap({ fileToFileInfo(it) })
@JoanZapata
JoanZapata / AutoPagerAdaptor.java
Last active August 29, 2015 14:13
Implementation of PagerAdapter that uses the children of a ViewPager as pages.
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
/**
* Implementation of PagerAdapter that uses
* the children of a ViewPager as pages.
*/
public class AutoPagerAdaptor extends PagerAdapter {
import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
public abstract class LocalService<T> extends Service {
@Override
public IBinder onBind(Intent intent) {
return new LocalServiceBinder();