本文整理汇总了Java中com.mikepenz.materialize.util.UIUtils类的典型用法代码示例。如果您正苦于以下问题:Java UIUtils类的具体用法?Java UIUtils怎么用?Java UIUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UIUtils类属于com.mikepenz.materialize.util包,在下文中一共展示了UIUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: bindView
import com.mikepenz.materialize.util.UIUtils; //导入依赖的package包/类
@Override
public void bindView(ViewHolder viewHolder, List<Object> payloads) {
super.bindView(viewHolder, payloads);
//get the context
Context ctx = viewHolder.itemView.getContext();
//set the background for the item
UIUtils.setBackground(viewHolder.view, FastAdapterUIUtils.getSelectableBackground(ctx, Color.RED, true));
//set the text for the name
StringHolder.applyTo(name, viewHolder.name);
//set the text for the description or hide
int selectedSubItems = 0;
if (mSubSelectionProvider != null)
selectedSubItems = mSubSelectionProvider.getSelectedSubItems();
StringHolder descr = new StringHolder(description.getText());
if (selectedSubItems > 0)
descr.setText("Selected children: " + selectedSubItems + "/" + getSubItems().size());
StringHolder.applyToOrHide(descr, viewHolder.description);
viewHolder.description.setTextColor(selectedSubItems == 0 ? Color.BLACK : Color.RED);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:HeaderSelectionItem.java
示例2: bindView
import com.mikepenz.materialize.util.UIUtils; //导入依赖的package包/类
/**
* binds the data of this item onto the viewHolder
*
* @param viewHolder the viewHolder of this item
*/
@Override
public void bindView(SimpleImageItem.ViewHolder viewHolder, List<Object> payloads) {
super.bindView(viewHolder, payloads);
//get the context
Context ctx = viewHolder.itemView.getContext();
//define our data for the view
viewHolder.imageName.setText(mName);
viewHolder.imageDescription.setText(mDescription);
viewHolder.imageView.setImageBitmap(null);
//set the background for the item
int color = UIUtils.getThemeColor(ctx, R.attr.colorPrimary);
viewHolder.view.setForeground(FastAdapterUIUtils.getSelectablePressedBackground(ctx, FastAdapterUIUtils.adjustAlpha(color, 100), 50, true));
//load glide
Glide.clear(viewHolder.imageView);
Glide.with(ctx).load(mImageUrl).animate(R.anim.alpha_on).into(viewHolder.imageView);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:SimpleImageItem.java
示例3: bindView
import com.mikepenz.materialize.util.UIUtils; //导入依赖的package包/类
/**
* binds the data of this item onto the viewHolder
*
* @param viewHolder the viewHolder of this item
*/
@Override
public void bindView(ViewHolder viewHolder, List<Object> payloads) {
super.bindView(viewHolder, payloads);
//get the context
Context ctx = viewHolder.itemView.getContext();
//set the background for the item
UIUtils.setBackground(viewHolder.view, FastAdapterUIUtils.getSelectableBackground(ctx, Color.RED, true));
//set the text for the name
StringHolder.applyTo(name, viewHolder.name);
//set the text for the description or hide
StringHolder.applyToOrHide(description, viewHolder.description);
if (isExpanded()) {
ViewCompat.setRotation(viewHolder.icon, 0);
} else {
ViewCompat.setRotation(viewHolder.icon, 180);
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:SimpleSubExpandableItem.java
示例4: FooterViewHolder
import com.mikepenz.materialize.util.UIUtils; //导入依赖的package包/类
FooterViewHolder(View itemView) {
super(itemView);
mSpace = itemView;
mPrefs.enableTransparentNavBar().asObservable()
.map(enable -> enable ?
UIUtils.getNavigationBarHeight(itemView.getContext()) : 0)
.subscribe(height -> {
ViewGroup.LayoutParams layoutParams = mSpace.getLayoutParams();
if (layoutParams == null) {
layoutParams = new ViewGroup.LayoutParams(MATCH_PARENT, height);
} else {
layoutParams.height = height;
}
mSpace.setLayoutParams(layoutParams);
});
}
开发者ID:sorcererXW,项目名称:SorceryIconPack,代码行数:17,代码来源:IconAdapter.java
示例5: bindView
import com.mikepenz.materialize.util.UIUtils; //导入依赖的package包/类
@Override
public void bindView(ViewHolder viewHolder) {
Context ctx = viewHolder.itemView.getContext();
//set the identifier from the drawerItem here. It can be used to run tests
viewHolder.itemView.setId(hashCode());
//define how the divider should look like
viewHolder.view.setClickable(false);
viewHolder.view.setEnabled(false);
viewHolder.view.setMinimumHeight(1);
ViewCompat.setImportantForAccessibility(viewHolder.view,
ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO);
//set the color for the divider
viewHolder.divider.setBackgroundColor(UIUtils.getThemeColorFromAttrOrRes(ctx, com.mikepenz.materialdrawer.R.attr.material_drawer_divider, com.mikepenz.materialdrawer.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);
}
开发者ID:LeMinhAn,项目名称:MaterialDrawer,代码行数:21,代码来源:AccountDividerDrawerItem.java
示例6: style
import com.mikepenz.materialize.util.UIUtils; //导入依赖的package包/类
public void style(TextView badgeTextView, ColorStateList colorStateList) {
Context ctx = badgeTextView.getContext();
//set background for badge
if (mBadgeBackground == null) {
UIUtils.setBackground(badgeTextView, new BadgeDrawableBuilder(this).build(ctx));
} else {
UIUtils.setBackground(badgeTextView, mBadgeBackground);
}
//set the badge text color
if (mTextColor != null) {
ColorHolder.applyToOr(mTextColor, badgeTextView, null);
} else if (colorStateList != null) {
badgeTextView.setTextColor(colorStateList);
}
//set the padding
int paddingLeftRight = mPaddingLeftRight.asPixel(ctx);
int paddingTopBottom = mPaddingTopBottom.asPixel(ctx);
badgeTextView.setPadding(paddingLeftRight, paddingTopBottom, paddingLeftRight, paddingTopBottom);
//set the min width
badgeTextView.setMinWidth(mMinWidth.asPixel(ctx));
}
开发者ID:LeMinhAn,项目名称:MaterialDrawer,代码行数:25,代码来源:BadgeStyle.java
示例7: decideIcon
import com.mikepenz.materialize.util.UIUtils; //导入依赖的package包/类
/**
* this only handles Drawables
*
* @param ctx
* @param iconColor
* @param tint
* @return
*/
public Drawable decideIcon(Context ctx, int iconColor, boolean tint, int paddingDp) {
Drawable icon = getIcon();
if (mIIcon != null) {
icon = new IconicsDrawable(ctx, mIIcon).color(iconColor).sizeDp(24).paddingDp(paddingDp);
} else if (getIconRes() != -1) {
icon = UIUtils.getCompatDrawable(ctx, getIconRes());
} else if (getUri() != null) {
try {
InputStream inputStream = ctx.getContentResolver().openInputStream(getUri());
icon = Drawable.createFromStream(inputStream, getUri().toString());
} catch (FileNotFoundException e) {
//no need to handle this
}
}
//if we got an icon AND we have auto tinting enabled AND it is no IIcon, tint it ;)
if (icon != null && tint && mIIcon == null) {
icon = icon.mutate();
icon.setColorFilter(iconColor, PorterDuff.Mode.SRC_IN);
}
return icon;
}
开发者ID:LeMinhAn,项目名称:MaterialDrawer,代码行数:33,代码来源:ImageHolder.java
示例8: build
import com.mikepenz.materialize.util.UIUtils; //导入依赖的package包/类
public StateListDrawable build(Context ctx) {
StateListDrawable stateListDrawable = new StateListDrawable();
GradientDrawable normal = (GradientDrawable) UIUtils.getCompatDrawable(ctx, mStyle.getGradientDrawable());
GradientDrawable selected = (GradientDrawable) normal.getConstantState().newDrawable().mutate();
ColorHolder.applyToOrTransparent(mStyle.getColor(), ctx, normal);
if (mStyle.getColorPressed() == null) {
ColorHolder.applyToOrTransparent(mStyle.getColor(), ctx, selected);
} else {
ColorHolder.applyToOrTransparent(mStyle.getColorPressed(), ctx, selected);
}
if (mStyle.getCorners() != null) {
normal.setCornerRadius(mStyle.getCorners().asPixel(ctx));
selected.setCornerRadius(mStyle.getCorners().asPixel(ctx));
}
stateListDrawable.addState(new int[]{android.R.attr.state_pressed}, selected);
stateListDrawable.addState(StateSet.WILD_CARD, normal);
return stateListDrawable;
}
开发者ID:LeMinhAn,项目名称:MaterialDrawer,代码行数:24,代码来源:BadgeDrawableBuilder.java
示例9: bindView
import com.mikepenz.materialize.util.UIUtils; //导入依赖的package包/类
@Override
public void bindView(ViewHolder viewHolder) {
Context ctx = viewHolder.itemView.getContext();
//set the identifier from the drawerItem here. It can be used to run tests
viewHolder.itemView.setId(hashCode());
//define how the divider should look like
viewHolder.view.setClickable(false);
viewHolder.view.setEnabled(false);
viewHolder.view.setMinimumHeight(1);
ViewCompat.setImportantForAccessibility(viewHolder.view,
ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO);
//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);
}
开发者ID:LeMinhAn,项目名称:MaterialDrawer,代码行数:21,代码来源:DividerDrawerItem.java
示例10: handleSelectionView
import com.mikepenz.materialize.util.UIUtils; //导入依赖的package包/类
/**
* a small helper to handle the selectionView
*
* @param on
*/
private void handleSelectionView(IProfile profile, boolean on) {
if (on) {
if (Build.VERSION.SDK_INT >= 21) {
((FrameLayout) mAccountHeaderContainer).setForeground(UIUtils.getCompatDrawable(mAccountHeaderContainer.getContext(), mAccountHeaderTextSectionBackgroundResource));
mAccountHeaderContainer.setOnClickListener(onSelectionClickListener);
mAccountHeaderContainer.setTag(R.id.material_drawer_profile_header, profile);
} else {
mAccountHeaderTextSection.setBackgroundResource(mAccountHeaderTextSectionBackgroundResource);
mAccountHeaderTextSection.setOnClickListener(onSelectionClickListener);
mAccountHeaderTextSection.setTag(R.id.material_drawer_profile_header, profile);
}
} else {
if (Build.VERSION.SDK_INT >= 21) {
((FrameLayout) mAccountHeaderContainer).setForeground(null);
mAccountHeaderContainer.setOnClickListener(null);
} else {
UIUtils.setBackground(mAccountHeaderTextSection, null);
mAccountHeaderTextSection.setOnClickListener(null);
}
}
}
开发者ID:LeMinhAn,项目名称:MaterialDrawer,代码行数:27,代码来源:AccountHeaderBuilder.java
示例11: buildStickyDrawerItemFooter
import com.mikepenz.materialize.util.UIUtils; //导入依赖的package包/类
/**
* build the sticky footer item view
*
* @return
*/
public static ViewGroup buildStickyDrawerItemFooter(Context ctx, DrawerBuilder drawer, View.OnClickListener onClickListener) {
//create the container view
final LinearLayout linearLayout = new LinearLayout(ctx);
linearLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
linearLayout.setOrientation(LinearLayout.VERTICAL);
//set the background color to the drawer background color (if it has alpha the shadow won't be visible)
linearLayout.setBackgroundColor(UIUtils.getThemeColorFromAttrOrRes(ctx, R.attr.material_drawer_background, R.color.material_drawer_background));
//create the divider
if (drawer.mStickyFooterDivider) {
addStickyFooterDivider(ctx, linearLayout);
}
fillStickyDrawerItemFooter(drawer, linearLayout, onClickListener);
return linearLayout;
}
开发者ID:LeMinhAn,项目名称:MaterialDrawer,代码行数:23,代码来源:DrawerUtils.java
示例12: bindView
import com.mikepenz.materialize.util.UIUtils; //导入依赖的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
holder.itemView.setId(getIdentifier());
//define how the divider should look like
viewHolder.view.setClickable(false);
viewHolder.view.setEnabled(false);
viewHolder.view.setMinimumHeight(1);
ViewCompat.setImportantForAccessibility(viewHolder.view,
ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO);
//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);
}
开发者ID:FreedomZZQ,项目名称:YouJoin-Android,代码行数:24,代码来源:DividerDrawerItem.java
示例13: bindView
import com.mikepenz.materialize.util.UIUtils; //导入依赖的package包/类
/**
* binds the data of this item onto the viewHolder
*
* @param viewHolder the viewHolder of this item
*/
@Override
public void bindView(ViewHolder viewHolder, List<Object> payloads) {
super.bindView(viewHolder, payloads);
//get the context
Context ctx = viewHolder.itemView.getContext();
//set the background for the item
UIUtils.setBackground(viewHolder.view, FastAdapterUIUtils.getSelectableBackground(ctx, Color.RED, true));
//set the text for the name
StringHolder.applyTo(name, viewHolder.name);
//set the text for the description or hide
StringHolder.applyToOrHide(description, viewHolder.description);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:SimpleItem.java
示例14: onCreateView
import com.mikepenz.materialize.util.UIUtils; //导入依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_icon_tab, container, false);
ButterKnife.bind(this, view);
initTabAndPager();
mTabLayout.setTabTextColors(UIUtils.adjustAlpha(Color.WHITE, 204), Color.WHITE);
return view;
}
开发者ID:sorcererXW,项目名称:SorceryIconPack,代码行数:11,代码来源:IconTabFragment.java
示例15: onCreateActionMode
import com.mikepenz.materialize.util.UIUtils; //导入依赖的package包/类
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(UIUtils.getThemeColorFromAttrOrRes(CompactHeaderDrawerActivity.this, R.attr.colorPrimaryDark, R.color.material_drawer_primary_dark));
}
mode.getMenuInflater().inflate(R.menu.cab, menu);
return true;
}
开发者ID:LeMinhAn,项目名称:MaterialDrawer,代码行数:10,代码来源:CompactHeaderDrawerActivity.java
示例16: bindView
import com.mikepenz.materialize.util.UIUtils; //导入依赖的package包/类
@Override
public void bindView(ViewHolder viewHolder) {
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);
}
开发者ID:LeMinhAn,项目名称:MaterialDrawer,代码行数:36,代码来源:SectionDrawerItem.java
示例17: build
import com.mikepenz.materialize.util.UIUtils; //导入依赖的package包/类
public View build() {
//create the container view
LinearLayout linearLayout = new LinearLayout(mContext);
linearLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
linearLayout.setOrientation(LinearLayout.VERTICAL);
//create the divider
if (mDivider) {
LinearLayout divider = new LinearLayout(mContext);
divider.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
divider.setMinimumHeight((int) UIUtils.convertDpToPixel(1, mContext));
divider.setOrientation(LinearLayout.VERTICAL);
divider.setBackgroundColor(UIUtils.getThemeColorFromAttrOrRes(mContext, R.attr.material_drawer_divider, R.color.material_drawer_divider));
linearLayout.addView(divider);
}
//add all drawer items
for (IDrawerItem drawerItem : mDrawerItems) {
View view = drawerItem.generateView(mContext);
view.setTag(drawerItem);
if (drawerItem.isEnabled()) {
view.setBackgroundResource(UIUtils.getSelectableBackgroundRes(mContext));
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mOnDrawerItemClickListener != null) {
mOnDrawerItemClickListener.onItemClick(v, (IDrawerItem) v.getTag());
}
}
});
}
linearLayout.addView(view);
}
return linearLayout;
}
开发者ID:LeMinhAn,项目名称:MaterialDrawer,代码行数:39,代码来源:DrawerItemViewHelper.java
示例18: addStickyFooterDivider
import com.mikepenz.materialize.util.UIUtils; //导入依赖的package包/类
/**
* adds the shadow to the stickyFooter
*
* @param ctx
* @param footerView
*/
private static void addStickyFooterDivider(Context ctx, ViewGroup footerView) {
LinearLayout divider = new LinearLayout(ctx);
LinearLayout.LayoutParams dividerParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
divider.setMinimumHeight((int) UIUtils.convertDpToPixel(1, ctx));
divider.setOrientation(LinearLayout.VERTICAL);
divider.setBackgroundColor(UIUtils.getThemeColorFromAttrOrRes(ctx, R.attr.material_drawer_divider, R.color.material_drawer_divider));
footerView.addView(divider, dividerParams);
}
开发者ID:LeMinhAn,项目名称:MaterialDrawer,代码行数:15,代码来源:DrawerUtils.java
示例19: bindView
import com.mikepenz.materialize.util.UIUtils; //导入依赖的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
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);
}
开发者ID:FreedomZZQ,项目名称:YouJoin-Android,代码行数:34,代码来源:SectionDrawerItem.java
示例20: build
import com.mikepenz.materialize.util.UIUtils; //导入依赖的package包/类
public View build() {
//create the container view
LinearLayout linearLayout = new LinearLayout(mContext);
linearLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
linearLayout.setOrientation(LinearLayout.VERTICAL);
//create the divider
if (mDivider) {
LinearLayout divider = new LinearLayout(mContext);
divider.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
divider.setMinimumHeight((int) UIUtils.convertDpToPixel(1, mContext));
divider.setOrientation(LinearLayout.VERTICAL);
divider.setBackgroundColor(UIUtils.getThemeColorFromAttrOrRes(mContext, R.attr.material_drawer_divider, R.color.material_drawer_divider));
linearLayout.addView(divider);
}
//add all drawer items
for (IDrawerItem drawerItem : mDrawerItems) {
View view = drawerItem.generateView(mContext);
view.setTag(drawerItem);
if (drawerItem.isEnabled()) {
view.setBackgroundResource(DrawerUIUtils.getSelectableBackground(mContext));
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mOnDrawerItemClickListener != null) {
mOnDrawerItemClickListener.onItemClick(v, (IDrawerItem) v.getTag());
}
}
});
}
linearLayout.addView(view);
}
return linearLayout;
}
开发者ID:FreedomZZQ,项目名称:YouJoin-Android,代码行数:39,代码来源:DrawerItemViewHelper.java
注:本文中的com.mikepenz.materialize.util.UIUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论