Skip to content

Instantly share code, notes, and snippets.

@scottdweber
scottdweber / percentToHex.sh
Created Mar 11, 2015
Quick script to convert a percentage for an alpha or color channel into its corresponding hex value.
View percentToHex.sh
#!/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 / HighQualityImageLoader.java
Last active Aug 29, 2015
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.
View HighQualityImageLoader.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 / DoubleMeasureRelativeLayout.java
Created Jul 20, 2013
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…
View DoubleMeasureRelativeLayout.java
/*
* 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 Mar 22, 2013
An example showing how to create and use a Drawable that animates.
View ExpandingCircleAnimationDrawable.java
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;
You can’t perform that action at this time.