Skip to content

Instantly share code, notes, and snippets.

@JoanZapata
JoanZapata / MapsUtils.java
Created Feb 5, 2015
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.
View MapsUtils.java
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 Feb 1, 2015
Experimentation with Rx (2)
View Main.kt
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 Feb 1, 2015
Experimentation with Rx
View Main.kt
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 Aug 29, 2015
Implementation of PagerAdapter that uses the children of a ViewPager as pages.
View AutoPagerAdaptor.java
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 {
View LocalService.java
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();