Java Code Examples for com.mikepenz.materialdrawer.holder.StringHolder
The following examples show how to use
com.mikepenz.materialdrawer.holder.StringHolder. These examples are extracted from open source projects.
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 Project: Focus Source File: MyExpandableBadgeDrawerItem.java License: GNU General Public License v3.0 | 5 votes |
@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 Project: Focus Source File: MyExpandableBadgeDrawerItem.java License: GNU General Public License v3.0 | 5 votes |
@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 Project: MaterialDrawer-Xamarin Source File: SecondaryDrawerItem.java License: Apache License 2.0 | 5 votes |
@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 Project: MaterialDrawer-Xamarin Source File: PrimaryDrawerItem.java License: Apache License 2.0 | 5 votes |
@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 Project: MaterialDrawer-Xamarin Source File: SectionDrawerItem.java License: Apache License 2.0 | 5 votes |
@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 6
Source Project: MaterialDrawer-Xamarin Source File: Drawer.java License: Apache License 2.0 | 5 votes |
/** * 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 7
Source Project: MaterialDrawer-Xamarin Source File: Drawer.java License: Apache License 2.0 | 5 votes |
/** * 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 8
Source Project: Focus Source File: MyExpandableBadgeDrawerItem.java License: GNU General Public License v3.0 | 4 votes |
@Override public MyExpandableBadgeDrawerItem withBadge(StringHolder badge) { this.mBadge = badge; return (MyExpandableBadgeDrawerItem) this; }
Example 9
Source Project: Focus Source File: MyExpandableBadgeDrawerItem.java License: GNU General Public License v3.0 | 4 votes |
@Override public MyExpandableBadgeDrawerItem withBadge(String badge) { this.mBadge = new StringHolder(badge); return (MyExpandableBadgeDrawerItem) this; }
Example 10
Source Project: Focus Source File: MyExpandableBadgeDrawerItem.java License: GNU General Public License v3.0 | 4 votes |
@Override public MyExpandableBadgeDrawerItem withBadge(@StringRes int badgeRes) { this.mBadge = new StringHolder(badgeRes); return (MyExpandableBadgeDrawerItem) this; }
Example 11
Source Project: Focus Source File: MyExpandableBadgeDrawerItem.java License: GNU General Public License v3.0 | 4 votes |
public StringHolder getBadge() { return mBadge; }
Example 12
Source Project: Focus Source File: MyExpandableBadgeDrawerItem.java License: GNU General Public License v3.0 | 4 votes |
@Override public MyExpandableBadgeDrawerItem withBadge(StringHolder badge) { this.mBadge = badge; return (MyExpandableBadgeDrawerItem) this; }
Example 13
Source Project: Focus Source File: MyExpandableBadgeDrawerItem.java License: GNU General Public License v3.0 | 4 votes |
@Override public MyExpandableBadgeDrawerItem withBadge(String badge) { this.mBadge = new StringHolder(badge); return (MyExpandableBadgeDrawerItem) this; }
Example 14
Source Project: Focus Source File: MyExpandableBadgeDrawerItem.java License: GNU General Public License v3.0 | 4 votes |
@Override public MyExpandableBadgeDrawerItem withBadge(@StringRes int badgeRes) { this.mBadge = new StringHolder(badgeRes); return (MyExpandableBadgeDrawerItem) this; }
Example 15
Source Project: Focus Source File: MyExpandableBadgeDrawerItem.java License: GNU General Public License v3.0 | 4 votes |
public StringHolder getBadge() { return mBadge; }
Example 16
Source Project: MidiSheetMusic-Android Source File: SheetMusicActivity.java License: GNU General Public License v3.0 | 4 votes |
/** Handle clicks on the drawer menu */ public boolean drawerItemClickListener(IDrawerItem item) { switch ((int)item.getIdentifier()) { case R.id.song_settings: changeSettings(); drawer.closeDrawer(); break; case R.id.save_images: showSaveImagesDialog(); drawer.closeDrawer(); break; case ID_LOOP_START: // Note that we display the measure numbers starting at 1, // but the actual playMeasuresInLoopStart field starts at 0. AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.play_measures_in_loop_start); String[] items = makeStringList(1, options.lastMeasure + 1); builder.setItems(items, (dialog, i) -> { options.playMeasuresInLoopStart = Integer.parseInt(items[i]) - 1; // Make sure End is not smaller than Start if (options.playMeasuresInLoopStart > options.playMeasuresInLoopEnd) { options.playMeasuresInLoopEnd = options.playMeasuresInLoopStart; drawer.updateBadge(ID_LOOP_END, new StringHolder(items[i])); } ((SecondaryDrawerItem) item).withBadge(items[i]); drawer.updateItem(item); }); AlertDialog alertDialog = builder.create(); alertDialog.show(); alertDialog.getListView().setSelection(options.playMeasuresInLoopStart); break; case ID_LOOP_END: // Note that we display the measure numbers starting at 1, // but the actual playMeasuresInLoopEnd field starts at 0. builder = new AlertDialog.Builder(this); builder.setTitle(R.string.play_measures_in_loop_end); items = makeStringList(1, options.lastMeasure + 1); builder.setItems(items, (dialog, i) -> { options.playMeasuresInLoopEnd = Integer.parseInt(items[i]) - 1; // Make sure End is not smaller than Start if (options.playMeasuresInLoopStart > options.playMeasuresInLoopEnd) { options.playMeasuresInLoopStart = options.playMeasuresInLoopEnd; drawer.updateBadge(ID_LOOP_START, new StringHolder(items[i])); } ((SecondaryDrawerItem) item).withBadge(items[i]); drawer.updateItem(item); }); alertDialog = builder.create(); alertDialog.show(); alertDialog.getListView().setSelection(options.playMeasuresInLoopEnd); break; } return true; }
Example 17
Source Project: MaterialDrawer-Xamarin Source File: BaseSecondaryDrawerItem.java License: Apache License 2.0 | 4 votes |
public T withDescription(String description) { this.description = new StringHolder(description); return (T) this; }
Example 18
Source Project: MaterialDrawer-Xamarin Source File: BaseSecondaryDrawerItem.java License: Apache License 2.0 | 4 votes |
public T withDescription(@StringRes int descriptionRes) { this.description = new StringHolder(descriptionRes); return (T) this; }
Example 19
Source Project: MaterialDrawer-Xamarin Source File: BaseSecondaryDrawerItem.java License: Apache License 2.0 | 4 votes |
public StringHolder getDescription() { return description; }
Example 20
Source Project: MaterialDrawer-Xamarin Source File: BaseSecondaryDrawerItem.java License: Apache License 2.0 | 4 votes |
/** * 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 21
Source Project: MaterialDrawer-Xamarin Source File: MiniDrawerItem.java License: Apache License 2.0 | 4 votes |
@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 22
Source Project: MaterialDrawer-Xamarin Source File: MiniProfileDrawerItem.java License: Apache License 2.0 | 4 votes |
@Override public StringHolder getName() { return null; }
Example 23
Source Project: MaterialDrawer-Xamarin Source File: MiniProfileDrawerItem.java License: Apache License 2.0 | 4 votes |
@Override public StringHolder getEmail() { return null; }
Example 24
Source Project: MaterialDrawer-Xamarin Source File: BasePrimaryDrawerItem.java License: Apache License 2.0 | 4 votes |
public T withDescription(String description) { this.description = new StringHolder(description); return (T) this; }
Example 25
Source Project: MaterialDrawer-Xamarin Source File: BasePrimaryDrawerItem.java License: Apache License 2.0 | 4 votes |
public T withDescription(@StringRes int descriptionRes) { this.description = new StringHolder(descriptionRes); return (T) this; }
Example 26
Source Project: MaterialDrawer-Xamarin Source File: BasePrimaryDrawerItem.java License: Apache License 2.0 | 4 votes |
public StringHolder getDescription() { return description; }
Example 27
Source Project: MaterialDrawer-Xamarin Source File: BasePrimaryDrawerItem.java License: Apache License 2.0 | 4 votes |
/** * 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); }
Example 28
Source Project: MaterialDrawer-Xamarin Source File: ProfileDrawerItem.java License: Apache License 2.0 | 4 votes |
public ProfileDrawerItem withName(String name) { this.name = new StringHolder(name); return this; }
Example 29
Source Project: MaterialDrawer-Xamarin Source File: ProfileDrawerItem.java License: Apache License 2.0 | 4 votes |
public ProfileDrawerItem withEmail(String email) { this.email = new StringHolder(email); return this; }
Example 30
Source Project: MaterialDrawer-Xamarin Source File: ProfileDrawerItem.java License: Apache License 2.0 | 4 votes |
@Override public StringHolder getName() { return name; }