Example #1
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);
                 }
             }
         }
     }
 }
Example #2
0
 /// <summary><p>Finds the largest cell in each column.</summary>
 /// <remarks>
 /// <p>Finds the largest cell in each column. For each column, the width of
 /// the largest cell is applied to all the other cells.</p>
 /// </remarks>
 /// <param name="widthMeasureSpec">the measure constraint imposed by our parent</param>
 private void findLargestCells(int widthMeasureSpec)
 {
     bool firstRow = true;
     // find the maximum width for each column
     // the total number of columns is dynamically changed if we find
     // wider rows as we go through the children
     // the array is reused for each layout operation; the array can grow
     // but never shrinks. Unused extra cells in the array are just ignored
     // this behavior avoids to unnecessary grow the array after the first
     // layout operation
     int count = getChildCount();
     {
         for (int i = 0; i < count; i++)
         {
             android.view.View child = getChildAt(i);
             if (child.getVisibility() == GONE)
             {
                 continue;
             }
             if (child is android.widget.TableRow)
             {
                 android.widget.TableRow row = (android.widget.TableRow)child;
                 // forces the row's height
                 android.view.ViewGroup.LayoutParams layoutParams = row.getLayoutParams();
                 layoutParams.height = android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
                 int[] widths    = row.getColumnsWidths(widthMeasureSpec);
                 int   newLength = widths.Length;
                 // this is the first row, we just need to copy the values
                 if (firstRow)
                 {
                     if (mMaxWidths == null || mMaxWidths.Length != newLength)
                     {
                         mMaxWidths = new int[newLength];
                     }
                     System.Array.Copy(widths, 0, mMaxWidths, 0, newLength);
                     firstRow = false;
                 }
                 else
                 {
                     int length     = mMaxWidths.Length;
                     int difference = newLength - length;
                     // the current row is wider than the previous rows, so
                     // we just grow the array and copy the values
                     if (difference > 0)
                     {
                         int[] oldMaxWidths = mMaxWidths;
                         mMaxWidths = new int[newLength];
                         System.Array.Copy(oldMaxWidths, 0, mMaxWidths, 0, oldMaxWidths.Length);
                         System.Array.Copy(widths, oldMaxWidths.Length, mMaxWidths, oldMaxWidths.Length, difference
                                           );
                     }
                     // the row is narrower or of the same width as the previous
                     // rows, so we find the maximum width for each column
                     // if the row is narrower than the previous ones,
                     // difference will be negative
                     int[] maxWidths = mMaxWidths;
                     length = System.Math.Min(length, newLength);
                     {
                         for (int j = 0; j < length; j++)
                         {
                             maxWidths[j] = System.Math.Max(maxWidths[j], widths[j]);
                         }
                     }
                 }
             }
         }
     }
 }