com.mikepenz.materialdrawer.holder.StringHolder Java Examples

The following examples show how to use com.mikepenz.materialdrawer.holder.StringHolder. 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: 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 #2
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 #3
Source File: SectionDrawerItem.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;

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

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

    //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, holder.itemView);
}
 
Example #4
Source File: Drawer.java    From MaterialDrawer-Xamarin with Apache License 2.0 5 votes vote down vote up
/**
 * update the badge for a specific drawerItem
 * identified by its id
 *
 * @param identifier
 * @param badge
 */
public void updateBadge(int identifier, StringHolder badge) {
    IDrawerItem drawerItem = getDrawerItem(identifier);
    if (drawerItem instanceof Badgeable) {
        Badgeable badgeable = (Badgeable) drawerItem;
        badgeable.withBadge(badge);
        updateItem((IDrawerItem) badgeable);
    }
}
 
Example #5
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 #6
Source File: Drawer.java    From MaterialDrawer-Xamarin with Apache License 2.0 5 votes vote down vote up
/**
 * update the name for a specific drawerItem
 * identified by its id
 *
 * @param identifier
 * @param name
 */
public void updateName(int identifier, StringHolder name) {
    IDrawerItem drawerItem = getDrawerItem(identifier);
    if (drawerItem instanceof Nameable) {
        Nameable pdi = (Nameable) drawerItem;
        pdi.withName(name);
        updateItem((IDrawerItem) pdi);
    }
}
 
Example #7
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 #8
Source File: SecondaryDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
@Override
public SecondaryDrawerItem withBadge(String badge) {
    this.mBadge = new StringHolder(badge);
    return this;
}
 
Example #9
Source File: SecondaryDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
@Override
public SecondaryDrawerItem withBadge(@StringRes int badgeRes) {
    this.mBadge = new StringHolder(badgeRes);
    return this;
}
 
Example #10
Source File: SecondaryDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
public StringHolder getBadge() {
    return mBadge;
}
 
Example #11
Source File: SecondaryDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
@Override
public SecondaryDrawerItem withBadge(StringHolder badge) {
    this.mBadge = badge;
    return this;
}
 
Example #12
Source File: BaseDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
public T withName(StringHolder name) {
    this.name = name;
    return (T) this;
}
 
Example #13
Source File: BaseDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
public T withName(String name) {
    this.name = new StringHolder(name);
    return (T) this;
}
 
Example #14
Source File: BaseDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
public T withName(@StringRes int nameRes) {
    this.name = new StringHolder(nameRes);
    return (T) this;
}
 
Example #15
Source File: MyExpandableBadgeDrawerItem.java    From Focus with GNU General Public License v3.0 4 votes vote down vote up
@Override
public MyExpandableBadgeDrawerItem withBadge(StringHolder badge) {
    this.mBadge = badge;
    return (MyExpandableBadgeDrawerItem) this;
}
 
Example #16
Source File: BaseDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
public StringHolder getName() {
    return name;
}
 
Example #17
Source File: PrimaryDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
@Override
public PrimaryDrawerItem withBadge(StringHolder badge) {
    this.mBadge = badge;
    return this;
}
 
Example #18
Source File: PrimaryDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
@Override
public PrimaryDrawerItem withBadge(String badge) {
    this.mBadge = new StringHolder(badge);
    return this;
}
 
Example #19
Source File: PrimaryDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
@Override
public PrimaryDrawerItem withBadge(@StringRes int badgeRes) {
    this.mBadge = new StringHolder(badgeRes);
    return this;
}
 
Example #20
Source File: PrimaryDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
public StringHolder getBadge() {
    return mBadge;
}
 
Example #21
Source File: SectionDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
public SectionDrawerItem withName(StringHolder name) {
    this.name = name;
    return this;
}
 
Example #22
Source File: SectionDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
public SectionDrawerItem withName(String name) {
    this.name = new StringHolder(name);
    return this;
}
 
Example #23
Source File: SectionDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
public SectionDrawerItem withName(@StringRes int nameRes) {
    this.name = new StringHolder(nameRes);
    return this;
}
 
Example #24
Source File: SectionDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
public StringHolder getName() {
    return name;
}
 
Example #25
Source File: ProfileSettingDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
public ProfileSettingDrawerItem withName(String name) {
    this.name = new StringHolder(name);
    return this;
}
 
Example #26
Source File: ProfileSettingDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
public ProfileSettingDrawerItem withDescription(String description) {
    this.email = new StringHolder(description);
    return this;
}
 
Example #27
Source File: ProfileSettingDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
public ProfileSettingDrawerItem withEmail(String email) {
    this.email = new StringHolder(email);
    return this;
}
 
Example #28
Source File: ProfileSettingDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
@Override
public StringHolder getName() {
    return name;
}
 
Example #29
Source File: ProfileSettingDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
public StringHolder getEmail() {
    return email;
}
 
Example #30
Source File: ProfileSettingDrawerItem.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
public StringHolder getDescription() {
    return email;
}