package org.sfx.catholicjourney.core.utils;

import android.content.res.ColorStateList;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

/**
 * Created by simonadmin on 2015-03-18.
 */
public class TextUtility {

	/**
	 * Set the TextView text. If text is null/empty, hide textview.
	 *
	 * @param tv   TextView to set text in
	 * @param text
	 * @throws Exception
	 */
	public static void setText(TextView tv, CharSequence text) {
		if (tv != null) {
			if (TextUtils.isEmpty(text)) {
				tv.setVisibility(View.GONE);
			} else {
				tv.setVisibility(View.VISIBLE);
				tv.setText(text);
			}
		}
	}

	public static void setTextColor(TextView tv, int color) {
		if (tv != null) {
			tv.setTextColor(color);
		}
	}

	public static void setTextColor(TextView tv, ColorStateList colorStateList) {
		if (tv != null) {
			tv.setTextColor(colorStateList);
		}
	}
}
