本文整理匯總了Java中android.util.SparseIntArray.append方法的典型用法代碼示例。如果您正苦於以下問題:Java SparseIntArray.append方法的具體用法?Java SparseIntArray.append怎麽用?Java SparseIntArray.append使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.util.SparseIntArray
的用法示例。
在下文中一共展示了SparseIntArray.append方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setItemPosition
import android.util.SparseIntArray; //導入方法依賴的package包/類
/**
* Sets the {@link #mItemPosition} instance variable with the current mapping of
* row id to cursor position.
*/
private void setItemPosition() {
if (mCursor == null || mCursor.isClosed()) {
mItemPosition = null;
return;
}
SparseIntArray itemPosition = new SparseIntArray(mCursor.getCount());
mCursor.moveToPosition(-1);
while (mCursor.moveToNext()) {
final int rowId = mCursor.getString(mRowIDColumn).hashCode();
final int position = mCursor.getPosition();
itemPosition.append(rowId, position);
}
mItemPosition = itemPosition;
}
示例2: makeBucketSizeArray
import android.util.SparseIntArray; //導入方法依賴的package包/類
private static SparseIntArray makeBucketSizeArray(int... params) {
Preconditions.checkArgument(params.length % 2 == 0);
final SparseIntArray bucketSizes = new SparseIntArray();
for (int i = 0; i < params.length; i += 2) {
bucketSizes.append(params[i], params[i + 1]);
}
return bucketSizes;
}
示例3: readSparseIntArray
import android.util.SparseIntArray; //導入方法依賴的package包/類
@NonNull
private static SparseIntArray readSparseIntArray(Parcel in) {
int size = in.readInt();
if (size < 0) {
return new SparseIntArray(0);
}
SparseIntArray array = new SparseIntArray(size);
for (int i = 0; i < size; ++i) {
array.append(in.readInt(), in.readInt());
}
return array;
}
示例4: fillMaxMinArrays
import android.util.SparseIntArray; //導入方法依賴的package包/類
/**
* Populates the max and min arrays for a given set of draw commands. Also populates a mapping of
* react tags to their index position in the command array.
*
* This should never be called from the UI thread, as the reason it exists is to do work off the
* UI thread.
*
* @param commands The draw commands that will eventually be mounted.
* @param maxBottom At each index i, the maximum bottom value of all draw commands at or below i.
* @param minTop At each index i, the minimum top value of all draw commands at or below i.
* @param drawViewIndexMap Mapping of ids to index position within the draw command array.
*/
public static void fillMaxMinArrays(
DrawCommand[] commands,
float[] maxBottom,
float[] minTop,
SparseIntArray drawViewIndexMap) {
float last = 0;
// Loop through the DrawCommands, keeping track of the maximum we've seen if we only iterated
// through items up to this position.
for (int i = 0; i < commands.length; i++) {
if (commands[i] instanceof DrawView) {
DrawView drawView = (DrawView) commands[i];
// These will generally be roughly sorted by id, so try to insert at the end if possible.
drawViewIndexMap.append(drawView.reactTag, i);
last = Math.max(last, drawView.mLogicalBottom);
} else {
last = Math.max(last, commands[i].getBottom());
}
maxBottom[i] = last;
}
// Intentionally leave last as it was, since it's at the maximum bottom position we've seen so
// far, we can use it again.
// Loop through backwards, keeping track of the minimum we've seen at this position.
for (int i = commands.length - 1; i >= 0; i--) {
if (commands[i] instanceof DrawView) {
last = Math.min(last, ((DrawView) commands[i]).mLogicalTop);
} else {
last = Math.min(last, commands[i].getTop());
}
minTop[i] = last;
}
}
示例5: fillMaxMinArrays
import android.util.SparseIntArray; //導入方法依賴的package包/類
/**
* Populates the max and min arrays for a given set of draw commands. Also populates a mapping of
* react tags to their index position in the command array.
*
* This should never be called from the UI thread, as the reason it exists is to do work off the
* UI thread.
*
* @param commands The draw commands that will eventually be mounted.
* @param maxRight At each index i, the maximum right value of all draw commands at or below i.
* @param minLeft At each index i, the minimum left value of all draw commands at or below i.
* @param drawViewIndexMap Mapping of ids to index position within the draw command array.
*/
public static void fillMaxMinArrays(
DrawCommand[] commands,
float[] maxRight,
float[] minLeft,
SparseIntArray drawViewIndexMap) {
float last = 0;
// Loop through the DrawCommands, keeping track of the maximum we've seen if we only iterated
// through items up to this position.
for (int i = 0; i < commands.length; i++) {
if (commands[i] instanceof DrawView) {
DrawView drawView = (DrawView) commands[i];
// These will generally be roughly sorted by id, so try to insert at the end if possible.
drawViewIndexMap.append(drawView.reactTag, i);
last = Math.max(last, drawView.mLogicalRight);
} else {
last = Math.max(last, commands[i].getRight());
}
maxRight[i] = last;
}
// Intentionally leave last as it was, since it's at the maximum bottom position we've seen so
// far, we can use it again.
// Loop through backwards, keeping track of the minimum we've seen at this position.
for (int i = commands.length - 1; i >= 0; i--) {
if (commands[i] instanceof DrawView) {
last = Math.min(last, ((DrawView) commands[i]).mLogicalLeft);
} else {
last = Math.min(last, commands[i].getLeft());
}
minLeft[i] = last;
}
}