protected override void OnAttached() { // Get the Android View corresponding to the Element that the effect is attached to view = Control ?? Container; // Get access to the TouchEffect class in the PCL var touchEffect = (SkiaUtil.Core.TouchTracking.TouchEffect)Element.Effects. FirstOrDefault(e => e is SkiaUtil.Core.TouchTracking.TouchEffect); if (touchEffect != null && view != null) { viewDictionary.Add(view, this); formsElement = Element; pclTouchEffect = touchEffect; // Save fromPixels function fromPixels = view.Context.FromPixels; // Set event handler on View view.Touch += OnTouch; } }
void SetContentView(global::Android.Views.View view, global::Android.Views.ViewGroup.LayoutParams @params, global::Xamarin.Android.Design.OnLayoutItemNotFoundHandler onLayoutItemNotFound) { __layout_binding = new global::Binding.ActivitySub(view, onLayoutItemNotFound); bool callBase = true; OnSetContentView(view, @params, ref callBase); if (callBase) { base.SetContentView(view, @params); } }
public override void SetContentView(global::Android.Views.View view, global::Android.Views.ViewGroup.LayoutParams @params) { __layout_binding = new global::Binding.ActivitySub(view); bool callBase = true; OnSetContentView(view, @params, ref callBase); if (callBase) { base.SetContentView(view, @params); } }
public ActivitySub( global::Android.Views.View client, global::Xamarin.Android.Design.OnLayoutItemNotFoundHandler itemNotFoundHandler = null) : base(client, itemNotFoundHandler) { }
partial void OnSetContentView(global::Android.Views.View view, global::Android.Views.ViewGroup.LayoutParams @params, ref bool callBaseAfterReturn);
partial void OnSetContentView(global::Android.Views.View view, ref bool callBaseAfterReturn);
void OnTouch(object sender, global::Android.Views.View.TouchEventArgs args) { // Two object common to all the events global::Android.Views.View senderView = sender as global::Android.Views.View; MotionEvent motionEvent = args.Event; // Get the pointer index int pointerIndex = motionEvent.ActionIndex; // Get the id that identifies a finger over the course of its progress int id = motionEvent.GetPointerId(pointerIndex); senderView.GetLocationOnScreen(twoIntArray); Point screenPointerCoords = new Point(twoIntArray[0] + motionEvent.GetX(pointerIndex), twoIntArray[1] + motionEvent.GetY(pointerIndex)); // Use ActionMasked here rather than Action to reduce the number of possibilities switch (args.Event.ActionMasked) { case MotionEventActions.Down: case MotionEventActions.PointerDown: FireEvent(this, id, TouchActionType.Pressed, screenPointerCoords, true); if (!idToEffectDictionary.ContainsKey(id)) { idToEffectDictionary.Add(id, this); } capture = pclTouchEffect.Capture; break; case MotionEventActions.Move: // Multiple Move events are bundled, so handle them in a loop for (pointerIndex = 0; pointerIndex < motionEvent.PointerCount; pointerIndex++) { id = motionEvent.GetPointerId(pointerIndex); if (capture) { senderView.GetLocationOnScreen(twoIntArray); screenPointerCoords = new Point(twoIntArray[0] + motionEvent.GetX(pointerIndex), twoIntArray[1] + motionEvent.GetY(pointerIndex)); FireEvent(this, id, TouchActionType.Moved, screenPointerCoords, true); } else { CheckForBoundaryHop(id, screenPointerCoords); if (idToEffectDictionary[id] != null) { FireEvent(idToEffectDictionary[id], id, TouchActionType.Moved, screenPointerCoords, true); } } } break; case MotionEventActions.Up: case MotionEventActions.Pointer1Up: if (capture) { FireEvent(this, id, TouchActionType.Released, screenPointerCoords, false); } else { CheckForBoundaryHop(id, screenPointerCoords); if (idToEffectDictionary[id] != null) { FireEvent(idToEffectDictionary[id], id, TouchActionType.Released, screenPointerCoords, false); } } idToEffectDictionary.Remove(id); break; case MotionEventActions.Cancel: if (capture) { FireEvent(this, id, TouchActionType.Cancelled, screenPointerCoords, false); } else { if (idToEffectDictionary[id] != null) { FireEvent(idToEffectDictionary[id], id, TouchActionType.Cancelled, screenPointerCoords, false); } } idToEffectDictionary.Remove(id); break; } }