Skip to content

Instantly share code, notes, and snippets.

Rainer-Lang /
Created July 19, 2017 14:33 — forked from xingrz/
An ImageView that always square, matching parent's width
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;
public class SquareImageView extends ImageView {
public SquareImageView(Context context) {
Rainer-Lang /
Created June 11, 2017 08:25 — forked from TWiStErRob/
Full POC for showing progress of loading in Glide v3 via OkHttp v2
// TODO add <meta-data android:value="GlideModule" android:name="....OkHttpProgressGlideModule" />
// TODO add <meta-data android:value="GlideModule" tools:node="remove" android:name="com.bumptech.glide.integration.okhttp.OkHttpGlideModule" />
// or not use 'okhttp@aar' in Gradle depdendencies
public class OkHttpProgressGlideModule implements GlideModule {
@Override public void applyOptions(Context context, GlideBuilder builder) { }
@Override public void registerComponents(Context context, Glide glide) {
OkHttpClient client = new OkHttpClient();
client.networkInterceptors().add(createInterceptor(new DispatchingProgressListener()));
glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(client));
Rainer-Lang /
Created May 1, 2017 09:44 — forked from swankjesse/
This OkHttp application interceptor will replace the destination hostname in the request URL.
import okhttp3.HttpUrl;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
/** An interceptor that allows runtime changes to the URL hostname. */
public final class HostSelectionInterceptor implements Interceptor {
private volatile String host;
import java.util.Queue;
import java.util.concurrent.atomic.*;
import rx.*;
import rx.Observable.Operator;
import rx.exceptions.MissingBackpressureException;
import rx.internal.operators.*;
import rx.internal.util.*;
import rx.internal.util.atomic.SpscAtomicArrayQueue;
Rainer-Lang /
Created December 21, 2016 13:06 — forked from agnoster/
My ZSH Theme


A ZSH theme optimized for people who use:

  • Solarized
  • Git
  • Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)

For Mac users, I highly recommend iTerm 2 + Solarized Dark

Rainer-Lang / permissions.txt
Created October 9, 2016 16:31 — forked from Arinerron/permissions.txt
A list of all Android permissions...
Rainer-Lang / colors_material.xml
Created January 23, 2016 10:49
Material Design Colors ( Resources )
<?xml version="1.0" encoding="utf-8"?>
<!-- Material Design Colors -->
<color name="md_red_50">#ffffebee</color>
<color name="md_red_100">#ffffcdd2</color>
<color name="md_red_200">#ffef9a9a</color>
<color name="md_red_300">#ffe57373</color>
<color name="md_red_400">#ffef5350</color>
Rainer-Lang /
Created September 29, 2015 14:46 — forked from 1zaman/
Loader for Retrofit 2.0 API. This uses the framework implementation, but it can be adapted to use the support library implementation without much modification.
package com.example.retrofit.loader;
import retrofit.Response;
* A wrapper around the Retrofit {@link Response} that will
* throw any loading errors upon retrieval.
* @param <T> The data type that was loaded.
Rainer-Lang /
Last active August 29, 2015 14:27 — forked from TheReprator/
A simple line through text view. ie. ----------------- Hello, World --------------
package views;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Build;
import android.text.TextUtils;
Rainer-Lang / methodcount.bat
Last active August 29, 2015 14:26 — forked from mrsasha/methodcount.bat
.jar and .dex method count helpers for Windows. dx from build-tools in the Android SDK has to be in your PATH. Just call methodcount.bat "filename"
IF "%1"=="" GOTO MissingFileNameError
IF EXIST "%1" (GOTO ContinueProcessing) ELSE (GOTO FileDoesntExist)
set FileNameToProcess=%1
set FileNameForDx=%~n1.dex
IF "%~x1"==".dex" GOTO ProcessWithPowerShell
REM preprocess Jar with dx