Java Code Examples for com.mikepenz.materialdrawer.holder.StringHolder#applyToOrHide()

The following examples show how to use com.mikepenz.materialdrawer.holder.StringHolder#applyToOrHide() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MyExpandableBadgeDrawerItem.java    From Focus with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void bindView(MyExpandableBadgeDrawerItem.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 (true) {
        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());
    }

    //make sure all animations are stopped
    if (viewHolder.arrow.getDrawable() instanceof IconicsDrawable) {
        ((IconicsDrawable) viewHolder.arrow.getDrawable()).color(this.arrowColor != null ? this.arrowColor.color(ctx) : getIconColor(ctx));
    }
    viewHolder.arrow.clearAnimation();
    if (!isExpanded()) {
        viewHolder.arrow.setRotation(this.arrowRotationAngleStart);
    } else {
        viewHolder.arrow.setRotation(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);
}
 
Example 2
Source File: MyExpandableBadgeDrawerItem.java    From Focus with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void bindView(MyExpandableBadgeDrawerItem.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 (true) {
        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());
    }

    //make sure all animations are stopped
    if (viewHolder.arrow.getDrawable() instanceof IconicsDrawable) {
        ((IconicsDrawable) viewHolder.arrow.getDrawable()).color(this.arrowColor != null ? this.arrowColor.color(ctx) : getIconColor(ctx));
    }
    viewHolder.arrow.clearAnimation();
    if (!isExpanded()) {
        viewHolder.arrow.setRotation(this.arrowRotationAngleStart);
    } else {
        viewHolder.arrow.setRotation(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);
}
 
Example 3
Source File: SecondaryDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 5 votes vote down vote up
@Override
public void bindView(RecyclerView.ViewHolder holder) {
    Context ctx = holder.itemView.getContext();

    //get our viewHolder
    ViewHolder viewHolder = (ViewHolder) holder;

    //bind the basic view parts
    bindViewHelper((BaseViewHolder) holder);

    //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, holder.itemView);
}
 
Example 4
Source File: PrimaryDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 5 votes vote down vote up
@Override
public void bindView(RecyclerView.ViewHolder holder) {
    Context ctx = holder.itemView.getContext();

    //get our viewHolder
    ViewHolder viewHolder = (ViewHolder) holder;

    //bind the basic view parts
    bindViewHelper((BaseViewHolder) holder);

    //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, holder.itemView);
}
 
Example 5
Source File: BaseSecondaryDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
/**
 * a helper method to have the logic for all secondaryDrawerItems only once
 *
 * @param viewHolder
 */
protected void bindViewHelper(BaseViewHolder viewHolder) {
    Context ctx = viewHolder.itemView.getContext();

    //set the identifier from the drawerItem here. It can be used to run tests
    viewHolder.itemView.setId(getIdentifier());

    //set the item selected if it is
    viewHolder.itemView.setSelected(isSelected());

    //get the correct color for the background
    int selectedColor = getSelectedColor(ctx);
    //get the correct color for the text
    int color = getColor(ctx);
    int selectedTextColor = getSelectedTextColor(ctx);
    //get the correct color for the icon
    int iconColor = getIconColor(ctx);
    int selectedIconColor = getSelectedIconColor(ctx);

    //set the background for the item
    UIUtils.setBackground(viewHolder.view, DrawerUIUtils.getSelectableBackground(ctx, selectedColor));
    //set the text for the name
    StringHolder.applyTo(this.getName(), viewHolder.name);

    //set the text for the description or hide
    StringHolder.applyToOrHide(this.getDescription(), viewHolder.description);

    //set the colors for textViews
    viewHolder.name.setTextColor(getTextColorStateList(color, selectedTextColor));

    //set the description text color
    ColorHolder.applyToOr(getDescriptionTextColor(), viewHolder.description, getTextColorStateList(getColor(ctx), getSelectedColor(ctx)));

    //define the typeface for our textViews
    if (getTypeface() != null) {
        viewHolder.name.setTypeface(getTypeface());
        viewHolder.description.setTypeface(getTypeface());
    }

    //get the drawables for our icon and set it
    Drawable icon = ImageHolder.decideIcon(getIcon(), ctx, iconColor, isIconTinted(), 1);
    Drawable selectedIcon = ImageHolder.decideIcon(getSelectedIcon(), ctx, selectedIconColor, isIconTinted(), 1);
    ImageHolder.applyMultiIconTo(icon, iconColor, selectedIcon, selectedIconColor, isIconTinted(), viewHolder.icon);

    //for android API 17 --> Padding not applied via xml
    DrawerUIUtils.setDrawerVerticalPadding(viewHolder.view, level);
}
 
