Java Code Examples for com.android.internal.util.ArrayUtils#newUnpaddedIntArray()
The following examples show how to use
com.android.internal.util.ArrayUtils#newUnpaddedIntArray() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DynamicLayout.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Create a new block, ending at the specified character offset. * A block will actually be created only if has at least one line, i.e. this offset is * not on the end line of the previous block. */ private void addBlockAtOffset(int offset) { final int line = getLineForOffset(offset); if (mBlockEndLines == null) { // Initial creation of the array, no test on previous block ending line mBlockEndLines = ArrayUtils.newUnpaddedIntArray(1); mBlockEndLines[mNumberOfBlocks] = line; updateAlwaysNeedsToBeRedrawn(mNumberOfBlocks); mNumberOfBlocks++; return; } final int previousBlockEndLine = mBlockEndLines[mNumberOfBlocks - 1]; if (line > previousBlockEndLine) { mBlockEndLines = GrowingArrayUtils.append(mBlockEndLines, mNumberOfBlocks, line); updateAlwaysNeedsToBeRedrawn(mNumberOfBlocks); mNumberOfBlocks++; } }
Example 2
Source File: StaticLayout.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Used by DynamicLayout. */ /* package */ StaticLayout(@Nullable CharSequence text) { super(text, null, 0, null, 0, 0); mColumns = COLUMNS_ELLIPSIZE; mLineDirections = ArrayUtils.newUnpaddedArray(Directions.class, 2); mLines = ArrayUtils.newUnpaddedIntArray(2 * mColumns); }
Example 3
Source File: StaticLayout.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private StaticLayout(Builder b) { super((b.mEllipsize == null) ? b.mText : (b.mText instanceof Spanned) ? new SpannedEllipsizer(b.mText) : new Ellipsizer(b.mText), b.mPaint, b.mWidth, b.mAlignment, b.mTextDir, b.mSpacingMult, b.mSpacingAdd); if (b.mEllipsize != null) { Ellipsizer e = (Ellipsizer) getText(); e.mLayout = this; e.mWidth = b.mEllipsizedWidth; e.mMethod = b.mEllipsize; mEllipsizedWidth = b.mEllipsizedWidth; mColumns = COLUMNS_ELLIPSIZE; } else { mColumns = COLUMNS_NORMAL; mEllipsizedWidth = b.mWidth; } mLineDirections = ArrayUtils.newUnpaddedArray(Directions.class, 2); mLines = ArrayUtils.newUnpaddedIntArray(2 * mColumns); mMaximumVisibleLineCount = b.mMaxLines; mLeftIndents = b.mLeftIndents; mRightIndents = b.mRightIndents; mLeftPaddings = b.mLeftPaddings; mRightPaddings = b.mRightPaddings; setJustificationMode(b.mJustificationMode); generate(b, b.mIncludePad, b.mIncludePad); }
Example 4
Source File: AutoGrowArray.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Creates an empty IntArray with the specified initial capacity. */ public IntArray(@IntRange(from = 0) int initialCapacity) { if (initialCapacity == 0) { mValues = EmptyArray.INT; } else { mValues = ArrayUtils.newUnpaddedIntArray(initialCapacity); } mSize = 0; }
Example 5
Source File: AutoGrowArray.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Ensures capacity to append at least <code>count</code> values. */ private void ensureCapacity(@IntRange(from = 0) int count) { final int requestedSize = mSize + count; if (requestedSize >= mValues.length) { final int newCapacity = computeNewCapacity(mSize, requestedSize); final int[] newValues = ArrayUtils.newUnpaddedIntArray(newCapacity); System.arraycopy(mValues, 0, newValues, 0, mSize); mValues = newValues; } }
Example 6
Source File: PackedIntVector.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Grows the value and gap arrays to be large enough to store at least * one more than the current number of rows. */ private final void growBuffer() { final int columns = mColumns; int[] newvalues = ArrayUtils.newUnpaddedIntArray( GrowingArrayUtils.growSize(size()) * columns); int newsize = newvalues.length / columns; final int[] valuegap = mValueGap; final int rowgapstart = mRowGapStart; int after = mRows - (rowgapstart + mRowGapLength); if (mValues != null) { System.arraycopy(mValues, 0, newvalues, 0, columns * rowgapstart); System.arraycopy(mValues, (mRows - after) * columns, newvalues, (newsize - after) * columns, after * columns); } for (int i = 0; i < columns; i++) { if (valuegap[i] >= rowgapstart) { valuegap[i] += newsize - mRows; if (valuegap[i] < rowgapstart) { valuegap[i] = rowgapstart; } } } mRowGapLength += newsize - mRows; mRows = newsize; mValues = newvalues; }
Example 7
Source File: IntArray.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Creates an empty IntArray with the specified initial capacity. */ public IntArray(int initialCapacity) { if (initialCapacity == 0) { mValues = EmptyArray.INT; } else { mValues = ArrayUtils.newUnpaddedIntArray(initialCapacity); } mSize = 0; }
Example 8
Source File: IntArray.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Ensures capacity to append at least <code>count</code> values. */ private void ensureCapacity(int count) { final int currentSize = mSize; final int minCapacity = currentSize + count; if (minCapacity >= mValues.length) { final int targetCap = currentSize + (currentSize < (MIN_CAPACITY_INCREMENT / 2) ? MIN_CAPACITY_INCREMENT : currentSize >> 1); final int newCapacity = targetCap > minCapacity ? targetCap : minCapacity; final int[] newValues = ArrayUtils.newUnpaddedIntArray(newCapacity); System.arraycopy(mValues, 0, newValues, 0, currentSize); mValues = newValues; } }
Example 9
Source File: SparseBooleanArray.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Creates a new SparseBooleanArray containing no mappings that will not * require any additional memory allocation to store the specified * number of mappings. If you supply an initial capacity of 0, the * sparse array will be initialized with a light-weight representation * not requiring any additional array allocations. */ public SparseBooleanArray(int initialCapacity) { if (initialCapacity == 0) { mKeys = EmptyArray.INT; mValues = EmptyArray.BOOLEAN; } else { mKeys = ArrayUtils.newUnpaddedIntArray(initialCapacity); mValues = new boolean[mKeys.length]; } mSize = 0; }
Example 10
Source File: SparseIntArray.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Creates a new SparseIntArray containing no mappings that will not * require any additional memory allocation to store the specified * number of mappings. If you supply an initial capacity of 0, the * sparse array will be initialized with a light-weight representation * not requiring any additional array allocations. */ public SparseIntArray(int initialCapacity) { if (initialCapacity == 0) { mKeys = EmptyArray.INT; mValues = EmptyArray.INT; } else { mKeys = ArrayUtils.newUnpaddedIntArray(initialCapacity); mValues = new int[mKeys.length]; } mSize = 0; }
Example 11
Source File: SpellChecker.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
public SpellChecker(TextView textView) { mTextView = textView; // Arbitrary: these arrays will automatically double their sizes on demand final int size = 1; mIds = ArrayUtils.newUnpaddedIntArray(size); mSpellCheckSpans = new SpellCheckSpan[mIds.length]; setLocale(mTextView.getSpellCheckerLocale()); mCookie = hashCode(); }
Example 12
Source File: StaticLayout.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
/** * @hide * @deprecated Use {@link Builder} instead. */ @Deprecated public StaticLayout(CharSequence source, int bufstart, int bufend, TextPaint paint, int outerwidth, Alignment align, TextDirectionHeuristic textDir, float spacingmult, float spacingadd, boolean includepad, TextUtils.TruncateAt ellipsize, int ellipsizedWidth, int maxLines) { super((ellipsize == null) ? source : (source instanceof Spanned) ? new SpannedEllipsizer(source) : new Ellipsizer(source), paint, outerwidth, align, textDir, spacingmult, spacingadd); Builder b = Builder.obtain(source, bufstart, bufend, paint, outerwidth) .setAlignment(align) .setTextDirection(textDir) .setLineSpacing(spacingadd, spacingmult) .setIncludePad(includepad) .setEllipsizedWidth(ellipsizedWidth) .setEllipsize(ellipsize) .setMaxLines(maxLines); /* * This is annoying, but we can't refer to the layout until superclass construction is * finished, and the superclass constructor wants the reference to the display text. * * In other words, the two Ellipsizer classes in Layout.java need a (Dynamic|Static)Layout * as a parameter to do their calculations, but the Ellipsizers also need to be the input * to the superclass's constructor (Layout). In order to go around the circular * dependency, we construct the Ellipsizer with only one of the parameters, the text. And * we fill in the rest of the needed information (layout, width, and method) later, here. * * This will break if the superclass constructor ever actually cares about the content * instead of just holding the reference. */ if (ellipsize != null) { Ellipsizer e = (Ellipsizer) getText(); e.mLayout = this; e.mWidth = ellipsizedWidth; e.mMethod = ellipsize; mEllipsizedWidth = ellipsizedWidth; mColumns = COLUMNS_ELLIPSIZE; } else { mColumns = COLUMNS_NORMAL; mEllipsizedWidth = outerwidth; } mLineDirections = ArrayUtils.newUnpaddedArray(Directions.class, 2); mLines = ArrayUtils.newUnpaddedIntArray(2 * mColumns); mMaximumVisibleLineCount = maxLines; generate(b, b.mIncludePad, b.mIncludePad); Builder.recycle(b); }
Example 13
Source File: SpannableStringBuilder.java From android_9.0.0_r45 with Apache License 2.0 | 3 votes |
/** * Check the size of the buffer and grow if required. * * @param buffer buffer to be checked. * @param size required size. * @return Same buffer instance if the current size is greater than required size. Otherwise a * new instance is created and returned. */ private static int[] checkSortBuffer(int[] buffer, int size) { if (buffer == null || size > buffer.length) { return ArrayUtils.newUnpaddedIntArray(GrowingArrayUtils.growSize(size)); } return buffer; }