示例#1
0
		private void addViewInner(android.view.View child, int index, android.view.ViewGroup
			.LayoutParams @params, bool preventRequestLayout)
		{
			if (mTransition != null)
			{
				// Don't prevent other add transitions from completing, but cancel remove
				// transitions to let them complete the process before we add to the container
				mTransition.cancel(android.animation.LayoutTransition.DISAPPEARING);
			}
			if (child.getParent() != null)
			{
				throw new System.InvalidOperationException("The specified child already has a parent. "
					 + "You must call removeView() on the child's parent first.");
			}
			if (mTransition != null)
			{
				mTransition.addChild(this, child);
			}
			if (!checkLayoutParams(@params))
			{
				@params = generateLayoutParams(@params);
			}
			if (preventRequestLayout)
			{
				child.mLayoutParams = @params;
			}
			else
			{
				child.setLayoutParams(@params);
			}
			if (index < 0)
			{
				index = mChildrenCount;
			}
			addInArray(child, index);
			// tell our children
			if (preventRequestLayout)
			{
				child.assignParent(this);
			}
			else
			{
				child.mParent = this;
			}
			if (child.hasFocus())
			{
				requestChildFocus(child, child.findFocus());
			}
			android.view.View.AttachInfo ai = mAttachInfo;
			if (ai != null && (mGroupFlags & FLAG_PREVENT_DISPATCH_ATTACHED_TO_WINDOW) == 0)
			{
				bool lastKeepOn = ai.mKeepScreenOn;
				ai.mKeepScreenOn = false;
				child.dispatchAttachedToWindow(mAttachInfo, (mViewFlags & VISIBILITY_MASK));
				if (ai.mKeepScreenOn)
				{
					needGlobalAttributesUpdate(true);
				}
				ai.mKeepScreenOn = lastKeepOn;
			}
			onViewAdded(child);
			if ((child.mViewFlags & DUPLICATE_PARENT_STATE) == DUPLICATE_PARENT_STATE)
			{
				mGroupFlags |= FLAG_NOTIFY_CHILDREN_ON_DRAWABLE_STATE_CHANGE;
			}
		}
示例#2
0
		/// <summary>Add an item view at the given index.</summary>
		/// <remarks>Add an item view at the given index.</remarks>
		/// <param name="itemView">View to add</param>
		/// <param name="childIndex">Index within the parent to insert at</param>
		protected internal virtual void addItemView(android.view.View itemView, int childIndex
			)
		{
			android.view.ViewGroup currentParent = (android.view.ViewGroup)itemView.getParent
				();
			if (currentParent != null)
			{
				currentParent.removeView(itemView);
			}
			((android.view.ViewGroup)mMenuView).addView(itemView, childIndex);
		}
