Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@scottdweber
scottdweber / HighQualityImageLoader.java
Last active August 29, 2015 13:57
Modification of ImageLoader from Volley so that it is easy to provide custom ImageRequest implementations. View Revisions to see the changes made to ImageLoader.java.
package com.example.volley;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import com.android.volley.RequestQueue;
import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;
import com.android.volley.toolbox.ImageCache;
import com.android.volley.toolbox.ImageLoader;
@scottdweber
scottdweber / percentToHex.sh
Created March 11, 2015 13:49
Quick script to convert a percentage for an alpha or color channel into its corresponding hex value.
#!/bin/bash
# Usage: ./percentToHex <percentValue>
# Examples:
# ./percentToHex 97.5
# ./percentToHex 78
num="$1 * .01000 * 255" # note: extra zeros for better precision
num=`echo "$num" | bc`
num=`echo "$num" | python -c "print(\"{:.0f}\".format(round(float(raw_input()))))"`
echo "obase=16; $num" | bc
@scottdweber
scottdweber / DoubleMeasureRelativeLayout.java
Created July 20, 2013 21:50
An extended RelativeLayout that fixes layout issues when the size of the layout is inexact (that is, wrap_content) and you want to base the positioning of one or more child views on the positioning of another child view that is itself positioned by layout_centerInParent, layout_centerHorizontal or layout_centerVertical. It is clearly not efficie…
/*
* Copyright (C) 2013 Scott Weber
*
* 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
@scottdweber
scottdweber / ExpandingCircleAnimationDrawable.java
Created March 22, 2013 02:14
An example showing how to create and use a Drawable that animates.
package com.example.manualanimation;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.view.animation.AnimationUtils;