Skip to content

Instantly share code, notes, and snippets.

@rharter
rharter / RevealDrawable.java
Created April 3, 2015 17:41
A Drawable that transitions between two child Drawables based on this Drawable's current level value. The idea here is that the center value (5000) will show the 'selected' Drawable, and any other value will show a transitional value between the 'selected' Drawable and the 'unselected' Drawable.
package com.pixite.fragment.widget;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable.Callback;
import android.view.Gravity;
@Tylos
Tylos / Map Range
Last active August 29, 2015 14:17
Maps value which is in the range fromLow and fromHigh to it's corresponding value in the range toLow, toHigh
private float mapRange(float value, float fromLow, float fromHigh, float toLow, float toHigh) {
return toLow + (((value - fromLow) / (fromHigh - fromLow)) * (toHigh - toLow));
}
@imminent
imminent / AccountUtils.java
Created November 12, 2012 19:55
Utility to retrieve user profile on Android device
/**
* A collection of authentication and account connection utilities. With strong inspiration from the Google IO session
* app.
* @author Dandré Allison
*/
public class AccountUtils {
/**
* Interface for interacting with the result of {@link AccountUtils#getUserProfile}.
*/