Search in sources :

Example 31 with Context

use of android.content.Context in project MaterialDrawer by mikepenz.

the class CustomUrlPrimaryDrawerItem method bindView.

@Override
public void bindView(ViewHolder viewHolder, List payloads) {
    super.bindView(viewHolder, payloads);
    Context ctx = viewHolder.itemView.getContext();
    //bind the basic view parts
    bindViewHelper(viewHolder);
    //set the text for the badge or hide
    boolean badgeVisible = StringHolder.applyToOrHide(mBadge, viewHolder.badge);
    //style the badge if it is visible
    if (badgeVisible) {
        mBadgeStyle.style(viewHolder.badge, getTextColorStateList(getColor(ctx), getSelectedTextColor(ctx)));
        viewHolder.badgeContainer.setVisibility(View.VISIBLE);
    } else {
        viewHolder.badgeContainer.setVisibility(View.GONE);
    }
    //define the typeface for our textViews
    if (getTypeface() != null) {
        viewHolder.badge.setTypeface(getTypeface());
    }
    //call the onPostBindView method to trigger post bind view actions (like the listener to modify the item if required)
    onPostBindView(this, viewHolder.itemView);
}
Also used : Context(android.content.Context)

Example 32 with Context

use of android.content.Context in project MaterialDrawer by mikepenz.

the class ExpandableDrawerItem method bindView.

@Override
public void bindView(ViewHolder viewHolder, List payloads) {
    super.bindView(viewHolder, payloads);
    Context ctx = viewHolder.itemView.getContext();
    //bind the basic view parts
    bindViewHelper(viewHolder);
    //make sure all animations are stopped
    viewHolder.arrow.setColor(this.arrowColor != null ? this.arrowColor.color(ctx) : getIconColor(ctx));
    viewHolder.arrow.clearAnimation();
    if (!isExpanded()) {
        ViewCompat.setRotation(viewHolder.arrow, this.arrowRotationAngleStart);
    } else {
        ViewCompat.setRotation(viewHolder.arrow, this.arrowRotationAngleEnd);
    }
    //call the onPostBindView method to trigger post bind view actions (like the listener to modify the item if required)
    onPostBindView(this, viewHolder.itemView);
}
Also used : Context(android.content.Context)

Example 33 with Context

use of android.content.Context in project MaterialDrawer by mikepenz.

the class SectionDrawerItem method bindView.

@Override
public void bindView(ViewHolder viewHolder, List payloads) {
    super.bindView(viewHolder, payloads);
    Context ctx = viewHolder.itemView.getContext();
    //set the identifier from the drawerItem here. It can be used to run tests
    viewHolder.itemView.setId(hashCode());
    //define this item to be not clickable nor enabled
    viewHolder.view.setClickable(false);
    viewHolder.view.setEnabled(false);
    //define the text color
    viewHolder.name.setTextColor(ColorHolder.color(getTextColor(), ctx, R.attr.material_drawer_secondary_text, R.color.material_drawer_secondary_text));
    //set the text for the name
    StringHolder.applyTo(this.getName(), viewHolder.name);
    //define the typeface for our textViews
    if (getTypeface() != null) {
        viewHolder.name.setTypeface(getTypeface());
    }
    //hide the divider if we do not need one
    if (this.hasDivider()) {
        viewHolder.divider.setVisibility(View.VISIBLE);
    } else {
        viewHolder.divider.setVisibility(View.GONE);
    }
    //set the color for the divider
    viewHolder.divider.setBackgroundColor(UIUtils.getThemeColorFromAttrOrRes(ctx, R.attr.material_drawer_divider, R.color.material_drawer_divider));
    //call the onPostBindView method to trigger post bind view actions (like the listener to modify the item if required)
    onPostBindView(this, viewHolder.itemView);
}
Also used : Context(android.content.Context)

Example 34 with Context

use of android.content.Context in project AndroidTraining by mixi-inc.

the class IcsListPopupWindow method buildDropDown.

