Skip to content

Instantly share code, notes, and snippets.

View VallaDanger's full-sized avatar
🎯
Focusing

chux VallaDanger

🎯
Focusing
View GitHub Profile
@VallaDanger
VallaDanger / ImmutableListDeserializer.java
Last active April 21, 2016 04:31
GSON JsonArray to Guava ImmutableList
public static void main(String[] args) {
Type type = getCollectionType(ImmutableList.class, Number.class);
Gson gson = new GsonBuilder().registerTypeAdapter(type, new ImmutableList_TypeAdapter<Number>()).create();
ImmutableList<Number> list = gson.fromJson("[1,2,3]", type);
ListVO vo = gson.fromJson("{\"numbers\":[1,2,3]}", ListVO.class);
}
private static class ListVO {
@Expose @SerializedName("numbers")
ImmutableList<Number> numbers;
@sierisimo
sierisimo / HeaderAdapter.java
Last active April 21, 2016 04:35 — forked from ec84b4/gist:d56c00fb5fd2dfaf279b
Adapater for RecyclerView with headers between items
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
/**
* Created by khaled bakhtiari on 10/26/2014.
* <a href="http://about.me/kh.bakhtiari">
*/