Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | List of all members
io.flutter.embedding.android.MotionEventTracker Class Reference

Classes

class  MotionEventId
 

Public Member Functions

MotionEventId track (@NonNull MotionEvent event)
 
MotionEvent pop (@NonNull MotionEventId eventId)
 

Static Public Member Functions

static MotionEventTracker getInstance ()
 

Detailed Description

Tracks the motion events received by the FlutterView.

Definition at line 11 of file MotionEventTracker.java.

Member Function Documentation

◆ getInstance()

static MotionEventTracker io.flutter.embedding.android.MotionEventTracker.getInstance ( )
inlinestatic

Definition at line 42 of file MotionEventTracker.java.

42 {
43 if (INSTANCE == null) {
44 INSTANCE = new MotionEventTracker();
45 }
46 return INSTANCE;
47 }

◆ pop()

MotionEvent io.flutter.embedding.android.MotionEventTracker.pop ( @NonNull MotionEventId  eventId)
inline

Returns the MotionEvent corresponding to the eventId while discarding all the motion events that occurred prior to the event represented by the eventId. Returns null if this event was popped or discarded.

Definition at line 76 of file MotionEventTracker.java.

76 {
77 // remove all the older events.
78 while (!unusedEvents.isEmpty() && unusedEvents.peek() < eventId.id) {
79 eventById.remove(unusedEvents.poll());
80 }
81
82 // remove the current event from the heap if it exists.
83 if (!unusedEvents.isEmpty() && unusedEvents.peek() == eventId.id) {
84 unusedEvents.poll();
85 }
86
87 MotionEvent event = eventById.get(eventId.id);
88 eventById.remove(eventId.id);
89 return event;
90 }
FlKeyEvent * event

◆ track()

MotionEventId io.flutter.embedding.android.MotionEventTracker.track ( @NonNull MotionEvent  event)
inline

Tracks the event and returns a unique MotionEventId identifying the event.

Definition at line 56 of file MotionEventTracker.java.

56 {
57 MotionEventId eventId = MotionEventId.createUnique();
58 // We copy event here because the original MotionEvent delivered to us
59 // will be automatically recycled (`MotionEvent.recycle`) by the RootView and we need
60 // access to it after the RootView code runs.
61 // The return value of `MotionEvent.obtain(event)` is still verifiable if the input
62 // event was verifiable. Other overloads of `MotionEvent.obtain` do not have this
63 // guarantee and should be avoided when possible.
64 MotionEvent eventCopy = MotionEvent.obtain(event);
65 eventById.put(eventId.id, eventCopy);
66 unusedEvents.add(eventId.id);
67 return eventId;
68 }

The documentation for this class was generated from the following file: