public abstract class AbstractPowerMenu<E,T extends MenuBaseAdapter>
extends java.lang.Object
implements androidx.lifecycle.LifecycleObserver
PowerMenu
and CustomPowerMenu
.
It implements basically almost things of the PowerMenu.
Modifier and Type | Field and Description |
---|---|
protected T |
adapter |
protected boolean |
allowTouchBackground |
protected android.view.View |
backgroundView |
protected android.widget.PopupWindow |
backgroundWindow |
protected int |
contentViewPadding |
protected boolean |
fixedHeight |
protected android.view.View |
footerView |
protected android.view.View |
headerView |
protected androidx.lifecycle.Lifecycle.Event |
initializeRule |
protected boolean |
isShowing |
protected android.view.LayoutInflater |
layoutInflater |
protected androidx.lifecycle.LifecycleOwner |
lifecycleOwner |
protected androidx.cardview.widget.CardView |
menuCard |
protected OnMenuItemClickListener |
menuItemClickListener |
protected android.widget.ListView |
menuListView |
protected android.view.View |
menuView |
protected android.widget.PopupWindow |
menuWindow |
protected OnDismissedListener |
onDismissedListener |
protected boolean |
showBackground |
Modifier | Constructor and Description |
---|---|
protected |
AbstractPowerMenu(android.content.Context context) |
protected |
AbstractPowerMenu(android.content.Context context,
AbstractMenuBuilder builder) |
Modifier and Type | Method and Description |
---|---|
void |
addItem(E item)
add an item.
|
void |
addItem(int position,
E item)
add an item on a specific position.
|
void |
addItemList(java.util.List<E> itemList)
add an item list.
|
void |
clearItems()
clears all the items of the list.
|
void |
clearPreference()
clears the preference name of PowerMenu.
|
void |
dismiss()
dismiss the popup menu.
|
T |
getAdapter()
gets the adapter of the popup menu list.
|
CircularEffect |
getCircularEffect()
gets menu effect.
|
int |
getContentViewHeight()
gets measured height of the popup.
|
protected int |
getContentViewPadding()
gets the content view padding of the popup menu.
|
int |
getContentViewWidth()
gets measured width of the popup.
|
android.view.View |
getFooterView()
gets the footer view of the popup menu list.
|
android.view.View |
getHeaderView()
gets the header view of the popup menu list.
|
java.util.List<E> |
getItemList()
gets the item list.
|
android.widget.ListView |
getListView()
gets the
ListView . |
protected android.view.View |
getMeasuredContentView()
gets the content view of the popup menu.
|
android.widget.ListView |
getMenuListView()
gets the
ListView of the popup menu. |
OnMenuItemClickListener<E> |
getOnMenuItemClickListener()
gets onMenuItemClickListener.
|
java.lang.String |
getPreferenceName()
gets the preference name of PowerMenu.
|
int |
getPreferencePosition(int defaultPosition)
gets the saved preference position from the SharedPreferences.
|
int |
getSelectedPosition()
gets the selected item position.
|
protected void |
initialize(android.content.Context context) |
void |
invokeOnMenuListener(int position)
invokes onMenuListener manually.
|
boolean |
isShowing()
gets the popup is showing or not.
|
void |
onCreate() |
void |
onDestroy() |
void |
onResume() |
void |
onStart() |
void |
removeItem(E item)
removes an item of the list.
|
void |
removeItem(int position)
removes an item on a specific position.
|
void |
setAnimation(MenuAnimation menuAnimation)
sets animations of the popup.
|
void |
setAnimationStyle(int style)
sets custom animations of the popup.
|
void |
setAutoDismiss(boolean autoDismiss)
sets the auto-dismissing or not.
|
void |
setBackgroundAlpha(float alpha)
sets the alpha of the background.
|
void |
setBackgroundColor(int color)
sets the color of the background.
|
void |
setCircularEffect(CircularEffect circularEffect)
sets menu effects for showing popup more dynamically.
|
void |
setDivider(android.graphics.drawable.Drawable divider)
sets the drawable of the divider.
|
void |
setDividerHeight(int height)
sets the divider height of the popup menu.
|
void |
setFocusable(boolean focusable)
makes focusing only on the menu popup.
|
void |
setFooterView(int layout)
sets the footer view of the popup menu using layout.
|
void |
setFooterView(android.view.View view)
sets the footer view of the popup menu list.
|
void |
setFooterView(android.view.View view,
java.lang.Object data,
boolean isSelectable)
sets the footer view of the popup menu list.
|
void |
setHeaderView(int layout)
sets the header view of the popup menu using layout.
|
void |
setHeaderView(android.view.View view)
sets the header view of the popup menu list.
|
void |
setHeaderView(android.view.View view,
java.lang.Object data,
boolean isSelectable)
sets the header view of the popup menu list.
|
void |
setHeight(int height)
sets the height of the popup menu.
|
void |
setIsClipping(boolean isClipping)
sets the clipping enable or unable.
|
void |
setLifecycleOwner(androidx.lifecycle.LifecycleOwner lifecycleOwner)
sets
LifecycleOwner for preventing memory leak. |
void |
setListView(android.widget.ListView listView)
sets the
ListView . |
protected void |
setMeasuredHeight(int height)
sets the measured height of the popup menu list.
|
void |
setMenuRadius(float radius)
sets the corner radius of the popup menu.
|
void |
setMenuShadow(float shadow)
sets the shadow of the popup menu.
|
void |
setOnBackgroundClickListener(android.view.View.OnClickListener onBackgroundClickListener)
sets the background click listener of the background.
|
void |
setOnDismissedListener(OnDismissedListener onDismissedListener)
sets the dismissed listener of the popup menu.
|
void |
setOnMenuItemClickListener(OnMenuItemClickListener<E> menuItemClickListener)
sets
OnMenuItemClickListener . |
void |
setPreferencePosition(int defaultPosition)
sets the preference position name for persistence.
|
void |
setSelectedPosition(int position)
sets the selected item position.
|
void |
setSelection(int position)
sets the selected position of the popup menu.
|
void |
setShowBackground(boolean show)
sets the background is showing or not.
|
void |
setTouchInterceptor(android.view.View.OnTouchListener onTouchListener)
sets
View.OnTouchListener manually for the outside of popup. |
void |
setWidth(int width)
sets the width of the popup menu.
|
void |
showAsAnchorCenter(android.view.View anchor)
showing the popup menu as center align to the anchor.
|
void |
showAsAnchorCenter(android.view.View anchor,
int xOff,
int yOff)
showing the popup menu as center align to the anchor.
|
void |
showAsAnchorLeftBottom(android.view.View anchor)
showing the popup menu as left-bottom aligns to the anchor.
|
void |
showAsAnchorLeftBottom(android.view.View anchor,
int xOff,
int yOff)
showing the popup menu as left-bottom aligns to the anchor.
|
void |
showAsAnchorLeftTop(android.view.View anchor)
showing the popup menu as left-top aligns to the anchor.
|
void |
showAsAnchorLeftTop(android.view.View anchor,
int xOff,
int yOff)
showing the popup menu as left-top aligns to the anchor with x-off and y-off.
|
void |
showAsAnchorRightBottom(android.view.View anchor)
showing the popup menu as right-bottom aligns to the anchor.
|
void |
showAsAnchorRightBottom(android.view.View anchor,
int xOff,
int yOff)
showing the popup menu as right-bottom aligns to the anchor.
|
void |
showAsAnchorRightTop(android.view.View anchor)
showing the popup menu as right-top aligns to the anchor.
|
void |
showAsAnchorRightTop(android.view.View anchor,
int xOff,
int yOff)
showing the popup menu as right-top aligns to the anchor.
|
void |
showAsDropDown(android.view.View anchor)
showing the popup menu as drop down to the anchor.
|
void |
showAsDropDown(android.view.View anchor,
int xOff,
int yOff)
showing the popup menu as drop down to the anchor with x-off and y-off.
|
void |
showAtCenter(android.view.View anchor)
showing the popup menu as center aligns to the anchor.
|
void |
showAtCenter(android.view.View anchor,
int xOff,
int yOff)
showing the popup menu as center aligns to the anchor with x-off and y-off.
|
void |
showAtLocation(android.view.View anchor,
int xOff,
int yOff)
showing the popup menu to the specific location to the anchor.
|
void |
showAtLocation(android.view.View anchor,
int gravity,
int xOff,
int yOff)
showing the popup menu to the specific location to the anchor with
Gravity . |
protected android.view.View backgroundView
protected android.view.View menuView
protected androidx.cardview.widget.CardView menuCard
protected android.widget.PopupWindow backgroundWindow
protected android.widget.PopupWindow menuWindow
protected androidx.lifecycle.Lifecycle.Event initializeRule
protected androidx.lifecycle.LifecycleOwner lifecycleOwner
protected android.widget.ListView menuListView
protected OnMenuItemClickListener menuItemClickListener
protected OnDismissedListener onDismissedListener
protected android.view.LayoutInflater layoutInflater
protected android.view.View headerView
protected android.view.View footerView
protected T extends MenuBaseAdapter adapter
protected boolean showBackground
protected boolean allowTouchBackground
protected boolean fixedHeight
protected boolean isShowing
protected int contentViewPadding
protected AbstractPowerMenu(android.content.Context context)
protected AbstractPowerMenu(android.content.Context context, AbstractMenuBuilder builder)
protected void initialize(android.content.Context context)
public void setLifecycleOwner(@NonNull androidx.lifecycle.LifecycleOwner lifecycleOwner)
LifecycleOwner
for preventing memory leak.
if sets the LifecycleOwner
this popup will be dismissed automatically
when onDestroy method called by lifecycle.
lifecycleOwner
- androidx.appcompat.app.AppCompatActivity
,
androidx.fragment.app.FragmentActivity
or etc are implements LifecycleOwner
.
public void setFocusable(boolean focusable)
focusable
- focusable or not.public void setTouchInterceptor(android.view.View.OnTouchListener onTouchListener)
View.OnTouchListener
manually for the outside of popup.onTouchListener
- onTouchListener.public OnMenuItemClickListener<E> getOnMenuItemClickListener()
OnMenuItemClickListener
.public void setOnMenuItemClickListener(OnMenuItemClickListener<E> menuItemClickListener)
OnMenuItemClickListener
.menuItemClickListener
- menu item click listener.public void showAsDropDown(android.view.View anchor)
anchor
- anchor view.public void showAsDropDown(android.view.View anchor, int xOff, int yOff)
anchor
- anchor view.xOff
- x-off,yOff
- y-off.public void showAsAnchorLeftTop(android.view.View anchor)
anchor
- anchor view.public void showAsAnchorLeftTop(android.view.View anchor, int xOff, int yOff)
anchor
- anchor view.xOff
- x-off.yOff
- y-off.public void showAsAnchorLeftBottom(android.view.View anchor)
anchor
- anchor view.public void showAsAnchorLeftBottom(android.view.View anchor, int xOff, int yOff)
anchor
- anchor view.xOff
- x-off.yOff
- y-off.public void showAsAnchorRightTop(android.view.View anchor)
anchor
- anchor view.public void showAsAnchorRightTop(android.view.View anchor, int xOff, int yOff)
anchor
- anchor view.xOff
- x-off.yOff
- y-off.public void showAsAnchorRightBottom(android.view.View anchor)
anchor
- anchor view.public void showAsAnchorRightBottom(android.view.View anchor, int xOff, int yOff)
anchor
- anchor view.xOff
- x-off.yOff
- y-off.public void showAsAnchorCenter(android.view.View anchor)
anchor
- anchor view.public void showAsAnchorCenter(android.view.View anchor, int xOff, int yOff)
anchor
- anchor view.xOff
- x-off.yOff
- y-off.public void showAtCenter(android.view.View anchor)
anchor
- anchor view.public void showAtCenter(android.view.View anchor, int xOff, int yOff)
anchor
- anchor view.xOff
- x-off.yOff
- y-off.public void showAtLocation(android.view.View anchor, int xOff, int yOff)
anchor
- anchor view.xOff
- x-off.yOff
- y-off.public void showAtLocation(android.view.View anchor, int gravity, int xOff, int yOff)
Gravity
.anchor
- anchor view.gravity
- gravity of the menu.xOff
- x-off.yOff
- y-off.public void dismiss()
public boolean isShowing()
public int getContentViewWidth()
public int getContentViewHeight()
protected android.view.View getMeasuredContentView()
protected int getContentViewPadding()
public void setWidth(int width)
width
- width of the popup menu.public void setHeight(int height)
height
- height of the popup menu.protected void setMeasuredHeight(int height)
height
- the measured height of the popup menu list.public void setDividerHeight(int height)
height
- divider height of the popup menu.public void setDivider(android.graphics.drawable.Drawable divider)
divider
- drawable of the divider.public void setShowBackground(boolean show)
show
- background is showing or not.public void setOnDismissedListener(OnDismissedListener onDismissedListener)
onDismissedListener
- OnDismissedListener
.public void setOnBackgroundClickListener(android.view.View.OnClickListener onBackgroundClickListener)
onBackgroundClickListener
- View.OnClickListener
.public void setAnimation(@NonNull MenuAnimation menuAnimation)
menuAnimation
- menu animation.public void setAnimationStyle(int style)
style
- custom animation style.public void setMenuRadius(float radius)
radius
- corner radius.public void setMenuShadow(float shadow)
shadow
- shadow value.public void setIsClipping(boolean isClipping)
isClipping
- clipping enable or unable.public void setSelection(int position)
position
- selected position.public void setBackgroundColor(int color)
color
- color value.public void setBackgroundAlpha(float alpha)
alpha
- alpha value.public void setHeaderView(android.view.View view)
view
- View
.public void setHeaderView(android.view.View view, java.lang.Object data, boolean isSelectable)
view
- View
.data
- Object.isSelectable
- is selectable or not.public void setHeaderView(int layout)
layout
- layout.public void setFooterView(android.view.View view)
view
- View
.public void setFooterView(android.view.View view, java.lang.Object data, boolean isSelectable)
view
- View
.data
- Object.isSelectable
- is selectable or not.public void setFooterView(int layout)
layout
- layout.public void invokeOnMenuListener(int position)
position
- the invoked position.public void onCreate()
public void onStart()
public void onResume()
public void onDestroy()
public T getAdapter()
public void addItem(E item)
item
- item.public void addItem(int position, E item)
position
- position of the list.item
- an item.public void addItemList(java.util.List<E> itemList)
itemList
- an item list.public android.widget.ListView getListView()
ListView
.ListView
.public void setListView(android.widget.ListView listView)
ListView
.listView
- ListView
.public int getSelectedPosition()
public void setSelectedPosition(int position)
position
- a selected item position.public void removeItem(E item)
item
- an item.public void removeItem(int position)
position
- an item position.public void clearItems()
public java.util.List<E> getItemList()
List
.public android.widget.ListView getMenuListView()
ListView
of the popup menu.ListView
.public android.view.View getHeaderView()
View
.public android.view.View getFooterView()
View
.public void setAutoDismiss(boolean autoDismiss)
The popup menu will be dismissed automatically when the item would be clicked.
autoDismiss
- is auto-dismissing or not.public java.lang.String getPreferenceName()
public int getPreferencePosition(int defaultPosition)
defaultPosition
- the default position of the preference.public void setPreferencePosition(int defaultPosition)
defaultPosition
- the default position of the preference.public void clearPreference()
public CircularEffect getCircularEffect()
CircularEffect
.public void setCircularEffect(@NonNull CircularEffect circularEffect)
circularEffect
- CircularEffect
.