Skip to content

Instantly share code, notes, and snippets.

@digitalbuddha
digitalbuddha / Dagger 2.md
Created February 29, 2016 20:02 — forked from lenguyenthanh/ Dagger 2.md
Dagger 2 configuration

Small gist show how to config Dagger 2 to an Android project

protected void clickButton(int id) {
onView(withId(id)).perform(click());
}
protected void clickOKButton() {
onView(withId(R.id.yes)).perform(click());
}
protected void clickYesButton() {
onView(withText("Yes")).perform(click());
package com.fresconews.fresco.framework.databinding.bindingAdapters;
import android.content.SharedPreferences;
import android.databinding.BindingAdapter;
import android.graphics.SurfaceTexture;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.preference.PreferenceManager;
import android.view.Surface;
import android.view.TextureView;
@Value.Immutable
@Value.Style(allParameters = true)
public abstract class Foo implements FooModel{
public static final FooModel.Mapper<Foo> MAPPER = new FooModel.Mapper<>((Mapper.Creator<Foo>) ImmutableFoo::of);
public static final class Marshal extends FooModel.FooMarshal {}
}
@digitalbuddha
digitalbuddha / MirroredSource.java
Last active August 29, 2016 14:22 — forked from RoryKelly/MirroredSource.java
Mirrored Source for OKIO.
import java.io.IOException;
import java.util.concurrent.atomic.AtomicBoolean;
import okio.Buffer;
import okio.Source;
import okio.Timeout;
import timber.log.Timber;
public class MirroredSource {
private final Buffer buffer = new Buffer();
@digitalbuddha
digitalbuddha / StoreReadme.md
Last active October 3, 2016 15:30
In Progress readme for new store Lib

Store

A Store is responsible for managing a particular data request in your application. When you create a Store, you provide it with an implementation of a Fetcher class which defines how it will fetch new data. You can also define how your Store will save data in-memory and on-disk as well as how to parse it. Once you’ve defined how your Store will handles these actions, Store handles the logic around data flow, allowing your views to show the best data source and ensuring that the newest data is always available for later offline use. Stores can both be used with logical defaults or are fully customizable to work with SqlLite, and your favorite networking libraries

Store’s leverage RxJava and intelligent in-flight logic to prevent excessive calls to the network and disk cache. By wrapping your data calls in Store’s, you eliminate the possibility of flooding your network with the same request while adding 2 layers of caching (memory + disk)

Creating a Store

The simplest way to make a Store is wi

@digitalbuddha
digitalbuddha / RxIdlingResource.java
Created November 17, 2016 20:05 — forked from aahlenst/RxIdlingResource.java
IdlingResource that makes Espresso 2 wait until all RxJava 2 tasks have finished
/*
* The MIT License
*
* Copyright (c) 2016 Andreas Ahlenstorf
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@digitalbuddha
digitalbuddha / RxIdlingResource.java
Created November 17, 2016 20:05 — forked from aahlenst/RxIdlingResource.java
IdlingResource that makes Espresso 2 wait until all RxJava 2 tasks have finished
/*
* The MIT License
*
* Copyright (c) 2016 Andreas Ahlenstorf
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
//Create a Model that represents your JSON data (It’s ok if fields are missing that are present in JSON)
public class User {
public String avatar_url;
public String login;
}
//Create an interface
public interface Github {
@GET(“/search/users”) UserResponse users(@Query(“q”) String name);
}
Store<Article> ArticleStore = StoreBuilder.<Article>builder()
.fetcher(barCode -> retrofitApi.getArticleObservable(barcode.getValue()))
.open();