Search in sources :

Example 1 with ActionMenuItemView

use of android.support.v7.view.menu.ActionMenuItemView in project HoloEverywhere by Prototik.

the class ActionMenuPresenter method getItemView.

@Override
public View getItemView(MenuItemImpl item, View convertView, ViewGroup parent) {
    View actionView = item.getActionView();
    if (actionView == null || item.hasCollapsibleActionView()) {
        if (!(convertView instanceof ActionMenuItemView)) {
            convertView = null;
        }
        actionView = super.getItemView(item, convertView, parent);
    }
    actionView.setVisibility(item.isActionViewExpanded() ? View.GONE : View.VISIBLE);
    final ActionMenuView menuParent = (ActionMenuView) parent;
    final ViewGroup.LayoutParams lp = actionView.getLayoutParams();
    if (!menuParent.checkLayoutParams(lp)) {
        actionView.setLayoutParams(menuParent.generateLayoutParams(lp));
    }
    return actionView;
}
Also used : ViewGroup(android.view.ViewGroup) ActionMenuChildView(android.support.v7.internal.view.menu.ActionMenuView.ActionMenuChildView) View(android.view.View)

Example 2 with ActionMenuItemView

use of android.support.v7.view.menu.ActionMenuItemView in project actor-platform by actorapp.

the class ActorToolbar method doColorizing.

public static void doColorizing(View v, final ColorFilter colorFilter, int toolbarIconsColor) {
    if (v instanceof ImageButton) {
        ((ImageButton) v).getDrawable().setAlpha(255);
        ((ImageButton) v).getDrawable().setColorFilter(colorFilter);
    }
    if (v instanceof ImageView && !(v instanceof AvatarView)) {
        ((ImageView) v).getDrawable().setAlpha(255);
        ((ImageView) v).getDrawable().setColorFilter(colorFilter);
    }
    if (v instanceof AutoCompleteTextView) {
        ((AutoCompleteTextView) v).setTextColor(toolbarIconsColor);
    }
    if (v instanceof TextView) {
        ((TextView) v).setTextColor(toolbarIconsColor);
    }
    if (v instanceof EditText) {
        ((EditText) v).setTextColor(toolbarIconsColor);
    }
    if (v instanceof ViewGroup) {
        for (int lli = 0; lli < ((ViewGroup) v).getChildCount(); lli++) {
            doColorizing(((ViewGroup) v).getChildAt(lli), colorFilter, toolbarIconsColor);
        }
    }
    if (v instanceof ActionMenuView) {
        for (int j = 0; j < ((ActionMenuView) v).getChildCount(); j++) {
            //Step 2: Changing the color of any ActionMenuViews - icons that
            //are not back button, nor text, nor overflow menu icon.
            final View innerView = ((ActionMenuView) v).getChildAt(j);
            if (innerView instanceof ActionMenuItemView) {
                int drawablesCount = ((ActionMenuItemView) innerView).getCompoundDrawables().length;
                for (int k = 0; k < drawablesCount; k++) {
                    if (((ActionMenuItemView) innerView).getCompoundDrawables()[k] != null) {
                        final int finalK = k;
                        //Important to set the color filter in seperate thread,
                        //by adding it to the message queue
                        //Won't work otherwise.
                        //Works fine for my case but needs more testing
                        ((ActionMenuItemView) innerView).getCompoundDrawables()[finalK].setColorFilter(colorFilter);
                    //                              innerView.post(new Runnable() {
                    //                                  @Override
                    //                                  public void run() {
                    //                                      ((ActionMenuItemView) innerView).getCompoundDrawables()[finalK].setColorFilter(colorFilter);
                    //                                  }
                    //                              });
                    }
                }
            }
        }
    }
}
Also used : EditText(android.widget.EditText) ImageButton(android.widget.ImageButton) AvatarView(im.actor.sdk.view.avatar.AvatarView) ViewGroup(android.view.ViewGroup) AutoCompleteTextView(android.widget.AutoCompleteTextView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ActionMenuView(android.support.v7.widget.ActionMenuView) ImageView(android.widget.ImageView) AutoCompleteTextView(android.widget.AutoCompleteTextView) ActionMenuView(android.support.v7.widget.ActionMenuView) TextView(android.widget.TextView) ActionMenuItemView(android.support.v7.view.menu.ActionMenuItemView) AvatarView(im.actor.sdk.view.avatar.AvatarView) View(android.view.View) ActionMenuItemView(android.support.v7.view.menu.ActionMenuItemView) AutoCompleteTextView(android.widget.AutoCompleteTextView)

Example 3 with ActionMenuItemView

use of android.support.v7.view.menu.ActionMenuItemView 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

ActionMenuItemView (android.support.v7.view.menu.ActionMenuItemView)2 View (android.view.View)2 ViewGroup (android.view.ViewGroup)2 EditText (android.widget.EditText)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 TypedArray (android.content.res.TypedArray)1 ActionMenuChildView (android.support.v7.internal.view.menu.ActionMenuView.ActionMenuChildView)1 ActionMenuView (android.support.v7.widget.ActionMenuView)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 AutoCompleteTextView (android.widget.AutoCompleteTextView)1 ImageButton (android.widget.ImageButton)1 Iconics (com.mikepenz.iconics.Iconics)1 AvatarView (im.actor.sdk.view.avatar.AvatarView)1