Class AbstractPowerMenu
-
- All Implemented Interfaces:
-
androidx.lifecycle.DefaultLifecycleObserver,androidx.lifecycle.LifecycleObserver,com.skydoves.powermenu.IMenuItem
public abstract class AbstractPowerMenu<E, T extends MenuBaseAdapter<E>> implements IMenuItem<T>, DefaultLifecycleObserver
AbstractPowerMenu is the abstract class of PowerMenu and CustomPowerMenu.
It implements basically almost things of the PowerMenu.
-
-
Field Summary
Fields Modifier and Type Field Description public CircularEffectcircularEffectpublic final OnMenuItemClickListener<E>onMenuItemClickListener
-
Method Summary
Modifier and Type Method Description CircularEffectgetCircularEffect()gets menu effect. voidsetCircularEffect(@NonNull() CircularEffect circularEffect)sets menu effects for showing popup more dynamically. OnMenuItemClickListener<E>getOnMenuItemClickListener()gets onMenuItemClickListener. voidsetOnMenuItemClickListener(OnMenuItemClickListener<E> menuItemClickListener)sets OnMenuItemClickListener. voidsetLifecycleOwnerFromContext(@NonNull() Context context)sets LifecycleOwner for preventing memory leak. voidsetLifecycleOwner(@NonNull() LifecycleOwner lifecycleOwner)sets LifecycleOwner for preventing memory leak. voidsetFocusable(boolean focusable)makes focusing only on the menu popup. voidsetTouchInterceptor(View.OnTouchListener onTouchListener)sets android.view.View.OnTouchListener manually for the outside of popup. voidshowAsDropDown(View anchor)showing the popup menu as drop down to the anchor. voidshowAsDropDown(View anchor, int xOff, int yOff)showing the popup menu as drop down to the anchor with x-off and y-off. voidshowAsAnchorLeftTop(View anchor)showing the popup menu as left-top aligns to the anchor. voidshowAsAnchorLeftTop(View anchor, int xOff, int yOff)showing the popup menu as left-top aligns to the anchor with x-off and y-off. voidshowAsAnchorLeftBottom(View anchor)showing the popup menu as left-bottom aligns to the anchor. voidshowAsAnchorLeftBottom(View anchor, int xOff, int yOff)showing the popup menu as left-bottom aligns to the anchor. voidshowAsAnchorRightTop(View anchor)showing the popup menu as right-top aligns to the anchor. voidshowAsAnchorRightTop(View anchor, int xOff, int yOff)showing the popup menu as right-top aligns to the anchor. voidshowAsAnchorRightBottom(View anchor)showing the popup menu as right-bottom aligns to the anchor. voidshowAsAnchorRightBottom(View anchor, int xOff, int yOff)showing the popup menu as right-bottom aligns to the anchor. voidshowAsAnchorCenter(View anchor)showing the popup menu as center align to the anchor. voidshowAsAnchorCenter(View anchor, int xOff, int yOff)showing the popup menu as center align to the anchor. voidshowAtCenter(View anchor)showing the popup menu as center aligns to the anchor. voidshowAtCenter(View anchor, int xOff, int yOff)showing the popup menu as center aligns to the anchor with x-off and y-off. voidshowAtLocation(View anchor, int xOff, int yOff)showing the popup menu to the specific location to the anchor. voidshowAtLocation(View anchor, int gravity, int xOff, int yOff)showing the popup menu to the specific location to the anchor with Gravity. voiddismiss()dismiss the popup menu. booleanisShowing()gets the popup is showing or not. intgetContentViewWidth()gets measured width of the popup. intgetContentViewHeight()gets measured height of the popup. voidsetWidth(@Px() int width)sets the width of the popup menu. voidsetHeight(@Px() int height)sets the height of the popup menu. voidsetPadding(@Px() int padding)sets a padding size of the popup menu. voidsetDividerHeight(@Px() int height)sets the divider height of the popup menu. voidsetDivider(Drawable divider)sets the drawable of the divider. voidsetShowBackground(boolean show)sets the background is showing or not. voidsetOnDismissedListener(OnDismissedListener onDismissedListener)sets the dismissed listener of the popup menu. voidsetOnBackgroundClickListener(View.OnClickListener onBackgroundClickListener)sets the background click listener of the background. voidsetAnimation(@NonNull() MenuAnimation menuAnimation)sets animations of the popup. voidsetAnimationStyle(@StyleRes() int style)sets custom animations of the popup. voidsetMenuRadius(@Px() float radius)sets the corner radius of the popup menu. voidsetMenuShadow(@Px() float shadow)sets the shadow of the popup menu. voidsetIsClipping(boolean isClipping)sets the clipping enable or unable. voidsetSelection(int position)sets the selected position of the popup menu. voidsetBackgroundColor(@ColorInt() int color)sets the color of the background. voidsetBackgroundAlpha(@FloatRange(from = 0.0, to = 1.0) float alpha)sets the alpha of the background. voidsetBackgroundSystemUiVisibility(int visibility)sets system UI visibility flags for backgroundView. voidsetHeaderView(View view)sets the header view of the popup menu list. voidsetHeaderView(View view, Object data, boolean isSelectable)sets the header view of the popup menu list. voidsetHeaderView(int layout)sets the header view of the popup menu using layout. voidsetFooterView(View view)sets the footer view of the popup menu list. voidsetFooterView(View view, Object data, boolean isSelectable)sets the footer view of the popup menu list. voidsetFooterView(int layout)sets the footer view of the popup menu using layout. voidinvokeOnMenuListener(int position)invokes onMenuListener manually. voidonCreate(@NonNull() LifecycleOwner owner)voidonStart(@NonNull() LifecycleOwner owner)voidonResume(@NonNull() LifecycleOwner owner)voidonDestroy(@NonNull() LifecycleOwner owner)TgetAdapter()gets the adapter of the popup menu list. voidaddItem(E item)add an item. voidaddItem(int position, E item)add an item on a specific position. voidaddItemList(List<E> itemList)add an item list. ListViewgetListView()gets the ListView. voidsetListView(ListView listView)sets the ListView. intgetSelectedPosition()gets the selected item position. voidsetSelectedPosition(int position)sets the selected item position. voidremoveItem(E item)removes an item of the list. voidremoveItem(int position)removes an item on a specific position. voidclearItems()clears all the items of the list. List<E>getItemList()gets the item list. ListViewgetMenuListView()gets the ListView of the popup menu. ViewgetHeaderView()gets the header view of the popup menu list. ViewgetFooterView()gets the footer view of the popup menu list. StringgetPreferenceName()gets the preference name of PowerMenu. intgetPreferencePosition(int defaultPosition)gets the saved preference position from the SharedPreferences. voidsetPreferencePosition(int defaultPosition)sets the preference position name for persistence. voidclearPreference()clears the preference name of PowerMenu. voidsetAutoDismiss(boolean autoDismiss)sets the auto-dismissing or not. voidsetDismissIfShowAgain(boolean dismissIfShowAgain)sets the dismiss action if already popup is showing. -
-
Method Detail
-
getCircularEffect
CircularEffect getCircularEffect()
gets menu effect.
-
setCircularEffect
void setCircularEffect(@NonNull() CircularEffect circularEffect)
sets menu effects for showing popup more dynamically.
- Parameters:
circularEffect- CircularEffect.
-
getOnMenuItemClickListener
OnMenuItemClickListener<E> getOnMenuItemClickListener()
gets onMenuItemClickListener.
-
setOnMenuItemClickListener
void setOnMenuItemClickListener(OnMenuItemClickListener<E> menuItemClickListener)
sets OnMenuItemClickListener.
- Parameters:
menuItemClickListener- menu item click listener.
-
setLifecycleOwnerFromContext
void setLifecycleOwnerFromContext(@NonNull() Context context)
sets LifecycleOwner for preventing memory leak.
if sets the LifecycleOwner this popup will be dismissed automatically
when onDestroy method called by lifecycle.
- Parameters:
context- Context which can be the , androidx.fragment.app.FragmentActivity or etc are implements .
-
setLifecycleOwner
void setLifecycleOwner(@NonNull() LifecycleOwner lifecycleOwner)
sets LifecycleOwner for preventing memory leak.
if sets the LifecycleOwner this popup will be dismissed automatically
when onDestroy method called by lifecycle.
- Parameters:
lifecycleOwner- androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity or etc are implements .
-
setFocusable
void setFocusable(boolean focusable)
makes focusing only on the menu popup.
- Parameters:
focusable- focusable or not.
-
setTouchInterceptor
void setTouchInterceptor(View.OnTouchListener onTouchListener)
sets android.view.View.OnTouchListener manually for the outside of popup.
- Parameters:
onTouchListener- onTouchListener.
-
showAsDropDown
void showAsDropDown(View anchor)
showing the popup menu as drop down to the anchor.
- Parameters:
anchor- anchor view.
-
showAsDropDown
void showAsDropDown(View anchor, int xOff, int yOff)
showing the popup menu as drop down to the anchor with x-off and y-off.
- Parameters:
anchor- anchor view.xOff- x-off,yOff- y-off.
-
showAsAnchorLeftTop
void showAsAnchorLeftTop(View anchor)
showing the popup menu as left-top aligns to the anchor.
- Parameters:
anchor- anchor view.
-
showAsAnchorLeftTop
void showAsAnchorLeftTop(View anchor, int xOff, int yOff)
showing the popup menu as left-top aligns to the anchor with x-off and y-off.
- Parameters:
anchor- anchor view.xOff- x-off.yOff- y-off.
-
showAsAnchorLeftBottom
void showAsAnchorLeftBottom(View anchor)
showing the popup menu as left-bottom aligns to the anchor.
- Parameters:
anchor- anchor view.
-
showAsAnchorLeftBottom
void showAsAnchorLeftBottom(View anchor, int xOff, int yOff)
showing the popup menu as left-bottom aligns to the anchor.
- Parameters:
anchor- anchor view.xOff- x-off.yOff- y-off.
-
showAsAnchorRightTop
void showAsAnchorRightTop(View anchor)
showing the popup menu as right-top aligns to the anchor.
- Parameters:
anchor- anchor view.
-
showAsAnchorRightTop
void showAsAnchorRightTop(View anchor, int xOff, int yOff)
showing the popup menu as right-top aligns to the anchor.
- Parameters:
anchor- anchor view.xOff- x-off.yOff- y-off.
-
showAsAnchorRightBottom
void showAsAnchorRightBottom(View anchor)
showing the popup menu as right-bottom aligns to the anchor.
- Parameters:
anchor- anchor view.
-
showAsAnchorRightBottom
void showAsAnchorRightBottom(View anchor, int xOff, int yOff)
showing the popup menu as right-bottom aligns to the anchor.
- Parameters:
anchor- anchor view.xOff- x-off.yOff- y-off.
-
showAsAnchorCenter
void showAsAnchorCenter(View anchor)
showing the popup menu as center align to the anchor.
- Parameters:
anchor- anchor view.
-
showAsAnchorCenter
void showAsAnchorCenter(View anchor, int xOff, int yOff)
showing the popup menu as center align to the anchor.
- Parameters:
anchor- anchor view.xOff- x-off.yOff- y-off.
-
showAtCenter
void showAtCenter(View anchor)
showing the popup menu as center aligns to the anchor.
- Parameters:
anchor- anchor view.
-
showAtCenter
void showAtCenter(View anchor, int xOff, int yOff)
showing the popup menu as center aligns to the anchor with x-off and y-off.
- Parameters:
anchor- anchor view.xOff- x-off.yOff- y-off.
-
showAtLocation
void showAtLocation(View anchor, int xOff, int yOff)
showing the popup menu to the specific location to the anchor.
- Parameters:
anchor- anchor view.xOff- x-off.yOff- y-off.
-
showAtLocation
void showAtLocation(View anchor, int gravity, int xOff, int yOff)
showing the popup menu to the specific location to the anchor with Gravity.
- Parameters:
anchor- anchor view.gravity- gravity of the menu.xOff- x-off.yOff- y-off.
-
dismiss
void dismiss()
dismiss the popup menu.
-
isShowing
boolean isShowing()
gets the popup is showing or not.
-
getContentViewWidth
int getContentViewWidth()
gets measured width of the popup.
-
getContentViewHeight
int getContentViewHeight()
gets measured height of the popup.
-
setWidth
void setWidth(@Px() int width)
sets the width of the popup menu.
- Parameters:
width- width of the popup menu.
-
setHeight
void setHeight(@Px() int height)
sets the height of the popup menu.
- Parameters:
height- height of the popup menu.
-
setPadding
void setPadding(@Px() int padding)
sets a padding size of the popup menu.
- Parameters:
padding- padding size.
-
setDividerHeight
void setDividerHeight(@Px() int height)
sets the divider height of the popup menu.
- Parameters:
height- divider height of the popup menu.
-
setDivider
void setDivider(Drawable divider)
sets the drawable of the divider.
- Parameters:
divider- drawable of the divider.
-
setShowBackground
void setShowBackground(boolean show)
sets the background is showing or not.
- Parameters:
show- background is showing or not.
-
setOnDismissedListener
void setOnDismissedListener(OnDismissedListener onDismissedListener)
sets the dismissed listener of the popup menu.
- Parameters:
onDismissedListener- OnDismissedListener.
-
setOnBackgroundClickListener
void setOnBackgroundClickListener(View.OnClickListener onBackgroundClickListener)
sets the background click listener of the background.
- Parameters:
onBackgroundClickListener- android.view.View.OnClickListener.
-
setAnimation
void setAnimation(@NonNull() MenuAnimation menuAnimation)
sets animations of the popup. It will start up when the popup is showing.
- Parameters:
menuAnimation- menu animation.
-
setAnimationStyle
void setAnimationStyle(@StyleRes() int style)
sets custom animations of the popup. It will start up when the popup is showing.
- Parameters:
style- custom animation style.
-
setMenuRadius
void setMenuRadius(@Px() float radius)
sets the corner radius of the popup menu.
- Parameters:
radius- corner radius.
-
setMenuShadow
void setMenuShadow(@Px() float shadow)
sets the shadow of the popup menu.
- Parameters:
shadow- shadow value.
-
setIsClipping
void setIsClipping(boolean isClipping)
sets the clipping enable or unable.
- Parameters:
isClipping- clipping enable or unable.
-
setSelection
void setSelection(int position)
sets the selected position of the popup menu. It can be used for scrolling as the position.
- Parameters:
position- selected position.
-
setBackgroundColor
void setBackgroundColor(@ColorInt() int color)
sets the color of the background.
- Parameters:
color- color value.
-
setBackgroundAlpha
void setBackgroundAlpha(@FloatRange(from = 0.0, to = 1.0) float alpha)
sets the alpha of the background.
- Parameters:
alpha- alpha value.
-
setBackgroundSystemUiVisibility
void setBackgroundSystemUiVisibility(int visibility)
sets system UI visibility flags for backgroundView.
- Parameters:
visibility- visibility value.
-
setHeaderView
void setHeaderView(View view)
sets the header view of the popup menu list.
- Parameters:
view- View.
-
setHeaderView
void setHeaderView(View view, Object data, boolean isSelectable)
sets the header view of the popup menu list.
- Parameters:
view- View.data- Object.isSelectable- is selectable or not.
-
setHeaderView
void setHeaderView(int layout)
sets the header view of the popup menu using layout.
- Parameters:
layout- layout.
-
setFooterView
void setFooterView(View view)
sets the footer view of the popup menu list.
- Parameters:
view- View.
-
setFooterView
void setFooterView(View view, Object data, boolean isSelectable)
sets the footer view of the popup menu list.
- Parameters:
view- View.data- Object.isSelectable- is selectable or not.
-
setFooterView
void setFooterView(int layout)
sets the footer view of the popup menu using layout.
- Parameters:
layout- layout.
-
invokeOnMenuListener
void invokeOnMenuListener(int position)
invokes onMenuListener manually.
- Parameters:
position- the invoked position.
-
onCreate
void onCreate(@NonNull() LifecycleOwner owner)
-
onStart
void onStart(@NonNull() LifecycleOwner owner)
-
onResume
void onResume(@NonNull() LifecycleOwner owner)
-
onDestroy
void onDestroy(@NonNull() LifecycleOwner owner)
-
getAdapter
T getAdapter()
gets the adapter of the popup menu list.
-
addItem
void addItem(int position, E item)
add an item on a specific position.
- Parameters:
position- position of the list.item- an item.
-
addItemList
void addItemList(List<E> itemList)
add an item list.
- Parameters:
itemList- an item list.
-
getListView
ListView getListView()
gets the ListView.
-
setListView
void setListView(ListView listView)
sets the ListView.
- Parameters:
listView- ListView.
-
getSelectedPosition
int getSelectedPosition()
gets the selected item position.
-
setSelectedPosition
void setSelectedPosition(int position)
sets the selected item position.
- Parameters:
position- a selected item position.
-
removeItem
void removeItem(E item)
removes an item of the list.
- Parameters:
item- an item.
-
removeItem
void removeItem(int position)
removes an item on a specific position.
- Parameters:
position- an item position.
-
clearItems
void clearItems()
clears all the items of the list.
-
getItemList
List<E> getItemList()
gets the item list.
-
getMenuListView
ListView getMenuListView()
gets the ListView of the popup menu.
-
getHeaderView
View getHeaderView()
gets the header view of the popup menu list.
-
getFooterView
View getFooterView()
gets the footer view of the popup menu list.
-
getPreferenceName
String getPreferenceName()
gets the preference name of PowerMenu.
-
getPreferencePosition
int getPreferencePosition(int defaultPosition)
gets the saved preference position from the SharedPreferences.
- Parameters:
defaultPosition- the default position of the preference.
-
setPreferencePosition
void setPreferencePosition(int defaultPosition)
sets the preference position name for persistence.
- Parameters:
defaultPosition- the default position of the preference.
-
clearPreference
void clearPreference()
clears the preference name of PowerMenu.
-
setAutoDismiss
void setAutoDismiss(boolean autoDismiss)
sets the auto-dismissing or not.
The popup menu will be dismissed automatically when the item would be clicked.
- Parameters:
autoDismiss- is auto-dismissing or not.
-
setDismissIfShowAgain
void setDismissIfShowAgain(boolean dismissIfShowAgain)
sets the dismiss action if already popup is showing.
- Parameters:
dismissIfShowAgain- dismiss if already popup is showing.
-
-
-
-