Пример #1
0
 /// <summary>
 /// <p>Parses a sequence of columns ids defined in a CharSequence with the
 /// following pattern (regex): \d+(\s*,\s*\d+)*</p>
 /// <p>Examples: "1" or "13, 7, 6" or "".</p>
 /// <p>The result of the parsing is stored in a sparse boolean array.
 /// </summary>
 /// <remarks>
 /// <p>Parses a sequence of columns ids defined in a CharSequence with the
 /// following pattern (regex): \d+(\s*,\s*\d+)*</p>
 /// <p>Examples: "1" or "13, 7, 6" or "".</p>
 /// <p>The result of the parsing is stored in a sparse boolean array. The
 /// parsed column ids are used as the keys of the sparse array. The values
 /// are always true.</p>
 /// </remarks>
 /// <param name="sequence">a sequence of column ids, can be empty but not null</param>
 /// <returns>
 /// a sparse array of boolean mapping column indexes to the columns
 /// collapse state
 /// </returns>
 private static android.util.SparseBooleanArray parseColumns(string sequence)
 {
     android.util.SparseBooleanArray columns = new android.util.SparseBooleanArray();
     java.util.regex.Pattern         pattern = java.util.regex.Pattern.compile("\\s*,\\s*");
     string[] columnDefs = pattern.split(java.lang.CharSequenceProxy.Wrap(sequence));
     foreach (string columnIdentifier in columnDefs)
     {
         try
         {
             int columnIndex = System.Convert.ToInt32(columnIdentifier);
             // only valid, i.e. positive, columns indexes are handled
             if (columnIndex >= 0)
             {
                 // putting true in this sparse array indicates that the
                 // column index was defined in the XML file
                 columns.put(columnIndex, true);
             }
         }
         catch (System.ArgumentException)
         {
         }
     }
     // we just ignore columns that don't exist
     return(columns);
 }
Пример #2
0
 public virtual android.util.SparseBooleanArray clone()
 {
     android.util.SparseBooleanArray clone_1 = null;
     clone_1         = (android.util.SparseBooleanArray)base.MemberwiseClone();
     clone_1.mKeys   = (int[])mKeys.Clone();
     clone_1.mValues = (bool[])mValues.Clone();
     return(clone_1);
 }
Пример #3
0
        /// <summary>
        /// <p>Creates a new TableLayout for the given context and with the
        /// specified set attributes.</p>
        /// </summary>
        /// <param name="context">the application environment</param>
        /// <param name="attrs">a collection of attributes</param>
        public TableLayout(android.content.Context context, android.util.AttributeSet attrs
                           ) : base(context, attrs)
        {
            android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                              .styleable.TableLayout);
            string stretchedColumns = a.getString([email protected]_stretchColumns
                                                  );

            if (stretchedColumns != null)
            {
                if (stretchedColumns[0] == '*')
                {
                    mStretchAllColumns = true;
                }
                else
                {
                    mStretchableColumns = parseColumns(stretchedColumns);
                }
            }
            string shrinkedColumns = a.getString([email protected]_shrinkColumns
                                                 );

            if (shrinkedColumns != null)
            {
                if (shrinkedColumns[0] == '*')
                {
                    mShrinkAllColumns = true;
                }
                else
                {
                    mShrinkableColumns = parseColumns(shrinkedColumns);
                }
            }
            string collapsedColumns = a.getString([email protected]_collapseColumns
                                                  );

            if (collapsedColumns != null)
            {
                mCollapsedColumns = parseColumns(collapsedColumns);
            }
            a.recycle();
            initTableLayout();
        }
Пример #4
0
 /// <summary>
 /// <p>Performs initialization common to prorgrammatic use and XML use of
 /// this widget.</p>
 /// </summary>
 private void initTableLayout()
 {
     if (mCollapsedColumns == null)
     {
         mCollapsedColumns = new android.util.SparseBooleanArray();
     }
     if (mStretchableColumns == null)
     {
         mStretchableColumns = new android.util.SparseBooleanArray();
     }
     if (mShrinkableColumns == null)
     {
         mShrinkableColumns = new android.util.SparseBooleanArray();
     }
     mPassThroughListener = new android.widget.TableLayout.PassThroughHierarchyChangeListener
                                (this);
     // make sure to call the parent class method to avoid potential
     // infinite loops
     base.setOnHierarchyChangeListener(mPassThroughListener);
     mInitialized = true;
 }
