本文整理汇总了Java中com.mikepenz.materialdrawer.util.DrawerUIUtils类的典型用法代码示例。如果您正苦于以下问题:Java DrawerUIUtils类的具体用法?Java DrawerUIUtils怎么用?Java DrawerUIUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DrawerUIUtils类属于com.mikepenz.materialdrawer.util包,在下文中一共展示了DrawerUIUtils类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fillStickyDrawerItemFooter
import com.mikepenz.materialdrawer.util.DrawerUIUtils; //导入依赖的package包/类
/**
* helper method to fill the sticky footer with it's elements
*
* @param drawer
* @param container
* @param onClickListener
*/
public static void fillStickyDrawerItemFooter(DrawerBuilder drawer, ViewGroup container, View.OnClickListener onClickListener) {
//add all drawer items
for (IDrawerItem drawerItem : drawer.mStickyDrawerItems) {
View view = drawerItem.generateView(container.getContext(), container);
view.setTag(drawerItem);
if (drawerItem.isEnabled()) {
//UIUtils.setBackground(view, UIUtils.getSelectableBackground(container.getContext(), selected_color, true));
view.setOnClickListener(onClickListener);
}
container.addView(view);
//for android API 17 --> Padding not applied via xml
DrawerUIUtils.setDrawerVerticalPadding(view);
}
//and really. don't ask about this. it won't set the padding if i don't set the padding for the container
container.setPadding(0, 0, 0, 0);
}
示例2: processDrawerLayoutParams
import com.mikepenz.materialdrawer.util.DrawerUIUtils; //导入依赖的package包/类
/**
* helper to extend the layoutParams of the drawer
*
* @param params
* @return
*/
public static DrawerLayout.LayoutParams processDrawerLayoutParams(DrawerBuilder drawer, DrawerLayout.LayoutParams params) {
if (params != null) {
if (drawer.mDrawerGravity != null && (drawer.mDrawerGravity == Gravity.RIGHT || drawer.mDrawerGravity == Gravity.END)) {
params.rightMargin = 0;
if (Build.VERSION.SDK_INT >= 17) {
params.setMarginEnd(0);
}
params.leftMargin = drawer.mActivity.getResources().getDimensionPixelSize(R.dimen.material_drawer_margin);
if (Build.VERSION.SDK_INT >= 17) {
params.setMarginEnd(drawer.mActivity.getResources().getDimensionPixelSize(R.dimen.material_drawer_margin));
}
}
if (drawer.mDrawerWidth > -1) {
params.width = drawer.mDrawerWidth;
} else {
params.width = DrawerUIUtils.getOptimalDrawerWidth(drawer.mActivity);
}
}
return params;
}
示例3: getTextColorStateList
import com.mikepenz.materialdrawer.util.DrawerUIUtils; //导入依赖的package包/类
/**
* helper to get the ColorStateList for the text and remembering it so we do not have to recreate it all the time
*
* @param color
* @param selectedTextColor
* @return
*/
protected ColorStateList getTextColorStateList(@ColorInt int color, @ColorInt int selectedTextColor) {
if (colorStateList == null || color + selectedTextColor != colorStateList.first) {
colorStateList = new Pair<>(color + selectedTextColor, DrawerUIUtils.getTextColorStateList(color, selectedTextColor));
}
return colorStateList.second;
}
示例4: setImageOrPlaceholder
import com.mikepenz.materialdrawer.util.DrawerUIUtils; //导入依赖的package包/类
/**
* small helper method to set an profile image or a placeholder
*
* @param iv
* @param imageHolder
*/
private void setImageOrPlaceholder(ImageView iv, ImageHolder imageHolder) {
//cancel previous started image loading processes
DrawerImageLoader.getInstance().cancelImage(iv);
//set the placeholder
iv.setImageDrawable(DrawerUIUtils.getPlaceHolder(iv.getContext()));
//set the real image (probably also the uri)
ImageHolder.applyTo(imageHolder, iv, DrawerImageLoader.Tags.PROFILE.name());
}
示例5: fillStickyDrawerItemFooter
import com.mikepenz.materialdrawer.util.DrawerUIUtils; //导入依赖的package包/类
/**
* helper method to fill the sticky footer with it's elements
*
* @param drawer
* @param container
* @param onClickListener
*/
public static void fillStickyDrawerItemFooter(DrawerBuilder drawer, ViewGroup container, View.OnClickListener onClickListener) {
//add all drawer items
for (IDrawerItem drawerItem : drawer.mStickyDrawerItems) {
//get the selected_color
int selected_color = UIUtils.getThemeColorFromAttrOrRes(container.getContext(), R.attr.material_drawer_selected, R.color.material_drawer_selected);
if (drawerItem instanceof PrimaryDrawerItem) {
selected_color = ColorHolder.color(((PrimaryDrawerItem) drawerItem).getSelectedColor(), container.getContext(), R.attr.material_drawer_selected, R.color.material_drawer_selected);
} else if (drawerItem instanceof SecondaryDrawerItem) {
selected_color = ColorHolder.color(((SecondaryDrawerItem) drawerItem).getSelectedColor(), container.getContext(), R.attr.material_drawer_selected, R.color.material_drawer_selected);
}
View view = drawerItem.generateView(container.getContext(), container);
view.setTag(drawerItem);
if (drawerItem.isEnabled()) {
UIUtils.setBackground(view, DrawerUIUtils.getSelectableBackground(container.getContext(), selected_color));
view.setOnClickListener(onClickListener);
}
container.addView(view);
//for android API 17 --> Padding not applied via xml
DrawerUIUtils.setDrawerVerticalPadding(view);
}
//and really. don't ask about this. it won't set the padding if i don't set the padding for the container
container.setPadding(0, 0, 0, 0);
}
示例6: processDrawerLayoutParams
import com.mikepenz.materialdrawer.util.DrawerUIUtils; //导入依赖的package包/类
/**
* helper to extend the layoutParams of the drawer
*
* @param params
* @return
*/
public static DrawerLayout.LayoutParams processDrawerLayoutParams(DrawerBuilder drawer, DrawerLayout.LayoutParams params) {
if (params != null) {
if (drawer.mDrawerGravity != null && (drawer.mDrawerGravity == Gravity.RIGHT || drawer.mDrawerGravity == Gravity.END)) {
params.rightMargin = 0;
if (Build.VERSION.SDK_INT >= 17) {
params.setMarginEnd(0);
}
params.leftMargin = drawer.mActivity.getResources().getDimensionPixelSize(R.dimen.material_drawer_margin);
if (Build.VERSION.SDK_INT >= 17) {
params.setMarginEnd(drawer.mActivity.getResources().getDimensionPixelSize(R.dimen.material_drawer_margin));
}
}
if (drawer.mDisplayBelowStatusBar != null && drawer.mDisplayBelowStatusBar && Build.VERSION.SDK_INT >= 19) {
params.topMargin = UIUtils.getStatusBarHeight(drawer.mActivity, true);
}
if (drawer.mDrawerWidth > -1) {
params.width = drawer.mDrawerWidth;
} else {
params.width = DrawerUIUtils.getOptimalDrawerWidth(drawer.mActivity);
}
}
return params;
}
示例7: bindView
import com.mikepenz.materialdrawer.util.DrawerUIUtils; //导入依赖的package包/类
@Override
public void bindView(RecyclerView.ViewHolder holder) {
Context ctx = holder.itemView.getContext();
ViewHolder viewHolder = (ViewHolder) holder;
viewHolder.itemView.setId(getIdentifier());
viewHolder.itemView.setSelected(isSelected());
viewHolder.itemView.setTag(this);
int selectedColor = getSelectedColor(ctx);
int color = getColor(ctx);
int selectedTextColor = getSelectedTextColor(ctx);
int iconColor = getIconColor(ctx);
int selectedIconColor = getSelectedIconColor(ctx);
UIUtils.setBackground(viewHolder.view, DrawerUIUtils.getSelectableBackground(ctx, selectedColor));
StringHolder.applyTo(this.getName(), viewHolder.name);
StringHolder.applyToOrHide(this.getDescription(), viewHolder.description);
viewHolder.name.setTextColor(getTextColorStateList(color, selectedTextColor));
ColorHolder.applyToOr(getDescriptionTextColor(), viewHolder.description, getTextColorStateList(color, selectedTextColor));
if (getTypeface() != null) {
viewHolder.name.setTypeface(getTypeface());
viewHolder.description.setTypeface(getTypeface());
}
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);
ImageHolder.applyTo(expanderIcon, viewHolder.expander);
}
示例8: bindViewHelper
import com.mikepenz.materialdrawer.util.DrawerUIUtils; //导入依赖的package包/类
/**
* a helper method to have the logic for all secondaryDrawerItems only once
*
* @param viewHolder
*/
protected void bindViewHelper(CustomBaseViewHolder viewHolder) {
Context ctx = viewHolder.itemView.getContext();
//set the identifier from the drawerItem here. It can be used to run tests
viewHolder.itemView.setId(hashCode());
//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, UIUtils.getSelectableBackground(ctx, selectedColor, true));
//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());
}
//we make sure we reset the image first before setting the new one in case there is an empty one
DrawerImageLoader.getInstance().cancelImage(viewHolder.icon);
viewHolder.icon.setImageBitmap(null);
//get the drawables for our icon and set it
ImageHolder.applyTo(icon, viewHolder.icon, "customUrlItem");
//for android API 17 --> Padding not applied via xml
DrawerUIUtils.setDrawerVerticalPadding(viewHolder.view);
}
示例9: bindViewHelper
import com.mikepenz.materialdrawer.util.DrawerUIUtils; //导入依赖的package包/类
/**
* 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(hashCode());
//set the item selected if it is
viewHolder.itemView.setSelected(isSelected());
//set the item enabled if it is
viewHolder.itemView.setEnabled(isEnabled());
//
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);
ColorStateList selectedTextColor = getTextColorStateList(color, 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, UIUtils.getSelectableBackground(ctx, selectedColor, true));
//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(selectedTextColor);
//set the description text color
ColorHolder.applyToOr(getDescriptionTextColor(), viewHolder.description, 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);
}
示例10: bindViewHelper
import com.mikepenz.materialdrawer.util.DrawerUIUtils; //导入依赖的package包/类
/**
* 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);
}
示例11: bindView
import com.mikepenz.materialdrawer.util.DrawerUIUtils; //导入依赖的package包/类
@Override
public void bindView(RecyclerView.ViewHolder holder) {
Context ctx = holder.itemView.getContext();
//get our viewHolder
ViewHolder viewHolder = (ViewHolder) holder;
//set a different height for this item
if (mCustomHeight != null) {
RecyclerView.LayoutParams lp = (RecyclerView.LayoutParams) viewHolder.itemView.getLayoutParams();
lp.height = mCustomHeight.asPixel(ctx);
viewHolder.itemView.setLayoutParams(lp);
}
//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);
}
示例12: bindViewHelper
import com.mikepenz.materialdrawer.util.DrawerUIUtils; //导入依赖的package包/类
/**
* 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);
}
示例13: bindView
import com.mikepenz.materialdrawer.util.DrawerUIUtils; //导入依赖的package包/类
@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);
}