Package icyllis.modernui.widget
Class ForwardingListener
java.lang.Object
icyllis.modernui.widget.ForwardingListener
- All Implemented Interfaces:
View.OnAttachStateChangeListener
,View.OnTouchListener
public abstract class ForwardingListener
extends Object
implements View.OnTouchListener, View.OnAttachStateChangeListener
Abstract class that forwards touch events to a
ShowableListMenu
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract ShowableListMenu
getPopup()
Returns the popup to which this listener is forwarding events.protected boolean
Called when forwarding would like to start.protected boolean
Called when forwarding would like to stop.boolean
onTouch
(View v, MotionEvent event) Called when a touch event is dispatched to a view.void
Called when the view is attached to a window.void
Called when the view is detached from a window.
-
Constructor Details
-
ForwardingListener
-
-
Method Details
-
getPopup
Returns the popup to which this listener is forwarding events.Override this to return the correct popup. If the popup is displayed asynchronously, you may also need to override
onForwardingStopped()
to prevent premature cancellation of forwarding.- Returns:
- the popup to which this listener is forwarding events
-
onTouch
Description copied from interface:View.OnTouchListener
Called when a touch event is dispatched to a view. This allows listeners to get a chance to respond before the target view.- Specified by:
onTouch
in interfaceView.OnTouchListener
- Parameters:
v
- The view the touch event has been dispatched to.event
- The MotionEvent object containing full information about the event.- Returns:
- True if the listener has consumed the event, false otherwise.
-
onViewAttachedToWindow
Description copied from interface:View.OnAttachStateChangeListener
Called when the view is attached to a window.- Specified by:
onViewAttachedToWindow
in interfaceView.OnAttachStateChangeListener
- Parameters:
v
- The view that was attached
-
onViewDetachedFromWindow
Description copied from interface:View.OnAttachStateChangeListener
Called when the view is detached from a window.- Specified by:
onViewDetachedFromWindow
in interfaceView.OnAttachStateChangeListener
- Parameters:
v
- The view that was detached
-
onForwardingStarted
protected boolean onForwardingStarted()Called when forwarding would like to start.By default, this will show the popup returned by
getPopup()
. It may be overridden to perform another action, like clicking the source view or preparing the popup before showing it.- Returns:
- true to start forwarding, false otherwise
-
onForwardingStopped
protected boolean onForwardingStopped()Called when forwarding would like to stop.By default, this will dismiss the popup returned by
getPopup()
. It may be overridden to perform some other action.- Returns:
- true to stop forwarding, false otherwise
-