private int buildDropDown() {
    ViewGroup dropDownView;
    int otherHeights = 0;
    if (mDropDownList == null) {
        Context context = mContext;
        mDropDownList = new DropDownListView(context, !mModal);
        if (mDropDownListHighlight != null) {
            mDropDownList.setSelector(mDropDownListHighlight);
        }
        mDropDownList.setAdapter(mAdapter);
        mDropDownList.setOnItemClickListener(mItemClickListener);
        mDropDownList.setFocusable(true);
        mDropDownList.setFocusableInTouchMode(true);
        mDropDownList.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                if (position != -1) {
                    DropDownListView dropDownList = mDropDownList;
                    if (dropDownList != null) {
                        dropDownList.mListSelectionHidden = false;
                    }
                }
            }

            public void onNothingSelected(AdapterView<?> parent) {
            }
        });
        mDropDownList.setOnScrollListener(mScrollListener);
        if (mItemSelectedListener != null) {
            mDropDownList.setOnItemSelectedListener(mItemSelectedListener);
        }
        dropDownView = mDropDownList;
        View hintView = mPromptView;
        if (hintView != null) {
            // if an hint has been specified, we accomodate more space for it and
            // add a text view in the drop down menu, at the bottom of the list
            LinearLayout hintContainer = new LinearLayout(context);
            hintContainer.setOrientation(LinearLayout.VERTICAL);
            LinearLayout.LayoutParams hintParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1.0f);
            switch(mPromptPosition) {
                case POSITION_PROMPT_BELOW:
                    hintContainer.addView(dropDownView, hintParams);
                    hintContainer.addView(hintView);
                    break;
                case POSITION_PROMPT_ABOVE:
                    hintContainer.addView(hintView);
                    hintContainer.addView(dropDownView, hintParams);
                    break;
                default:
                    break;
            }
            // measure the hint's height to find how much more vertical space
            // we need to add to the drop down's height
            int widthSpec = MeasureSpec.makeMeasureSpec(mDropDownWidth, MeasureSpec.AT_MOST);
            int heightSpec = MeasureSpec.UNSPECIFIED;
            hintView.measure(widthSpec, heightSpec);
            hintParams = (LinearLayout.LayoutParams) hintView.getLayoutParams();
            otherHeights = hintView.getMeasuredHeight() + hintParams.topMargin + hintParams.bottomMargin;
            dropDownView = hintContainer;
        }
        mPopup.setContentView(dropDownView);
    } else {
        dropDownView = (ViewGroup) mPopup.getContentView();
        final View view = mPromptView;
        if (view != null) {
            LinearLayout.LayoutParams hintParams = (LinearLayout.LayoutParams) view.getLayoutParams();
            otherHeights = view.getMeasuredHeight() + hintParams.topMargin + hintParams.bottomMargin;
        }
    }
    // getMaxAvailableHeight() subtracts the padding, so we put it back
    // to get the available height for the whole window
    int padding = 0;
    Drawable background = mPopup.getBackground();
    if (background != null) {
        background.getPadding(mTempRect);
        padding = mTempRect.top + mTempRect.bottom;
        // background so that content will line up.
        if (!mDropDownVerticalOffsetSet) {
            mDropDownVerticalOffset = -mTempRect.top;
        }
    }
    // Max height available on the screen for a popup.
    boolean ignoreBottomDecorations = mPopup.getInputMethodMode() == PopupWindow.INPUT_METHOD_NOT_NEEDED;
    final int maxHeight = /*mPopup.*/
    getMaxAvailableHeight(mDropDownAnchorView, mDropDownVerticalOffset, ignoreBottomDecorations);
    if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) {
        return maxHeight + padding;
    }
    final int listContent = /*mDropDownList.*/
    measureHeightOfChildren(MeasureSpec.UNSPECIFIED, 0, -1, /*ListView.NO_POSITION*/
    maxHeight - otherHeights, -1);
    // the popup if it is not needed
    if (listContent > 0)
        otherHeights += padding;
    return listContent + otherHeights;
}
Also used : Context(android.content.Context) ViewGroup(android.view.ViewGroup) Drawable(android.graphics.drawable.Drawable) AbsListView(android.widget.AbsListView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) AdapterView(android.widget.AdapterView) LinearLayout(android.widget.LinearLayout)

Example 35 with Context

use of android.content.Context in project AndroidTraining by mixi-inc.

the class MenuItemImpl method setActionView.

public MenuItem setActionView(int resId) {
    final Context context = mMenu.getContext();
    final LayoutInflater inflater = LayoutInflater.from(context);
    setActionView(inflater.inflate(resId, new LinearLayout(context), false));
    return this;
}
Also used : Context(android.content.Context) LayoutInflater(android.view.LayoutInflater) LinearLayout(android.widget.LinearLayout)

Aggregations

Context (android.content.Context)7516 Test (org.junit.Test)1645 Intent (android.content.Intent)1356 View (android.view.View)797 TextView (android.widget.TextView)549 BroadcastReceiver (android.content.BroadcastReceiver)497 IntentFilter (android.content.IntentFilter)485 PackageManager (android.content.pm.PackageManager)383 Resources (android.content.res.Resources)369 ArrayList (java.util.ArrayList)358 Bundle (android.os.Bundle)292 PendingIntent (android.app.PendingIntent)281 File (java.io.File)280 LayoutInflater (android.view.LayoutInflater)279 ImageView (android.widget.ImageView)263 Drawable (android.graphics.drawable.Drawable)256 IOException (java.io.IOException)248 Uri (android.net.Uri)247 RecyclerView (android.support.v7.widget.RecyclerView)200 Activity (android.app.Activity)198