private void setPositionHeightRatio(final int position, final int height) { GridItemRecord rec = getOrCreateRecord(position); rec.heightRatio = (double) height / (double) mColumnWidth; if (DBG) Log.d( TAG, "position:" + position + " width:" + mColumnWidth + " height:" + height + " heightRatio:" + rec.heightRatio); }
/** * * Our mColumnTops and mColumnBottoms need to be re-built up to the mSyncPosition - the * following layout request will then layout the that position and then fillUp and fillDown * appropriately. */ private void onColumnSync() { // re-calc tops for new column count! int syncPosition = Math.min(mSyncPosition, getCount() - 1); SparseArray<Double> positionHeightRatios = new SparseArray<Double>(syncPosition); for (int pos = 0; pos < syncPosition; pos++) { // check for weirdness final GridItemRecord rec = mPositionData.get(pos); if (rec == null) break; Log.d(TAG, "onColumnSync:" + pos + " ratio:" + rec.heightRatio); positionHeightRatios.append(pos, rec.heightRatio); } mPositionData.clear(); // re-calc our relative position while at the same time // rebuilding our GridItemRecord collection if (DBG) Log.d(TAG, "onColumnSync column width:" + mColumnWidth); for (int pos = 0; pos < syncPosition; pos++) { // Check for weirdness again final Double heightRatio = positionHeightRatios.get(pos); if (heightRatio == null) { break; } final GridItemRecord rec = getOrCreateRecord(pos); final int height = (int) (mColumnWidth * heightRatio); rec.heightRatio = heightRatio; int top; int bottom; // check for headers if (isHeaderOrFooter(pos)) { // the next top is the bottom for that column top = getLowestPositionedBottom(); bottom = top + height; for (int i = 0; i < mColumnCount; i++) { mColumnTops[i] = top; mColumnBottoms[i] = bottom; } } else { // what's the next column down ? final int column = getHighestPositionedBottomColumn(); // the next top is the bottom for that column top = mColumnBottoms[column]; bottom = top + height + getChildTopMargin(pos) + getChildBottomMargin(); mColumnTops[column] = top; mColumnBottoms[column] = bottom; rec.column = column; } if (DBG) Log.d( TAG, "onColumnSync position:" + pos + " top:" + top + " bottom:" + bottom + " height:" + height + " heightRatio:" + heightRatio); } // our sync position will be displayed in this column final int syncColumn = getHighestPositionedBottomColumn(); setPositionColumn(syncPosition, syncColumn); // we want to offset from height of the sync position // minus the offset int syncToBottom = mColumnBottoms[syncColumn]; int offset = -syncToBottom + mSpecificTop; // offset all columns by offsetAllColumnsTopAndBottom(offset); // sync the distance to top mDistanceToTop = -syncToBottom; // stash our bottoms in our tops - though these will be copied back to // the bottoms System.arraycopy(mColumnBottoms, 0, mColumnTops, 0, mColumnCount); }
private void setPositionIsHeaderFooter(final int position) { GridItemRecord rec = getOrCreateRecord(position); rec.isHeaderFooter = true; }
private void setPositionColumn(final int position, final int column) { GridItemRecord rec = getOrCreateRecord(position); rec.column = column; }