package com.raizlabs.widget;

import android.content.res.Resources;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.View;

public class ViewUtils {

	/**
	 * Converts the given value in density-independent pixels into raw pixels
	 * with respect to the metrics of the given {@link View}
	 * @param dips The value in density-independent pixels
	 * @param view The {@link View} whose metrics to use to do the conversion
	 * @return The value in raw pixels
	 */
	public static float dipsToPixels(float dips, View view) {
		return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 
				dips, view.getResources().getDisplayMetrics());
	}
	
	/**
	 * Converts the given value in density-independent pixels into raw pixels
	 * with respect to the metrics of the given {@link Resources}
	 * @param dips The value in density-independent pixels
	 * @param resources The {@link Resources} whose metrics to use to do the
	 * conversion
	 * @return The value in raw pixels
	 */
	public static float dipsToPixels(float dips, Resources resources) {
		return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 
				dips, resources.getDisplayMetrics()); 
	}
	
	/**
	 * Converts the given value in density-independent pixels into raw pixels
	 * with respect to the given {@link DisplayMetrics}
	 * @param dips The value in density-independent pixels
	 * @param metrics The {@link DisplayMetrics} to use to do the conversion
	 * @return The value in raw pixels
	 */
	public static float dipsToPixels(float dips, DisplayMetrics metrics) {
		return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
				dips, metrics);
	}
}

@@ -61,16 +61,47 @@
 ources;%0A
+import android.text.TextUtils;%0A
 import a
@@ -190,33 +190,700 @@
 ew;%0A
-%0Apublic class ViewUtils %7B
+import android.widget.TextView;%0A%0Apublic class ViewUtils %7B%0A%09%0A%09/**%0A%09 * Returns the text for a given %7B@link textView%7D or else null if%0A%09 * the textView is null or has no text within.%0A%09 * @param textView The textView whose text should be returned%0A%09 * @return the text within the textView or null%0A%09 */%0A%09public static CharSequence getTextOrNull(TextView textView) %7B%0A%09%09if (textView == null) return null;%0A%09%09%0A%09    CharSequence text = textView.getText();%0A%09    return !TextUtils.isEmpty(text) ? text : null;%0A%09%7D%0A%09%0A%09/**%0A%09 * Overload for #getTextOrNull(TextView) which returns a %7B@link String%7D%0A%09 */%0A%09public static String getStringTextOrNull(TextView textView) %7B%0A%09%09return (String) getTextOrNull(textView);%0A%09%7D
 %0A%0A%09/

Add utility to get the text within a textView or return null if there is no text