Search in sources :

Example 1 with Iconics

use of com.mikepenz.iconics.Iconics in project Android-Iconics by mikepenz.

the class IconicsFactory method onViewCreatedInternal.

/**
     * @param view
     * @param context
     * @param attrs
     */
void onViewCreatedInternal(View view, final Context context, AttributeSet attrs) {
    if (attrs == null) {
        return;
    }
    if (view instanceof ActionMenuItemView) {
        final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Iconics);
        String icon = a.getString(R.styleable.Iconics_ico_icon);
        if (!TextUtils.isEmpty(icon)) {
            ((ActionMenuItemView) view).setIcon(getDrawable(context, a, icon));
        }
        a.recycle();
    } else if (view instanceof EditText) {
        //handle iconics
        new Iconics.IconicsBuilder().ctx(context).on((TextView) view).build();
    //for an editText we only style initial as styling the Editable causes problems!
    } else if (view instanceof TextView) {
        //handle iconics
        new Iconics.IconicsBuilder().ctx(context).on((TextView) view).build();
        ((TextView) view).addTextChangedListener(new TextWatcher() {

            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            }

            @Override
            public void afterTextChanged(Editable editable) {
                Iconics.styleEditable(context, editable);
            }
        });
    } else if (view instanceof ImageView) {
        final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Iconics);
        String icon = a.getString(R.styleable.Iconics_ico_icon);
        if (!TextUtils.isEmpty(icon)) {
            ((ImageView) view).setImageDrawable(getDrawable(context, a, icon));
        }
        a.recycle();
    }
}
Also used : EditText(android.widget.EditText) Iconics(com.mikepenz.iconics.Iconics) TypedArray(android.content.res.TypedArray) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ActionMenuItemView(android.support.v7.view.menu.ActionMenuItemView)

Aggregations

TypedArray (android.content.res.TypedArray)1 ActionMenuItemView (android.support.v7.view.menu.ActionMenuItemView)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 EditText (android.widget.EditText)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 Iconics (com.mikepenz.iconics.Iconics)1