Skip to content

Instantly share code, notes, and snippets.

View lucamtudor's full-sized avatar

Tudor Luca lucamtudor

View GitHub Profile
@lucamtudor
lucamtudor / Config.java
Created July 2, 2013 10:19
Helper methods that make logging more consistent throughout the application.
public class Config {
public static final boolean DEBUG = true;
}
@lucamtudor
lucamtudor / ImageHelper.java
Created July 2, 2013 10:14
ImageHelper that has the following features: - getRoundedCornerBitmap() : Create a round shape cropped Bitmap from an existing Bitmap. - decodeUri() : Obtains an image at a specified Uri.
/**
* @author Tudor Luca
*/
public class ImageHelper {
public static class Options {
/**
* If not set, the source Bitmap width will be used.
*/
@lucamtudor
lucamtudor / AndroidManifest.xml
Created July 2, 2013 10:00
Method to check if the Android device is connected to the Internet.
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
@lucamtudor
lucamtudor / Example.java
Created September 18, 2014 12:33
An array adapter that uses the last item as a hint. Use with a spinner
String[] strings = getResources().getStringArray(R.array.spinner_options);
HintAdapter<String> hintAdapter = new HintAdapter<String>(this, android.R.layout.simple_spinner_item, strings);
hintAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mSpinner.setAdapter(hintAdapter);
mSpinner.setSelection(hintAdapter.getCount());
@lucamtudor
lucamtudor / colors.xml
Last active August 29, 2015 14:17 — forked from mpost/colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="action_pause">#FF8F00</color>
<color name="action_resume">#43A047</color>
</resources>
public class ColorUtils {
private static final double LM_RED_COEFFICIENT = 0.2126;
private static final double LM_GREEN_COEFFICIENT = 0.7152;
private static final double LM_BLUE_COEFFICIENT = 0.0722;
public static int calculateRelativeLuminance(int color) {
int red = (int) (Color.red(color) * LM_RED_COEFFICIENT);
int green = (int) (Color.green(color) * LM_GREEN_COEFFICIENT);
int blue = (int) (Color.blue(color) * LM_BLUE_COEFFICIENT);
return red + green + blue;