Package 

Class TouchEventCoalescingKeyHelper


  • 
    public class TouchEventCoalescingKeyHelper
    
                        

    Utility for determining coalescing keys for TouchEvents. To preserve proper ordering of events, move events should only be coalesced if there has been no up/down event between them (this basically only applies to multitouch since for single touches an up would signal the end of the gesture). To illustrate to kind of coalescing we want, imagine we are coalescing the following touch stream:

    (U = finger up, D = finger down, M = move) D MMMMM D MMMMMMMMMMMMMM U MMMMM D MMMMMM U U

    We want to make sure to coalesce this as

    D M D M U M D U U

    and *not*

    D D U M D U U

    To accomplish this, this class provides a way to initialize a coalescing key for a gesture and then increment it for every pointer up/down that occurs during that single gesture.

    We identify a single gesture based on getDownTime which will stay constant for a given set of related touches on a single view.

    NB: even though down time is a long, we cast as an int using the least significant bits as the identifier. In practice, we will not be coalescing over a time range where the most significant bits of that time range matter. This would require a gesture that lasts Integer.MAX_VALUE * 2 ms, or ~48 days.

    NB: we assume two gestures cannot begin at the same time.

    NB: this class should only be used from the UI thread.

    • Method Summary

      Modifier and Type Method Description
      void addCoalescingKey(long downTime) Starts tracking a new coalescing key corresponding to the gesture with this down time.
      void incrementCoalescingKey(long downTime) Increments the coalescing key corresponding to the gesture with this down time.
      short getCoalescingKey(long downTime) Gets the coalescing key corresponding to the gesture with this down time.
      void removeCoalescingKey(long downTime) Stops tracking a new coalescing key corresponding to the gesture with this down time.
      boolean hasCoalescingKey(long downTime)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • addCoalescingKey

         void addCoalescingKey(long downTime)

        Starts tracking a new coalescing key corresponding to the gesture with this down time.

      • incrementCoalescingKey

         void incrementCoalescingKey(long downTime)

        Increments the coalescing key corresponding to the gesture with this down time.

      • getCoalescingKey

         short getCoalescingKey(long downTime)

        Gets the coalescing key corresponding to the gesture with this down time.

      • removeCoalescingKey

         void removeCoalescingKey(long downTime)

        Stops tracking a new coalescing key corresponding to the gesture with this down time.