Skip to content

Instantly share code, notes, and snippets.

import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.PorterDuff;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.ProgressBar;
public class TintedProgressBar extends ProgressBar {
import java.util.Collection;
/**
* @author Eric Cochran
*/
public class ArrayListBest<T> {
private static final int DEFAULT_CAPACITY = 10;
private final int initialCapacity;
private T[] arr;
@NightlyNexus
NightlyNexus / ItemTypeAdapterFactory.java
Created June 16, 2015 19:25
Remove those pesky "status" objects in your JSON payload with Gson. Usage: new GsonConverter(new GsonBuilder().registerTypeAdapterFactory(new ItemTypeAdapterFactory())create());
public static class ItemTypeAdapterFactory implements TypeAdapterFactory {
final static String KEY_TO_REMOVE = "status";
@Override
public <T> TypeAdapter<T> create(Gson gson, final TypeToken<T> type) {
final TypeAdapter<T> delegate = gson.getDelegateAdapter(this, type);
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
import android.content.Context;
import android.content.Intent;
import android.support.annotation.StringDef;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
public final class DemoModeHelper {
public static void enter(Context context) {
new Enter(context).send();
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
public final class GridViewPager extends android.support.wearable.view.GridViewPager {
private WindowInsets insets = null;
@NightlyNexus
NightlyNexus / OkHttpStack.java
Created May 13, 2016 21:27
OkHttp 3 implementation of Volley's HttpStack
/*
* Copyright (C) 2016 Eric Cochran
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright (C) 2016 Eric Cochran
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@NightlyNexus
NightlyNexus / FlagView.java
Created August 28, 2016 06:51
A quickly made Android View to show an American flag.
/*
* Copyright (C) 2016 Eric Cochran
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
final class GuessGame {
public static void main(String[] args) {
GuessGame game = new GuessGame(new SimpleGame(13, 0, 100));
System.out.println(game.play());
}
private static final class SimpleGame implements GameSetup {
private final int known;
private final int lowerBound;
private final int upperBound;
/*
* Copyright (C) 2016 Eric Cochran
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software