Guest User

Untitled

a guest
Jan 20th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. public override IBinder OnBind(Intent intent)
  2. {
  3. throw new System.NotImplementedException();
  4. }
  5.  
  6. public bool OnTouch(View v, MotionEvent e)
  7. {
  8. switch (e.Action)
  9. {
  10. case MotionEventActions.Up:
  11. closeFloatingView.Visibility = ViewStates.Gone;
  12.  
  13. initialX = layoutParams.X;
  14. initialY = layoutParams.Y;
  15.  
  16. if (initialX + v.Width / 2 <= centerX + CLOSING_THRESHOLD && initialX + v.Width / 2 >= centerX - CLOSING_THRESHOLD)
  17. if (initialY + v.Height / 2 <= centerY + CLOSING_THRESHOLD && initialY + v.Height / 2 >= centerY - CLOSING_THRESHOLD)
  18. {
  19. floatingView.Visibility = ViewStates.Gone;
  20. StopSelf();
  21. }
  22. return true;
  23.  
  24. case MotionEventActions.Down:
  25. initialX = layoutParams.X;
  26. initialY = layoutParams.Y;
  27.  
  28. initialTouchX = e.RawX;
  29. initialTouchY = e.RawY;
  30. return true;
  31.  
  32. case MotionEventActions.Move:
  33. layoutParams.X = initialX + (int)(e.RawX - initialTouchX);
  34. layoutParams.Y = initialY + (int)(e.RawY - initialTouchY);
  35.  
  36. closeFloatingView.Visibility = ViewStates.Visible;
  37. windowManager.UpdateViewLayout(floatingView, layoutParams);
  38.  
  39. return true;
  40. }
  41.  
  42. return false;
  43. }
Add Comment
Please, Sign In to add comment