Пример #5
0
 /// <summary>
 /// <p>Applies the columns collapse status to a new row added to this
 /// table.
 /// </summary>
 /// <remarks>
 /// <p>Applies the columns collapse status to a new row added to this
 /// table. This method is invoked by PassThroughHierarchyChangeListener
 /// upon child insertion.</p>
 /// <p>This method only applies to
 /// <see cref="TableRow">TableRow</see>
 /// instances.</p>
 /// </remarks>
 /// <param name="child">the newly added child</param>
 private void trackCollapsedColumns(android.view.View child)
 {
     if (child is android.widget.TableRow)
     {
         android.widget.TableRow         row = (android.widget.TableRow)child;
         android.util.SparseBooleanArray collapsedColumns = mCollapsedColumns;
         int count = collapsedColumns.size();
         {
             for (int i = 0; i < count; i++)
             {
                 int  columnIndex = collapsedColumns.keyAt(i);
                 bool isCollapsed = collapsedColumns.valueAt(i);
                 // the collapse status is set only when the column should be
                 // collapsed; otherwise, this might affect the default
                 // visibility of the row's children
                 if (isCollapsed)
                 {
                     row.setColumnCollapsed(columnIndex, isCollapsed);
                 }
             }
         }
     }
 }
Пример #6
0
		/// <summary>
		/// <p>Creates a new TableLayout for the given context and with the
		/// specified set attributes.</p>
		/// </summary>
		/// <param name="context">the application environment</param>
		/// <param name="attrs">a collection of attributes</param>
		public TableLayout(android.content.Context context, android.util.AttributeSet attrs
			) : base(context, attrs)
		{
			android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
				.styleable.TableLayout);
			string stretchedColumns = a.getString([email protected]_stretchColumns
				);
			if (stretchedColumns != null)
			{
				if (stretchedColumns[0] == '*')
				{
					mStretchAllColumns = true;
				}
				else
				{
					mStretchableColumns = parseColumns(stretchedColumns);
				}
			}
			string shrinkedColumns = a.getString([email protected]_shrinkColumns
				);
			if (shrinkedColumns != null)
			{
				if (shrinkedColumns[0] == '*')
				{
					mShrinkAllColumns = true;
				}
				else
				{
					mShrinkableColumns = parseColumns(shrinkedColumns);
				}
			}
			string collapsedColumns = a.getString([email protected]_collapseColumns
				);
			if (collapsedColumns != null)
			{
				mCollapsedColumns = parseColumns(collapsedColumns);
			}
			a.recycle();
			initTableLayout();
		}
Пример #7
0
		/// <summary>
		/// <p>Performs initialization common to prorgrammatic use and XML use of
		/// this widget.</p>
		/// </summary>
		private void initTableLayout()
		{
			if (mCollapsedColumns == null)
			{
				mCollapsedColumns = new android.util.SparseBooleanArray();
			}
			if (mStretchableColumns == null)
			{
				mStretchableColumns = new android.util.SparseBooleanArray();
			}
			if (mShrinkableColumns == null)
			{
				mShrinkableColumns = new android.util.SparseBooleanArray();
			}
			mPassThroughListener = new android.widget.TableLayout.PassThroughHierarchyChangeListener
				(this);
			// make sure to call the parent class method to avoid potential
			// infinite loops
			base.setOnHierarchyChangeListener(mPassThroughListener);
			mInitialized = true;
		}
