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 Details

    • ForwardingListener

      public ForwardingListener(@Nonnull View view)
  • Method Details

    • getPopup

      public abstract ShowableListMenu 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

      public boolean onTouch(View v, MotionEvent event)
      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 interface View.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

      public void onViewAttachedToWindow(View v)
      Description copied from interface: View.OnAttachStateChangeListener
      Called when the view is attached to a window.
      Specified by:
      onViewAttachedToWindow in interface View.OnAttachStateChangeListener
      Parameters:
      v - The view that was attached
    • onViewDetachedFromWindow

      public void onViewDetachedFromWindow(View v)
      Description copied from interface: View.OnAttachStateChangeListener
      Called when the view is detached from a window.
      Specified by:
      onViewDetachedFromWindow in interface View.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