Class CustomPowerMenu.Builder
-
- All Implemented Interfaces:
public class CustomPowerMenu.Builder<T, E extends MenuBaseAdapter<T>> extends AbstractMenuBuilder
Builder class for creating CustomPowerMenu.
-
-
Constructor Summary
Constructors Constructor Description CustomPowerMenu.Builder(Context context, E adapter)
-
Method Summary
Modifier and Type Method Description CustomPowerMenu.Builder<T, E>setLifecycleOwner(@NonNull() LifecycleOwner lifecycleOwner)sets the LifecycleOwner for dismissing automatically when the LifecycleOwner is destroyed. CustomPowerMenu.Builder<T, E>setShowBackground(boolean show)sets the visibility of the background popup. CustomPowerMenu.Builder<T, E>setOnMenuItemClickListener(Object menuItemClickListener)sets the OnMenuItemClickListener to the popup. CustomPowerMenu.Builder<T, E>setOnBackgroundClickListener(View.OnClickListener onBackgroundClickListener)sets the View.OnClickListener to the popup. CustomPowerMenu.Builder<T, E>setOnDismissListener(OnDismissedListener onDismissListener)sets the OnDismissedListener to the popup. CustomPowerMenu.Builder<T, E>setHeaderView(@LayoutRes() int headerView)sets the header view by layout resource. CustomPowerMenu.Builder<T, E>setHeaderView(View headerView)sets the header view by layout view. CustomPowerMenu.Builder<T, E>setFooterView(@LayoutRes() int footerView)sets the footer view by layout resource. CustomPowerMenu.Builder<T, E>setFooterView(View footerView)sets the footer view by layout view. CustomPowerMenu.Builder<T, E>setAnimation(@NonNull() MenuAnimation menuAnimation)sets the menu animation to the popup. CustomPowerMenu.Builder<T, E>setAnimationStyle(@StyleRes() int style)sets the customized menu animation using resource. CustomPowerMenu.Builder<T, E>setMenuRadius(@Px() float radius)sets the corner radius of the popup menu. CustomPowerMenu.Builder<T, E>setMenuShadow(@Px() float shadow)sets the shadow of the popup menu. CustomPowerMenu.Builder<T, E>setWidth(@Px() int width)sets the width size of the popup menu. CustomPowerMenu.Builder<T, E>setHeight(@Px() int height)sets the height size of the popup menu. CustomPowerMenu.Builder<T, E>setPadding(@Px() int padding)sets a padding size of the popup menu. CustomPowerMenu.Builder<T, E>setSize(@Px() int width, @Px() int height)sets the width and height size of the popup menu. CustomPowerMenu.Builder<T, E>setDividerHeight(@Px() int height)sets the divider height between the menu items. CustomPowerMenu.Builder<T, E>setDivider(Drawable divider)sets the divider Drawable between the menu items. CustomPowerMenu.Builder<T, E>setBackgroundColor(@Px() int color)sets the color of the background popup. CustomPowerMenu.Builder<T, E>setBackgroundColorResource(@ColorRes() int color)sets the color of the background popup. CustomPowerMenu.Builder<T, E>setBackgroundAlpha(@FloatRange(from = 0.0, to = 1.0) float alpha)sets the alpha of the background popup. CustomPowerMenu.Builder<T, E>setBackgroundSystemUiVisibility(int visibility)sets the system UI visibility of the background popup. CustomPowerMenu.Builder<T, E>setFocusable(boolean focusable)sets the focusability of the popup menu. CustomPowerMenu.Builder<T, E>setSelected(int position)sets the initialized selected effect menu item position. CustomPowerMenu.Builder<T, E>setIsClipping(boolean isClipping)sets the clipping or not of the popup menu. CustomPowerMenu.Builder<T, E>setDismissIfShowAgain(boolean dismissIfShowAgain)sets the dismiss action if already popup is showing. CustomPowerMenu.Builder<T, E>setAutoDismiss(boolean autoDismiss)sets the dismissing automatically when the menu item is clicked. CustomPowerMenu.Builder<T, E>addItem(Object item)adds an PowerMenuItem item to the popup menu list. CustomPowerMenu.Builder<T, E>addItem(int position, Object item)adds an PowerMenuItem item to the popup menu list at position. CustomPowerMenu.Builder<T, E>addItemList(List<T> itemList)adds a list of the PowerMenuItem item to the popup menu list. CustomPowerMenu.Builder<T, E>setPreferenceName(@NonNull() String preferenceName)sets the preference name of the popup menu. CustomPowerMenu.Builder<T, E>setInitializeRule(@NonNull() Lifecycle.Event event, int defaultPosition)sets the initialization rule of the recovering persisted position. CustomPowerMenu.Builder<T, E>setCircularEffect(@NonNull() CircularEffect circularEffect)sets the circular revealed effect using CircularEffect. CustomPowerMenu.Builder<T, E>setIsMaterial(Boolean isMaterial)sets the menu layout should be composed of material components. CustomPowerMenu<T, E>build()-
-
Method Detail
-
setLifecycleOwner
CustomPowerMenu.Builder<T, E> 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
CustomPowerMenu.Builder<T, E> setShowBackground(boolean show)
sets the visibility of the background popup.
- Parameters:
show- visibility of the background popup.
-
setOnMenuItemClickListener
CustomPowerMenu.Builder<T, E> setOnMenuItemClickListener(Object menuItemClickListener)
sets the OnMenuItemClickListener to the popup.
- Parameters:
menuItemClickListener- OnMenuItemClickListener interface.
-
setOnBackgroundClickListener
CustomPowerMenu.Builder<T, E> setOnBackgroundClickListener(View.OnClickListener onBackgroundClickListener)
sets the View.OnClickListener to the popup.
- Parameters:
onBackgroundClickListener- View.OnClickListener interface.
-
setOnDismissListener
CustomPowerMenu.Builder<T, E> setOnDismissListener(OnDismissedListener onDismissListener)
sets the OnDismissedListener to the popup.
- Parameters:
onDismissListener- OnDismissedListener interface.
-
setHeaderView
CustomPowerMenu.Builder<T, E> setHeaderView(@LayoutRes() int headerView)
sets the header view by layout resource.
- Parameters:
headerView- layout resource
-
setHeaderView
CustomPowerMenu.Builder<T, E> setHeaderView(View headerView)
sets the header view by layout view.
- Parameters:
headerView- header view.
-
setFooterView
CustomPowerMenu.Builder<T, E> setFooterView(@LayoutRes() int footerView)
sets the footer view by layout resource.
- Parameters:
footerView- footer view.
-
setFooterView
CustomPowerMenu.Builder<T, E> setFooterView(View footerView)
sets the footer view by layout view.
- Parameters:
footerView- footer view.
-
setAnimation
CustomPowerMenu.Builder<T, E> setAnimation(@NonNull() MenuAnimation menuAnimation)
sets the menu animation to the popup.
- Parameters:
menuAnimation- animation.
-
setAnimationStyle
CustomPowerMenu.Builder<T, E> setAnimationStyle(@StyleRes() int style)
sets the customized menu animation using resource.
- Parameters:
style- animation resource.
-
setMenuRadius
CustomPowerMenu.Builder<T, E> setMenuRadius(@Px() float radius)
sets the corner radius of the popup menu.
- Parameters:
radius- corner radius.
-
setMenuShadow
CustomPowerMenu.Builder<T, E> setMenuShadow(@Px() float shadow)
sets the shadow of the popup menu.
- Parameters:
shadow- popup shadow.
-
setWidth
CustomPowerMenu.Builder<T, E> setWidth(@Px() int width)
sets the width size of the popup menu.
- Parameters:
width- width size.
-
setHeight
CustomPowerMenu.Builder<T, E> setHeight(@Px() int height)
sets the height size of the popup menu.
- Parameters:
height- height size.
-
setPadding
CustomPowerMenu.Builder<T, E> setPadding(@Px() int padding)
sets a padding size of the popup menu.
- Parameters:
padding- padding size.
-
setSize
CustomPowerMenu.Builder<T, E> setSize(@Px() int width, @Px() int height)
sets the width and height size of the popup menu.
- Parameters:
width- width size.height- height size.
-
setDividerHeight
CustomPowerMenu.Builder<T, E> setDividerHeight(@Px() int height)
sets the divider height between the menu items.
- Parameters:
height- divider height between the menu items.
-
setDivider
CustomPowerMenu.Builder<T, E> setDivider(Drawable divider)
sets the divider Drawable between the menu items.
- Parameters:
divider- divider Drawable between the menu items.
-
setBackgroundColor
CustomPowerMenu.Builder<T, E> setBackgroundColor(@Px() int color)
sets the color of the background popup.
- Parameters:
color- color of the background popup.
-
setBackgroundColorResource
CustomPowerMenu.Builder<T, E> setBackgroundColorResource(@ColorRes() int color)
sets the color of the background popup.
- Parameters:
color- color of the background popup by resource.
-
setBackgroundAlpha
CustomPowerMenu.Builder<T, E> 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
CustomPowerMenu.Builder<T, E> setBackgroundSystemUiVisibility(int visibility)
sets the system UI visibility of the background popup.
- Parameters:
visibility- system UI visibility of the background popup.
-
setFocusable
CustomPowerMenu.Builder<T, E> setFocusable(boolean focusable)
sets the focusability of the popup menu.
- Parameters:
focusable- focusability of the popup menu.
-
setSelected
CustomPowerMenu.Builder<T, E> setSelected(int position)
sets the initialized selected effect menu item position.
- Parameters:
position- initialized selected effect menu item position.
-
setIsClipping
CustomPowerMenu.Builder<T, E> setIsClipping(boolean isClipping)
sets the clipping or not of the popup menu.
- Parameters:
isClipping- clipping or not of the popup menu.
-
setDismissIfShowAgain
CustomPowerMenu.Builder<T, E> 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.
-
setAutoDismiss
CustomPowerMenu.Builder<T, E> setAutoDismiss(boolean autoDismiss)
sets the dismissing automatically when the menu item is clicked.
- Parameters:
autoDismiss- dismissing automatically when the menu item is clicked.
-
addItem
CustomPowerMenu.Builder<T, E> addItem(Object item)
adds an PowerMenuItem item to the popup menu list.
- Parameters:
item- PowerMenuItem item.
-
addItem
CustomPowerMenu.Builder<T, E> addItem(int position, Object item)
adds an PowerMenuItem item to the popup menu list at position.
- Parameters:
position- specific position.item- PowerMenuItem item.
-
addItemList
CustomPowerMenu.Builder<T, E> addItemList(List<T> itemList)
adds a list of the PowerMenuItem item to the popup menu list.
- Parameters:
itemList- list of the PowerMenuItem.
-
setPreferenceName
CustomPowerMenu.Builder<T, E> 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
CustomPowerMenu.Builder<T, E> 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
CustomPowerMenu.Builder<T, E> setCircularEffect(@NonNull() CircularEffect circularEffect)
sets the circular revealed effect using CircularEffect.
- Parameters:
circularEffect- circular revealed effect using CircularEffect.
-
setIsMaterial
CustomPowerMenu.Builder<T, E> setIsMaterial(Boolean isMaterial)
sets the menu layout should be composed of material components.
- Parameters:
isMaterial- is material layout or not.
-
build
CustomPowerMenu<T, E> build()
-
-
-
-