Пример #8
0
		/// <summary>
		/// <p>Parses a sequence of columns ids defined in a CharSequence with the
		/// following pattern (regex): \d+(\s*,\s*\d+)*</p>
		/// <p>Examples: "1" or "13, 7, 6" or "".</p>
		/// <p>The result of the parsing is stored in a sparse boolean array.
		/// </summary>
		/// <remarks>
		/// <p>Parses a sequence of columns ids defined in a CharSequence with the
		/// following pattern (regex): \d+(\s*,\s*\d+)*</p>
		/// <p>Examples: "1" or "13, 7, 6" or "".</p>
		/// <p>The result of the parsing is stored in a sparse boolean array. The
		/// parsed column ids are used as the keys of the sparse array. The values
		/// are always true.</p>
		/// </remarks>
		/// <param name="sequence">a sequence of column ids, can be empty but not null</param>
		/// <returns>
		/// a sparse array of boolean mapping column indexes to the columns
		/// collapse state
		/// </returns>
		private static android.util.SparseBooleanArray parseColumns(string sequence)
		{
			android.util.SparseBooleanArray columns = new android.util.SparseBooleanArray();
			java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("\\s*,\\s*");
			string[] columnDefs = pattern.split(java.lang.CharSequenceProxy.Wrap(sequence));
			foreach (string columnIdentifier in columnDefs)
			{
				try
				{
					int columnIndex = System.Convert.ToInt32(columnIdentifier);
					// only valid, i.e. positive, columns indexes are handled
					if (columnIndex >= 0)
					{
						// putting true in this sparse array indicates that the
						// column index was defined in the XML file
						columns.put(columnIndex, true);
					}
				}
				catch (System.ArgumentException)
				{
				}
			}
			// we just ignore columns that don't exist
			return columns;
		}
Пример #9
0
        private void mutateColumnsWidth(android.util.SparseBooleanArray columns, bool allColumns
                                        , int size, int totalWidth)
        {
            int skipped = 0;

            int[] maxWidths       = mMaxWidths;
            int   length          = maxWidths.Length;
            int   count           = allColumns ? length : columns.size();
            int   totalExtraSpace = size - totalWidth;
            int   extraSpace      = totalExtraSpace / count;
            // Column's widths are changed: force child table rows to re-measure.
            // (done by super.measureVertical after shrinkAndStretchColumns.)
            int nbChildren = getChildCount();

            {
                for (int i = 0; i < nbChildren; i++)
                {
                    android.view.View child = getChildAt(i);
                    if (child is android.widget.TableRow)
                    {
                        child.forceLayout();
                    }
                }
            }
            if (!allColumns)
            {
                {
                    for (int i_1 = 0; i_1 < count; i_1++)
                    {
                        int column = columns.keyAt(i_1);
                        if (columns.valueAt(i_1))
                        {
                            if (column < length)
                            {
                                maxWidths[column] += extraSpace;
                            }
                            else
                            {
                                skipped++;
                            }
                        }
                    }
                }
            }
            else
            {
                {
                    for (int i_1 = 0; i_1 < count; i_1++)
                    {
                        maxWidths[i_1] += extraSpace;
                    }
                }
                // we don't skip any column so we can return right away
                return;
            }
            if (skipped > 0 && skipped < count)
            {
                // reclaim any extra space we left to columns that don't exist
                extraSpace = skipped * extraSpace / (count - skipped);
                {
                    for (int i_1 = 0; i_1 < count; i_1++)
                    {
                        int column = columns.keyAt(i_1);
                        if (columns.valueAt(i_1) && column < length)
                        {
                            if (extraSpace > maxWidths[column])
                            {
                                maxWidths[column] = 0;
                            }
                            else
                            {
                                maxWidths[column] += extraSpace;
                            }
                        }
                    }
                }
            }
        }
Пример #10
0
 public void writeSparseBooleanArray(android.util.SparseBooleanArray val)
 {
     throw new System.NotImplementedException();
 }
