Ejemplo n.º 1
0
 /// <summary>Recycle the DragEvent, to be re-used by a later caller.</summary>
 /// <remarks>
 /// Recycle the DragEvent, to be re-used by a later caller.  After calling
 /// this function you must never touch the event again.
 /// </remarks>
 /// <hide></hide>
 public void recycle()
 {
     // Ensure recycle is only called once!
     if (mRecycled)
     {
         throw new java.lang.RuntimeException(ToString() + " recycled twice!");
     }
     mRecycled        = true;
     mClipData        = null;
     mClipDescription = null;
     mLocalState      = null;
     lock (gRecyclerLock)
     {
         if (gRecyclerUsed < MAX_RECYCLED)
         {
             gRecyclerUsed++;
             mNext        = gRecyclerTop;
             gRecyclerTop = this;
         }
     }
 }
Ejemplo n.º 2
0
 /// <hide></hide>
 public static android.view.DragEvent obtain(int action, float x, float y, object
                                             localState, android.content.ClipDescription description, android.content.ClipData
                                             data, bool result)
 {
     android.view.DragEvent ev;
     lock (gRecyclerLock)
     {
         if (gRecyclerTop == null)
         {
             ev = new android.view.DragEvent();
             ev.init(action, x, y, description, data, localState, result);
             return(ev);
         }
         ev             = gRecyclerTop;
         gRecyclerTop   = ev.mNext;
         gRecyclerUsed -= 1;
     }
     ev.mRecycledLocation = null;
     ev.mRecycled         = false;
     ev.mNext             = null;
     ev.init(action, x, y, description, data, localState, result);
     return(ev);
 }
Ejemplo n.º 3
0
 /// <hide></hide>
 public static android.view.DragEvent obtain(android.view.DragEvent source)
 {
     return(obtain(source.mAction, source.mX, source.mY, source.mLocalState, source.mClipDescription
                   , source.mClipData, source.mDragResult));
 }
Ejemplo n.º 4
0
		internal override void dispatchDetachedFromWindow()
		{
			// If we still have a touch target, we are still in the process of
			// dispatching motion events to a child; we need to get rid of that
			// child to avoid dispatching events to it after the window is torn
			// down. To make sure we keep the child in a consistent state, we
			// first send it an ACTION_CANCEL motion event.
			cancelAndClearTouchTargets(null);
			// In case view is detached while transition is running
			mLayoutSuppressed = false;
			// Tear down our drag tracking
			mDragNotifiedChildren = null;
			if (mCurrentDrag != null)
			{
				mCurrentDrag.recycle();
				mCurrentDrag = null;
			}
			int count = mChildrenCount;
			android.view.View[] children = mChildren;
			{
				for (int i = 0; i < count; i++)
				{
					children[i].dispatchDetachedFromWindow();
				}
			}
			base.dispatchDetachedFromWindow();
		}
