public abstract class

QuickActionWidget

extends PopupWindow
java.lang.Object
   ↳ android.widget.PopupWindow
     ↳ greendroid.widget.QuickActionWidget
Known Direct Subclasses

Class Overview

Abstraction of a QuickAction wrapper. A QuickActionWidget is displayed on top of the user interface (it overlaps all UI elements but the notification bar). Clients may listen to user actions using a QuickActionWidget.OnQuickActionClickListener .

Summary

Nested Classes
interface QuickActionWidget.OnQuickActionClickListener Interface that may be used to listen to clicks on quick actions. 
[Expand]
Inherited Constants
From class android.widget.PopupWindow
Public Constructors
QuickActionWidget(Context context)
Creates a new QuickActionWidget for the given context.
Public Methods
void addQuickAction(QuickAction action)
Add a new QuickAction to this QuickActionWidget.
void clearAllQuickActions()
Removes all QuickAction from this QuickActionWidget.
int getArrowOffsetY()
Returns the arrow offset for the Y axis.
boolean getDismissOnClick()
void setArrowOffsetY(int offsetY)
Sets the arrow offset to a new value.
void setContentView(int layoutId)
Equivalent to setContentView(View) but with a layout identifier.
void setDismissOnClick(boolean dismissOnClick)
By default, a QuickActionWidget is dismissed once the user clicked on a QuickAction.
void setOnQuickActionClickListener(QuickActionWidget.OnQuickActionClickListener listener)
void show(View anchor)
Call that method to display the QuickActionWidget anchored to the given view.
Protected Methods
void clearQuickActions()
Context getContext()
QuickActionWidget.OnQuickActionClickListener getOnQuickActionClickListener()
int getScreenHeight()
Returns the height of the screen.
int getScreenWidth()
Returns the width of the screen.
void onClearQuickActions()
abstract void onMeasureAndLayout(Rect anchorRect, View contentView)
abstract void populateQuickActions(List<QuickAction> quickActions)
void setWidgetSpecs(int popupY, boolean isOnTop)
[Expand]
Inherited Methods
From class android.widget.PopupWindow
From class java.lang.Object

Public Constructors

public QuickActionWidget (Context context)

Creates a new QuickActionWidget for the given context.

Parameters
context The context in which the QuickActionWidget is running in

Public Methods

public void addQuickAction (QuickAction action)

Add a new QuickAction to this QuickActionWidget. Adding a new QuickAction while the QuickActionWidget is currently being shown does nothing. The new QuickAction will be displayed on the next call to show(View).

Parameters
action The new QuickAction to add

public void clearAllQuickActions ()

Removes all QuickAction from this QuickActionWidget.

public int getArrowOffsetY ()

Returns the arrow offset for the Y axis.

Returns
  • The arrow offset.
See Also
  • {@link #setArrowOffsetY(int)}

public boolean getDismissOnClick ()

public void setArrowOffsetY (int offsetY)

Sets the arrow offset to a new value. Setting an arrow offset may be particular useful to warn which view the QuickActionWidget is related to. By setting a positive offset, the arrow will overlap the view given by show(View). The default value is 5dp.

Parameters
offsetY The offset for the Y axis

public void setContentView (int layoutId)

Equivalent to setContentView(View) but with a layout identifier.

Parameters
layoutId The layout identifier of the view to use.

public void setDismissOnClick (boolean dismissOnClick)

By default, a QuickActionWidget is dismissed once the user clicked on a QuickAction. This behavior can be changed using this method.

Parameters
dismissOnClick True if you want the QuickActionWidget to be dismissed on click else false.

public void setOnQuickActionClickListener (QuickActionWidget.OnQuickActionClickListener listener)

public void show (View anchor)

Call that method to display the QuickActionWidget anchored to the given view.

Parameters
anchor The view the QuickActionWidget will be anchored to.

Protected Methods

protected void clearQuickActions ()

protected Context getContext ()

protected QuickActionWidget.OnQuickActionClickListener getOnQuickActionClickListener ()

protected int getScreenHeight ()

Returns the height of the screen.

Returns
  • The height of the screen

protected int getScreenWidth ()

Returns the width of the screen.

Returns
  • The width of the screen

protected void onClearQuickActions ()

protected abstract void onMeasureAndLayout (Rect anchorRect, View contentView)

protected abstract void populateQuickActions (List<QuickAction> quickActions)

protected void setWidgetSpecs (int popupY, boolean isOnTop)