| 712 | } |
| 713 | |
| 714 | export class TouchGestureEventData { |
| 715 | eventName: string = toString(GestureTypes.touch); |
| 716 | type: GestureTypes = GestureTypes.touch; |
| 717 | ios: any = undefined; |
| 718 | action: string; |
| 719 | view: View; |
| 720 | android: android.view.MotionEvent; |
| 721 | object: any; |
| 722 | |
| 723 | private _activePointers: Array<Pointer>; |
| 724 | private _allPointers: Array<Pointer>; |
| 725 | |
| 726 | public prepare(view: View, e: android.view.MotionEvent) { |
| 727 | this.view = view; |
| 728 | this.object = view; |
| 729 | this.android = e; |
| 730 | this.action = this.getActionType(e); |
| 731 | |
| 732 | this._activePointers = undefined; |
| 733 | this._allPointers = undefined; |
| 734 | } |
| 735 | |
| 736 | getPointerCount(): number { |
| 737 | return this.android.getPointerCount(); |
| 738 | } |
| 739 | |
| 740 | getActivePointers(): Array<Pointer> { |
| 741 | // Only one active pointer in Android |
| 742 | if (!this._activePointers) { |
| 743 | this._activePointers = [new Pointer(this.android.getActionIndex(), this.android)]; |
| 744 | } |
| 745 | |
| 746 | return this._activePointers; |
| 747 | } |
| 748 | |
| 749 | getAllPointers(): Array<Pointer> { |
| 750 | if (!this._allPointers) { |
| 751 | this._allPointers = []; |
| 752 | for (let i = 0; i < this.getPointerCount(); i++) { |
| 753 | this._allPointers.push(new Pointer(i, this.android)); |
| 754 | } |
| 755 | } |
| 756 | |
| 757 | return this._allPointers; |
| 758 | } |
| 759 | |
| 760 | getX(): number { |
| 761 | return this.getActivePointers()[0].getX(); |
| 762 | } |
| 763 | |
| 764 | getY(): number { |
| 765 | return this.getActivePointers()[0].getY(); |
| 766 | } |
| 767 | |
| 768 | private getActionType(e: android.view.MotionEvent): string { |
| 769 | switch (e.getActionMasked()) { |
| 770 | case android.view.MotionEvent.ACTION_DOWN: |
| 771 | case android.view.MotionEvent.ACTION_POINTER_DOWN: |
nothing calls this directly
no test coverage detected