Ejemplo n.º 5
0
		public override bool dispatchDragEvent(android.view.DragEvent @event)
		{
			bool retval = false;
			float tx = @event.mX;
			float ty = @event.mY;
			android.view.ViewRootImpl root = getViewRootImpl();
			switch (@event.mAction)
			{
				case android.view.DragEvent.ACTION_DRAG_STARTED:
				{
					// Dispatch down the view hierarchy
					// clear state to recalculate which views we drag over
					mCurrentDragView = null;
					// Set up our tracking of drag-started notifications
					mCurrentDrag = android.view.DragEvent.obtain(@event);
					if (mDragNotifiedChildren == null)
					{
						mDragNotifiedChildren = new java.util.HashSet<android.view.View>();
					}
					else
					{
						mDragNotifiedChildren.clear();
					}
					// Now dispatch down to our children, caching the responses
					mChildAcceptsDrag = false;
					int count = mChildrenCount;
					android.view.View[] children = mChildren;
					{
						for (int i = 0; i < count; i++)
						{
							android.view.View child = children[i];
							child.mPrivateFlags2 &= ~android.view.View.DRAG_MASK;
							if (child.getVisibility() == VISIBLE)
							{
								bool handled = notifyChildOfDrag(children[i]);
								if (handled)
								{
									mChildAcceptsDrag = true;
								}
							}
						}
					}
					// Return HANDLED if one of our children can accept the drag
					if (mChildAcceptsDrag)
					{
						retval = true;
					}
					break;
				}

				case android.view.DragEvent.ACTION_DRAG_ENDED:
				{
					// Release the bookkeeping now that the drag lifecycle has ended
					if (mDragNotifiedChildren != null)
					{
						foreach (android.view.View child in Sharpen.IterableProxy.Create(mDragNotifiedChildren
							))
						{
							// If a child was notified about an ongoing drag, it's told that it's over
							child.dispatchDragEvent(@event);
							child.mPrivateFlags2 &= ~android.view.View.DRAG_MASK;
							child.refreshDrawableState();
						}
						mDragNotifiedChildren.clear();
						mCurrentDrag.recycle();
						mCurrentDrag = null;
					}
					// We consider drag-ended to have been handled if one of our children
					// had offered to handle the drag.
					if (mChildAcceptsDrag)
					{
						retval = true;
					}
					break;
				}

				case android.view.DragEvent.ACTION_DRAG_LOCATION:
				{
					// Find the [possibly new] drag target
					android.view.View target = findFrontmostDroppableChildAt(@event.mX, @event.mY, mLocalPoint
						);
					// If we've changed apparent drag target, tell the view root which view
					// we're over now [for purposes of the eventual drag-recipient-changed
					// notifications to the framework] and tell the new target that the drag
					// has entered its bounds.  The root will see setDragFocus() calls all
					// the way down to the final leaf view that is handling the LOCATION event
					// before reporting the new potential recipient to the framework.
					if (mCurrentDragView != target)
					{
						root.setDragFocus(target);
						int action = @event.mAction;
						// If we've dragged off of a child view, send it the EXITED message
						if (mCurrentDragView != null)
						{
							android.view.View view = mCurrentDragView;
							@event.mAction = android.view.DragEvent.ACTION_DRAG_EXITED;
							view.dispatchDragEvent(@event);
							view.mPrivateFlags2 &= ~android.view.View.DRAG_HOVERED;
							view.refreshDrawableState();
						}
						mCurrentDragView = target;
						// If we've dragged over a new child view, send it the ENTERED message
						if (target != null)
						{
							@event.mAction = android.view.DragEvent.ACTION_DRAG_ENTERED;
							target.dispatchDragEvent(@event);
							target.mPrivateFlags2 |= android.view.View.DRAG_HOVERED;
							target.refreshDrawableState();
						}
						@event.mAction = action;
					}
					// restore the event's original state
					// Dispatch the actual drag location notice, localized into its coordinates
					if (target != null)
					{
						@event.mX = mLocalPoint.x;
						@event.mY = mLocalPoint.y;
						retval = target.dispatchDragEvent(@event);
						@event.mX = tx;
						@event.mY = ty;
					}
					break;
				}

				case android.view.DragEvent.ACTION_DRAG_EXITED:
				{
					if (mCurrentDragView != null)
					{
						android.view.View view = mCurrentDragView;
						view.dispatchDragEvent(@event);
						view.mPrivateFlags2 &= ~android.view.View.DRAG_HOVERED;
						view.refreshDrawableState();
						mCurrentDragView = null;
					}
					break;
				}

				case android.view.DragEvent.ACTION_DROP:
				{
					android.view.View target = findFrontmostDroppableChildAt(@event.mX, @event.mY, mLocalPoint
						);
					if (target != null)
					{
						@event.mX = mLocalPoint.x;
						@event.mY = mLocalPoint.y;
						retval = target.dispatchDragEvent(@event);
						@event.mX = tx;
						@event.mY = ty;
					}
					break;
				}
			}
			// If none of our children could handle the event, try here
			if (!retval)
			{
				// Call up to the View implementation that dispatches to installed listeners
				retval = base.dispatchDragEvent(@event);
			}
			return retval;
		}
Ejemplo n.º 6
0
 public virtual bool onDragEvent(DragEvent @event)
 {
     return(false);
 }
Ejemplo n.º 7
0
 public override void dispatchDragEvent(android.view.DragEvent @event)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 8
0
 public abstract void dispatchDragEvent(android.view.DragEvent arg1);