Example usage for android.text TextUtils stringOrSpannedString

List of usage examples for android.text TextUtils stringOrSpannedString

Introduction

In this page you can find the example usage for android.text TextUtils stringOrSpannedString.

Prototype

public static CharSequence stringOrSpannedString(CharSequence source) 

Source Link

Usage

From source file:com.coreform.open.android.formidablevalidation.SetErrorHandler.java

public void setError(CharSequence error, Drawable icon, boolean showError,
        boolean showCompoundDrawableOnRight) {
    if (DEBUG)/*from  ww  w  .  j av a 2  s.c  o  m*/
        Log.d(TAG, ".setError(error, icon, showError, showCompoundDrawableOnRight)...");
    if (icon != null) {
        if (DEBUG)
            Log.d(TAG, "...icon is not null...");
        icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight());
    }
    error = TextUtils.stringOrSpannedString(error);
    mErrorWasChanged = true;

    mError = error;
    mErrorWasChanged = true;

    final Drawables dr = mDrawables;
    if (mView instanceof TextView && error != null) {
        if (true || dr != null) {
            if (showCompoundDrawableOnRight) {
                if (DEBUG)
                    Log.d(TAG, "...showing CompoundDrawable on right)...");
                //((TextView) mView).setCompoundDrawables(dr.mDrawableLeft, dr.mDrawableTop, icon, dr.mDrawableBottom);
                ((TextView) mView).setCompoundDrawables(null, null, icon, null);
            } else {
                //((TextView) mView).setCompoundDrawables(icon, dr.mDrawableTop, dr.mDrawableRight, dr.mDrawableBottom);
                ((TextView) mView).setCompoundDrawables(icon, null, null, null);
            }
        }
    }

    if (error == null) {
        if (mPopup != null) {
            if (mPopup.isShowing()) {
                mPopup.dismiss();
            }
            if (mView instanceof TextView) {
                ((TextView) mView).setCompoundDrawables(null, null, null, null);
            }
            mPopup = null;
        }
    } else if (showError) {
        //LD - EditTexts use isFocused to show only the focused one, other Views may not be focusable
        //if (isFocused()) {
        showError();
        //}
    }
}