Class PowerMenu.Builder
-
- All Implemented Interfaces:
public class PowerMenu.Builder extends AbstractMenuBuilder
Builder class for creating PowerMenu.
-
-
Constructor Summary
Constructors Constructor Description PowerMenu.Builder(Context context)Builder class for creating PowerMenu.
-
Method Summary
Modifier and Type Method Description PowerMenu.BuildersetLifecycleOwner(@NonNull() LifecycleOwner lifecycleOwner)sets the LifecycleOwner for dismissing automatically when the LifecycleOwner is destroyed. PowerMenu.BuildersetShowBackground(boolean show)sets the visibility of the background popup. PowerMenu.BuildersetOnMenuItemClickListener(OnMenuItemClickListener<PowerMenuItem> menuItemClickListener)sets the OnMenuItemClickListener to the popup. PowerMenu.BuildersetOnBackgroundClickListener(View.OnClickListener onBackgroundClickListener)sets the View.OnClickListener to the popup. PowerMenu.BuildersetOnDismissListener(OnDismissedListener onDismissListener)sets the OnDismissedListener to the popup. PowerMenu.BuildersetHeaderView(@LayoutRes() int headerView)sets the header view by layout resource. PowerMenu.BuildersetHeaderView(View headerView)sets the header view by layout view. PowerMenu.BuildersetFooterView(@LayoutRes() int footerView)sets the footer view by layout resource. PowerMenu.BuildersetFooterView(View footerView)sets the footer view by layout view. PowerMenu.BuildersetAnimation(@NonNull() MenuAnimation menuAnimation)sets the menu animation to the popup. PowerMenu.BuildersetAnimationStyle(@StyleRes() int style)sets the customized menu animation using resource. PowerMenu.BuildersetMenuRadius(@Px() float radius)sets the corner radius of the popup menu. PowerMenu.BuildersetMenuShadow(float shadow)sets the shadow of the popup menu. PowerMenu.BuildersetWidth(@Px() int width)sets the width size of the popup menu. PowerMenu.BuildersetHeight(@Px() int height)sets the height size of the popup menu. PowerMenu.BuildersetSize(@Px() int width, @Px() int height)sets the width and height size of the popup menu. PowerMenu.BuildersetPadding(@Px() int padding)sets a padding size of the popup menu. PowerMenu.BuildersetTextColorResource(@ColorRes() int color)sets the content text color of the popup menu item. PowerMenu.BuildersetIconColor(@ColorInt() int iconColor)sets an icon color of the menu item. PowerMenu.BuildersetIconSize(@Dp() int iconSize)sets an icon size of the menu item. PowerMenu.BuildersetIconPadding(@Dp() int iconPadding)sets a padding value between icon and menu item. PowerMenu.BuildersetMenuColorResource(@ColorRes() int color)sets the normal menu item background color. PowerMenu.BuildersetSelectedTextColorResource(@ColorRes() int color)sets the selected menu item text color. PowerMenu.BuildersetSelectedMenuColorResource(@ColorRes() int color)sets the selected menu item background color. PowerMenu.BuildersetDividerHeight(@Px() int height)sets the divider height between the menu items. PowerMenu.BuildersetDivider(Drawable divider)sets the divider Drawable between the menu items. PowerMenu.BuildersetBackgroundColor(@ColorInt() int color)sets the color of the background popup. PowerMenu.BuildersetBackgroundColorResource(@ColorRes() int color)sets the color of the background popup. PowerMenu.BuildersetBackgroundAlpha(@FloatRange(from = 0.0, to = 1.0) float alpha)sets the alpha of the background popup. PowerMenu.BuildersetBackgroundSystemUiVisibility(int visibility)sets the system UI visibility of the background popup. PowerMenu.BuildersetFocusable(boolean focusable)sets the focusability of the popup menu. PowerMenu.BuildersetSelected(int position)sets the initialized selected effect menu item position. PowerMenu.BuildersetIsClipping(boolean isClipping)sets the clipping or not of the popup menu. PowerMenu.BuildersetAutoDismiss(boolean autoDismiss)sets the dismissing automatically when the menu item is clicked. PowerMenu.BuildersetDismissIfShowAgain(boolean dismissIfShowAgain)sets the dismiss action if already popup is showing. PowerMenu.BuilderaddItem(PowerMenuItem item)adds an PowerMenuItem item to the popup menu list. PowerMenu.BuilderaddItem(int position, PowerMenuItem item)adds an PowerMenuItem item to the popup menu list at position. PowerMenu.BuilderaddItemList(List<PowerMenuItem> itemList)adds a list of the PowerMenuItem item to the popup menu list. PowerMenu.BuildersetPreferenceName(@NonNull() String preferenceName)sets the preference name of the popup menu. PowerMenu.BuildersetInitializeRule(@NonNull() Lifecycle.Event event, int defaultPosition)sets the initialization rule of the recovering persisted position. PowerMenu.BuildersetCircularEffect(@NonNull() CircularEffect circularEffect)sets the circular revealed effect using CircularEffect. PowerMenu.BuildersetIsMaterial(Boolean isMaterial)sets the menu layout should be composed of material components. PowerMenubuild()PowerMenu.BuildersetTextColor(@ColorInt() int color)sets the content text color of the popup menu item. PowerMenu.BuildersetTextSize(@Sp() int size)sets the content text size of the popup menu item. PowerMenu.BuildersetTextGravity(int gravity)sets the content text Gravity of the popup menu item. PowerMenu.BuildersetTextTypeface(@NonNull() Typeface typeface)sets the content text Typeface of the popup menu item. PowerMenu.BuildersetMenuColor(@ColorInt() int color)sets the normal menu item background color. PowerMenu.BuildersetSelectedTextColor(@ColorInt() int color)sets the selected menu item text color. PowerMenu.BuildersetSelectedMenuColor(@ColorInt() int color)sets the selected menu item background color. PowerMenu.BuildersetSelectedEffect(boolean effect)sets true or false of the menu item selected effect -
-
Method Detail
-
setLifecycleOwner
PowerMenu.Builder setLifecycleOwner(@NonNull() LifecycleOwner lifecycleOwner)
sets the LifecycleOwner for dismissing automatically when the LifecycleOwner is destroyed. It will prevents memory leak.
- Parameters:
lifecycleOwner- lifecycle owner
-
setShowBackground
PowerMenu.Builder setShowBackground(boolean show)
sets the visibility of the background popup.
- Parameters:
show- visibility of the background popup.
-
setOnMenuItemClickListener
PowerMenu.Builder setOnMenuItemClickListener(OnMenuItemClickListener<PowerMenuItem> menuItemClickListener)
sets the OnMenuItemClickListener to the popup.
- Parameters:
menuItemClickListener- OnMenuItemClickListener interface.
-
setOnBackgroundClickListener
PowerMenu.Builder setOnBackgroundClickListener(View.OnClickListener onBackgroundClickListener)
sets the View.OnClickListener to the popup.
- Parameters:
onBackgroundClickListener- View.OnClickListener interface.
-
setOnDismissListener
PowerMenu.Builder setOnDismissListener(OnDismissedListener onDismissListener)
sets the OnDismissedListener to the popup.
- Parameters:
onDismissListener- OnDismissedListener interface.
-
setHeaderView
PowerMenu.Builder setHeaderView(@LayoutRes() int headerView)
sets the header view by layout resource.
- Parameters:
headerView- layout resource
-
setHeaderView
PowerMenu.Builder setHeaderView(View headerView)
sets the header view by layout view.
- Parameters:
headerView- header view.
-
setFooterView
PowerMenu.Builder setFooterView(@LayoutRes() int footerView)
sets the footer view by layout resource.
- Parameters:
footerView- footer view.
-
setFooterView
PowerMenu.Builder setFooterView(View footerView)
sets the footer view by layout view.
- Parameters:
footerView- footer view.
-
setAnimation
PowerMenu.Builder setAnimation(@NonNull() MenuAnimation menuAnimation)
sets the menu animation to the popup.
- Parameters:
menuAnimation- animation.
-
setAnimationStyle
PowerMenu.Builder setAnimationStyle(@StyleRes() int style)
sets the customized menu animation using resource.
- Parameters:
style- animation resource.
-
setMenuRadius
PowerMenu.Builder setMenuRadius(@Px() float radius)
sets the corner radius of the popup menu.
- Parameters:
radius- corner radius.
-
setMenuShadow
PowerMenu.Builder setMenuShadow(float shadow)
sets the shadow of the popup menu.
- Parameters:
shadow- popup shadow.
-
setWidth
PowerMenu.Builder setWidth(@Px() int width)
sets the width size of the popup menu.
- Parameters:
width- width size.
-
setHeight
PowerMenu.Builder setHeight(@Px() int height)
sets the height size of the popup menu.
- Parameters:
height- height size.
-
setSize
PowerMenu.Builder setSize(@Px() int width, @Px() int height)
sets the width and height size of the popup menu.
- Parameters:
width- width size.height- height size.
-
setPadding
PowerMenu.Builder setPadding(@Px() int padding)
sets a padding size of the popup menu.
- Parameters:
padding- padding size.
-
setTextColorResource
PowerMenu.Builder setTextColorResource(@ColorRes() int color)
sets the content text color of the popup menu item.
- Parameters:
color- menu item's content text color by resource.
-
setIconColor
PowerMenu.Builder setIconColor(@ColorInt() int iconColor)
sets an icon color of the menu item.
- Parameters:
iconColor- icon color of the menu item.
-
setIconSize
PowerMenu.Builder setIconSize(@Dp() int iconSize)
sets an icon size of the menu item.
- Parameters:
iconSize- icon size of the menu item.
-
setIconPadding
PowerMenu.Builder setIconPadding(@Dp() int iconPadding)
sets a padding value between icon and menu item.
- Parameters:
iconPadding- padding value between icon and menu item.
-
setMenuColorResource
PowerMenu.Builder setMenuColorResource(@ColorRes() int color)
sets the normal menu item background color.
- Parameters:
color- normal menu item background color by resource.
-
setSelectedTextColorResource
PowerMenu.Builder setSelectedTextColorResource(@ColorRes() int color)
sets the selected menu item text color.
- Parameters:
color- selected menu item text color by resource.
-
setSelectedMenuColorResource
PowerMenu.Builder setSelectedMenuColorResource(@ColorRes() int color)
sets the selected menu item background color.
- Parameters:
color- selected menu item background color by resource.
-
setDividerHeight
PowerMenu.Builder setDividerHeight(@Px() int height)
sets the divider height between the menu items.
- Parameters:
height- divider height between the menu items.
-
setDivider
PowerMenu.Builder setDivider(Drawable divider)
sets the divider Drawable between the menu items.
- Parameters:
divider- divider Drawable between the menu items.
-
setBackgroundColor
PowerMenu.Builder setBackgroundColor(@ColorInt() int color)
sets the color of the background popup.
- Parameters:
color- color of the background popup.
-
setBackgroundColorResource
PowerMenu.Builder setBackgroundColorResource(@ColorRes() int color)
sets the color of the background popup.
- Parameters:
color- color of the background popup by resource.
-
setBackgroundAlpha
PowerMenu.Builder setBackgroundAlpha(@FloatRange(from = 0.0, to = 1.0) float alpha)
sets the alpha of the background popup.
- Parameters:
alpha- alpha of the background popup.
-
setBackgroundSystemUiVisibility
PowerMenu.Builder setBackgroundSystemUiVisibility(int visibility)
sets the system UI visibility of the background popup.
- Parameters:
visibility- system UI visibility of the background popup.
-
setFocusable
PowerMenu.Builder setFocusable(boolean focusable)
sets the focusability of the popup menu.
- Parameters:
focusable- focusability of the popup menu.
-
setSelected
PowerMenu.Builder setSelected(int position)
sets the initialized selected effect menu item position.
- Parameters:
position- initialized selected effect menu item position.
-
setIsClipping
PowerMenu.Builder setIsClipping(boolean isClipping)
sets the clipping or not of the popup menu.
- Parameters:
isClipping- clipping or not of the popup menu.
-
setAutoDismiss
PowerMenu.Builder setAutoDismiss(boolean autoDismiss)
sets the dismissing automatically when the menu item is clicked.
- Parameters:
autoDismiss- dismissing automatically when the menu item is clicked.
-
setDismissIfShowAgain
PowerMenu.Builder setDismissIfShowAgain(boolean dismissIfShowAgain)
sets the dismiss action if already popup is showing.
Recommend to use with setFocusable(true) and setShowBackground(false).
- Parameters:
dismissIfShowAgain- dismiss if already popup is showing.
-
addItem
PowerMenu.Builder addItem(PowerMenuItem item)
adds an PowerMenuItem item to the popup menu list.
- Parameters:
item- PowerMenuItem item.
-
addItem
PowerMenu.Builder addItem(int position, PowerMenuItem item)
adds an PowerMenuItem item to the popup menu list at position.
- Parameters:
position- specific position.item- PowerMenuItem item.
-
addItemList
PowerMenu.Builder addItemList(List<PowerMenuItem> itemList)
adds a list of the PowerMenuItem item to the popup menu list.
- Parameters:
itemList- list of the PowerMenuItem.
-
setPreferenceName
PowerMenu.Builder setPreferenceName(@NonNull() String preferenceName)
sets the preference name of the popup menu. For persistence the clicked item position. If the preference name is set, the persisted position item will be clicked automatically when the popup menu initialized. This option should be used with setInitializeRule and setLifecycleOwner.
- Parameters:
preferenceName- name of the popup menu.
-
setInitializeRule
PowerMenu.Builder setInitializeRule(@NonNull() Lifecycle.Event event, int defaultPosition)
sets the initialization rule of the recovering persisted position.
- Parameters:
event- when should be recovered.defaultPosition- default selected position.
-
setCircularEffect
PowerMenu.Builder setCircularEffect(@NonNull() CircularEffect circularEffect)
sets the circular revealed effect using CircularEffect.
- Parameters:
circularEffect- circular revealed effect using CircularEffect.
-
setIsMaterial
PowerMenu.Builder setIsMaterial(Boolean isMaterial)
sets the menu layout should be composed of material components.
- Parameters:
isMaterial- is material layout or not.
-
setTextColor
PowerMenu.Builder setTextColor(@ColorInt() int color)
sets the content text color of the popup menu item.
- Parameters:
color- menu item's content text color.
-
setTextSize
PowerMenu.Builder setTextSize(@Sp() int size)
sets the content text size of the popup menu item.
- Parameters:
size- menu item's content text size.
-
setTextGravity
PowerMenu.Builder setTextGravity(int gravity)
sets the content text Gravity of the popup menu item.
- Parameters:
gravity- menu item's content text gravity.
-
setTextTypeface
PowerMenu.Builder setTextTypeface(@NonNull() Typeface typeface)
sets the content text Typeface of the popup menu item.
- Parameters:
typeface- menu item's content text typeface.
-
setMenuColor
PowerMenu.Builder setMenuColor(@ColorInt() int color)
sets the normal menu item background color.
- Parameters:
color- normal menu item background color.
-
setSelectedTextColor
PowerMenu.Builder setSelectedTextColor(@ColorInt() int color)
sets the selected menu item text color.
- Parameters:
color- selected menu item text color.
-
setSelectedMenuColor
PowerMenu.Builder setSelectedMenuColor(@ColorInt() int color)
sets the selected menu item background color.
- Parameters:
color- selected menu item background color.
-
setSelectedEffect
PowerMenu.Builder setSelectedEffect(boolean effect)
sets true or false of the menu item selected effect
- Parameters:
effect- the menu item selected effect.
-
-
-
-