示例#3
0
		/// <summary>Return true if child is an descendant of parent, (or equal to the parent).
		/// 	</summary>
		/// <remarks>Return true if child is an descendant of parent, (or equal to the parent).
		/// 	</remarks>
		private bool isViewDescendantOf(android.view.View child, android.view.View parent
			)
		{
			if (child == parent)
			{
				return true;
			}
			android.view.ViewParent theParent = child.getParent();
			return (theParent is android.view.ViewGroup) && isViewDescendantOf((android.view.View
				)theParent, parent);
		}
		public override bool onTouchEvent(android.widget.TextView widget, android.text.Spannable
			 buffer, android.view.MotionEvent @event)
		{
			int initialScrollX = -1;
			int initialScrollY = -1;
			int action = @event.getAction();
			if (action == android.view.MotionEvent.ACTION_UP)
			{
				initialScrollX = android.text.method.Touch.getInitialScrollX(widget, buffer);
				initialScrollY = android.text.method.Touch.getInitialScrollY(widget, buffer);
			}
			bool handled = android.text.method.Touch.onTouchEvent(widget, buffer, @event);
			if (widget.isFocused() && !widget.didTouchFocusSelect())
			{
				if (action == android.view.MotionEvent.ACTION_DOWN)
				{
					if (isSelecting(buffer))
					{
						int offset = widget.getOffsetForPosition(@event.getX(), @event.getY());
						buffer.setSpan(LAST_TAP_DOWN, offset, offset, android.text.SpannedClass.SPAN_POINT_POINT
							);
						// Disallow intercepting of the touch events, so that
						// users can scroll and select at the same time.
						// without this, users would get booted out of select
						// mode once the view detected it needed to scroll.
						widget.getParent().requestDisallowInterceptTouchEvent(true);
					}
				}
				else
				{
					if (action == android.view.MotionEvent.ACTION_MOVE)
					{
						if (isSelecting(buffer) && handled)
						{
							// Before selecting, make sure we've moved out of the "slop".
							// handled will be true, if we're in select mode AND we're
							// OUT of the slop
							// Turn long press off while we're selecting. User needs to
							// re-tap on the selection to enable long press
							widget.cancelLongPress();
							// Update selection as we're moving the selection area.
							// Get the current touch position
							int offset = widget.getOffsetForPosition(@event.getX(), @event.getY());
							android.text.Selection.extendSelection(buffer, offset);
							return true;
						}
					}
					else
					{
						if (action == android.view.MotionEvent.ACTION_UP)
						{
							// If we have scrolled, then the up shouldn't move the cursor,
							// but we do need to make sure the cursor is still visible at
							// the current scroll offset to avoid the scroll jumping later
							// to show it.
							if ((initialScrollY >= 0 && initialScrollY != widget.getScrollY()) || (initialScrollX
								 >= 0 && initialScrollX != widget.getScrollX()))
							{
								widget.moveCursorToVisibleOffset();
								return true;
							}
							int offset = widget.getOffsetForPosition(@event.getX(), @event.getY());
							if (isSelecting(buffer))
							{
								buffer.removeSpan(LAST_TAP_DOWN);
								android.text.Selection.extendSelection(buffer, offset);
							}
							else
							{
								if (!widget.shouldIgnoreActionUpEvent())
								{
									android.text.Selection.setSelection(buffer, offset);
								}
							}
							android.text.method.MetaKeyKeyListener.adjustMetaAfterKeypress(buffer);
							android.text.method.MetaKeyKeyListener.resetLockedMeta(buffer);
							return true;
						}
					}
				}
			}
			return handled;
		}
示例#5
0
		public virtual android.view.WindowManagerClass.LayoutParams getRootViewLayoutParameter
			(android.view.View view)
		{
			android.view.ViewParent vp = view.getParent();
			while (vp != null && !(vp is android.view.ViewRootImpl))
			{
				vp = vp.getParent();
			}
			if (vp == null)
			{
				return null;
			}
			android.view.ViewRootImpl vr = (android.view.ViewRootImpl)vp;
			int N = mRoots.Length;
			{
				for (int i = 0; i < N; ++i)
				{
					if (mRoots[i] == vr)
					{
						return mParams[i];
					}
				}
			}
			return null;
		}
示例#6
0
			internal virtual void invalidateGlobalRegion(android.view.View v, android.graphics.Rect
				 r)
			{
				// We need to make a new rect here, so as not to modify the one passed
				this.globalInvalidateRect.set(r);
				this.globalInvalidateRect.union(0, 0, this._enclosing.getWidth(), this._enclosing
					.getHeight());
				android.view.View p = v;
				if (!(v.getParent() != null && v.getParent() is android.view.View))
				{
					return;
				}
				bool firstPass = true;
				this.parentRect.set(0, 0, 0, 0);
				while (p.getParent() != null && p.getParent() is android.view.View && !this.parentRect
					.contains(this.globalInvalidateRect))
				{
					if (!firstPass)
					{
						this.globalInvalidateRect.offset(p.getLeft() - p.getScrollX(), p.getTop() - p.getScrollY
							());
					}
					firstPass = false;
					p = (android.view.View)p.getParent();
					this.parentRect.set(p.getScrollX(), p.getScrollY(), p.getWidth() + p.getScrollX()
						, p.getHeight() + p.getScrollY());
					p.invalidate(this.globalInvalidateRect.left, this.globalInvalidateRect.top, this.
						globalInvalidateRect.right, this.globalInvalidateRect.bottom);
				}
				p.invalidate(this.globalInvalidateRect.left, this.globalInvalidateRect.top, this.
					globalInvalidateRect.right, this.globalInvalidateRect.bottom);
			}