Example 6
Source File: MiniDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
@Override
public void bindView(RecyclerView.ViewHolder holder) {
    Context ctx = holder.itemView.getContext();

    //get our viewHolder
    ViewHolder viewHolder = (ViewHolder) holder;

    //set the identifier from the drawerItem here. It can be used to run tests
    viewHolder.itemView.setId(getIdentifier());

    //set the item selected if it is
    viewHolder.itemView.setSelected(isSelected());

    //
    viewHolder.itemView.setTag(this);

    //get the correct color for the icon
    int iconColor = getIconColor(ctx);
    int selectedIconColor = getSelectedIconColor(ctx);

    if (mEnableSelectedBackground) {
        //get the correct color for the background
        int selectedColor = getSelectedColor(ctx);
        //set the background for the item
        UIUtils.setBackground(viewHolder.view, DrawerUIUtils.getSelectableBackground(ctx, selectedColor));
    }

    //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);
    }

    //get the drawables for our icon and set it
    Drawable icon = ImageHolder.decideIcon(getIcon(), ctx, iconColor, isIconTinted(), 1);
    Drawable selectedIcon = ImageHolder.decideIcon(getSelectedIcon(), ctx, selectedIconColor, isIconTinted(), 1);
    ImageHolder.applyMultiIconTo(icon, iconColor, selectedIcon, selectedIconColor, isIconTinted(), viewHolder.icon);

    //for android API 17 --> Padding not applied via xml
    int verticalPadding = ctx.getResources().getDimensionPixelSize(R.dimen.material_drawer_padding);
    int topBottomPadding = ctx.getResources().getDimensionPixelSize(R.dimen.material_mini_drawer_item_padding);
    viewHolder.itemView.setPadding(verticalPadding, topBottomPadding, verticalPadding, topBottomPadding);

    //call the onPostBindView method to trigger post bind view actions (like the listener to modify the item if required)
    onPostBindView(this, holder.itemView);
}
 
Example 7
Source File: BasePrimaryDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
/**
 * a helper method to have the logic for all secondaryDrawerItems only once
 *
 * @param viewHolder
 */
protected void bindViewHelper(BaseViewHolder viewHolder) {
    Context ctx = viewHolder.itemView.getContext();

    //set the identifier from the drawerItem here. It can be used to run tests
    viewHolder.itemView.setId(getIdentifier());

    //set the item selected if it is
    viewHolder.itemView.setSelected(isSelected());

    //
    viewHolder.itemView.setTag(this);

    //get the correct color for the background
    int selectedColor = getSelectedColor(ctx);
    //get the correct color for the text
    int color = getColor(ctx);
    int selectedTextColor = getSelectedTextColor(ctx);
    //get the correct color for the icon
    int iconColor = getIconColor(ctx);
    int selectedIconColor = getSelectedIconColor(ctx);

    //set the background for the item
    UIUtils.setBackground(viewHolder.view, DrawerUIUtils.getSelectableBackground(ctx, selectedColor));
    //set the text for the name
    StringHolder.applyTo(this.getName(), viewHolder.name);
    //set the text for the description or hide
    StringHolder.applyToOrHide(this.getDescription(), viewHolder.description);

    //set the colors for textViews
    viewHolder.name.setTextColor(getTextColorStateList(color, selectedTextColor));
    //set the description text color
    ColorHolder.applyToOr(getDescriptionTextColor(), viewHolder.description, getTextColorStateList(color, selectedTextColor));

    //define the typeface for our textViews
    if (getTypeface() != null) {
        viewHolder.name.setTypeface(getTypeface());
        viewHolder.description.setTypeface(getTypeface());
    }

    //get the drawables for our icon and set it
    Drawable icon = ImageHolder.decideIcon(getIcon(), ctx, iconColor, isIconTinted(), 1);
    Drawable selectedIcon = ImageHolder.decideIcon(getSelectedIcon(), ctx, selectedIconColor, isIconTinted(), 1);
    ImageHolder.applyMultiIconTo(icon, iconColor, selectedIcon, selectedIconColor, isIconTinted(), viewHolder.icon);

    //for android API 17 --> Padding not applied via xml
    DrawerUIUtils.setDrawerVerticalPadding(viewHolder.view, level);
}