Пример #11
0
        public override bool flagActionItems()
        {
            java.util.ArrayList <*****@*****.**> visibleItems = mMenu
                                                                                          .getVisibleItems();
            int itemsSize  = visibleItems.size();
            int maxActions = mMaxItems;
            int widthLimit = mActionItemWidthLimit;
            int querySpec  = android.view.View.MeasureSpec.makeMeasureSpec(0, android.view.View
                                                                           .MeasureSpec.UNSPECIFIED);

            android.view.ViewGroup parent = (android.view.ViewGroup)mMenuView;
            int  requiredItems            = 0;
            int  requestedItems           = 0;
            int  firstActionWidth         = 0;
            bool hasOverflow = false;

            {
                for (int i = 0; i < itemsSize; i++)
                {
                    [email protected] item = visibleItems.get(i);
                    if (item.requiresActionButton())
                    {
                        requiredItems++;
                    }
                    else
                    {
                        if (item.requestsActionButton())
                        {
                            requestedItems++;
                        }
                        else
                        {
                            hasOverflow = true;
                        }
                    }
                    if (mExpandedActionViewsExclusive && item.isActionViewExpanded())
                    {
                        // Overflow everything if we have an expanded action view and we're
                        // space constrained.
                        maxActions = 0;
                    }
                }
            }
            // Reserve a spot for the overflow item if needed.
            if (mReserveOverflow && (hasOverflow || requiredItems + requestedItems > maxActions
                                     ))
            {
                maxActions--;
            }
            maxActions -= requiredItems;
            android.util.SparseBooleanArray seenGroups = mActionButtonGroups;
            seenGroups.clear();
            int cellSize       = 0;
            int cellsRemaining = 0;

            if (mStrictWidthLimit)
            {
                cellsRemaining = widthLimit / mMinCellSize;
                int cellSizeRemaining = widthLimit % mMinCellSize;
                cellSize = mMinCellSize + cellSizeRemaining / cellsRemaining;
            }
            {
                // Flag as many more requested items as will fit.
                for (int i_1 = 0; i_1 < itemsSize; i_1++)
                {
                    [email protected] item = visibleItems.get(i_1);
                    if (item.requiresActionButton())
                    {
                        android.view.View v = getItemView(item, mScrapActionButtonView, parent);
                        if (mScrapActionButtonView == null)
                        {
                            mScrapActionButtonView = v;
                        }
                        if (mStrictWidthLimit)
                        {
                            cellsRemaining -= [email protected]
                                                  (v, cellSize, cellsRemaining, querySpec, 0);
                        }
                        else
                        {
                            v.measure(querySpec, querySpec);
                        }
                        int measuredWidth = v.getMeasuredWidth();
                        widthLimit -= measuredWidth;
                        if (firstActionWidth == 0)
                        {
                            firstActionWidth = measuredWidth;
                        }
                        int groupId = item.getGroupId();
                        if (groupId != 0)
                        {
                            seenGroups.put(groupId, true);
                        }
                        item.setIsActionButton(true);
                    }
                    else
                    {
                        if (item.requestsActionButton())
                        {
                            // Items in a group with other items that already have an action slot
                            // can break the max actions rule, but not the width limit.
                            int  groupId  = item.getGroupId();
                            bool inGroup  = seenGroups.get(groupId);
                            bool isAction = (maxActions > 0 || inGroup) && widthLimit > 0 && (!mStrictWidthLimit ||
                                                                                              cellsRemaining > 0);
                            if (isAction)
                            {
                                android.view.View v = getItemView(item, mScrapActionButtonView, parent);
                                if (mScrapActionButtonView == null)
                                {
                                    mScrapActionButtonView = v;
                                }
                                if (mStrictWidthLimit)
                                {
                                    int cells = [email protected](v, cellSize
                                                                                                                , cellsRemaining, querySpec, 0);
                                    cellsRemaining -= cells;
                                    if (cells == 0)
                                    {
                                        isAction = false;
                                    }
                                }
                                else
                                {
                                    v.measure(querySpec, querySpec);
                                }
                                int measuredWidth = v.getMeasuredWidth();
                                widthLimit -= measuredWidth;
                                if (firstActionWidth == 0)
                                {
                                    firstActionWidth = measuredWidth;
                                }
                                if (mStrictWidthLimit)
                                {
                                    isAction &= widthLimit >= 0;
                                }
                                else
                                {
                                    // Did this push the entire first item past the limit?
                                    isAction &= widthLimit + firstActionWidth > 0;
                                }
                            }
                            if (isAction && groupId != 0)
                            {
                                seenGroups.put(groupId, true);
                            }
                            else
                            {
                                if (inGroup)
                                {
                                    // We broke the width limit. Demote the whole group, they all overflow now.
                                    seenGroups.put(groupId, false);
                                    {
                                        for (int j = 0; j < i_1; j++)
                                        {
                                            [email protected] areYouMyGroupie = visibleItems.get(j);
                                            if (areYouMyGroupie.getGroupId() == groupId)
                                            {
                                                // Give back the action slot
                                                if (areYouMyGroupie.isActionButton())
                                                {
                                                    maxActions++;
                                                }
                                                areYouMyGroupie.setIsActionButton(false);
                                            }
                                        }
                                    }
                                }
                            }
                            if (isAction)
                            {
                                maxActions--;
                            }
                            item.setIsActionButton(isAction);
                        }
                    }
                }
            }
            return(true);
        }