本文整理汇总了Java中android.util.SparseIntArray.put方法的典型用法代码示例。如果您正苦于以下问题:Java SparseIntArray.put方法的具体用法?Java SparseIntArray.put怎么用?Java SparseIntArray.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.util.SparseIntArray
的用法示例。
在下文中一共展示了SparseIntArray.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCheckedChanged
import android.util.SparseIntArray; //导入方法依赖的package包/类
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (buttonView == loopCheckBox) {
ultraViewPager.setInfiniteLoop(isChecked);
}
if (buttonView == autoScrollCheckBox) {
if (isChecked) {
SparseIntArray special = new SparseIntArray();
special.put(0, 5000);
special.put(1, 1500);
ultraViewPager.setAutoScroll(2000, special);
}
else
ultraViewPager.disableAutoScroll();
}
}
示例2: getExpanded
import android.util.SparseIntArray; //导入方法依赖的package包/类
/**
* returns the expanded items this contains position and the count of items
* which are expanded by this position
*
* @return the expanded items
*/
public SparseIntArray getExpanded() {
if (mPositionBasedStateManagement) {
return mExpanded;
} else {
SparseIntArray expandedItems = new SparseIntArray();
Item item;
for (int i = 0, size = getItemCount(); i < size; i++) {
item = getItem(i);
if (item instanceof IExpandable && ((IExpandable) item).isExpanded()) {
expandedItems.put(i, ((IExpandable) item).getSubItems().size());
}
}
return expandedItems;
}
}
示例3: SavedStateScrolling
import android.util.SparseIntArray; //导入方法依赖的package包/类
/**
* Called by CREATOR.
*
* @param in na
*/
public SavedStateScrolling(Parcel in) {
// Parcel 'in' has its parent(RecyclerView)'s saved state.
// To restore it, class loader that loaded RecyclerView is required.
Parcelable superState = in.readParcelable(RecyclerView.class.getClassLoader());
this.superState = superState != null ? superState : EMPTY_STATE;
prevFirstVisiblePosition = in.readInt();
prevFirstVisibleChildHeight = in.readInt();
prevScrolledChildrenHeight = in.readInt();
prevScrollY = in.readInt();
scrollY = in.readInt();
childrenHeights = new SparseIntArray();
final int numOfChildren = in.readInt();
if (0 < numOfChildren) {
for (int i = 0; i < numOfChildren; i++) {
final int key = in.readInt();
final int value = in.readInt();
childrenHeights.put(key, value);
}
}
}
示例4: get
import android.util.SparseIntArray; //导入方法依赖的package包/类
public static PoolParams get() {
SparseIntArray DEFAULT_BUCKETS = new SparseIntArray();
DEFAULT_BUCKETS.put(1 * ByteConstants.KB, SMALL_BUCKET_LENGTH);
DEFAULT_BUCKETS.put(2 * ByteConstants.KB, SMALL_BUCKET_LENGTH);
DEFAULT_BUCKETS.put(4 * ByteConstants.KB, SMALL_BUCKET_LENGTH);
DEFAULT_BUCKETS.put(8 * ByteConstants.KB, SMALL_BUCKET_LENGTH);
DEFAULT_BUCKETS.put(16 * ByteConstants.KB, SMALL_BUCKET_LENGTH);
DEFAULT_BUCKETS.put(32 * ByteConstants.KB, SMALL_BUCKET_LENGTH);
DEFAULT_BUCKETS.put(64 * ByteConstants.KB, SMALL_BUCKET_LENGTH);
DEFAULT_BUCKETS.put(128 * ByteConstants.KB, SMALL_BUCKET_LENGTH);
DEFAULT_BUCKETS.put(256 * ByteConstants.KB, LARGE_BUCKET_LENGTH);
DEFAULT_BUCKETS.put(512 * ByteConstants.KB, LARGE_BUCKET_LENGTH);
DEFAULT_BUCKETS.put(1024 * ByteConstants.KB, LARGE_BUCKET_LENGTH);
return new PoolParams(
getMaxSizeSoftCap(),
getMaxSizeHardCap(),
DEFAULT_BUCKETS);
}
示例5: setup
import android.util.SparseIntArray; //导入方法依赖的package包/类
@Before
public void setup() {
SparseIntArray buckets = new SparseIntArray();
for (int i = MIN_BUFFER_SIZE; i <= MAX_BUFFER_SIZE; i*=2) {
buckets.put(i, 3);
}
mPool = new FlexByteArrayPool(
mock(MemoryTrimmableRegistry.class),
new PoolParams(
Integer.MAX_VALUE,
Integer.MAX_VALUE,
buckets,
MIN_BUFFER_SIZE,
MAX_BUFFER_SIZE,
1));
mDelegatePool = mPool.mDelegatePool;
}
示例6: buildIdRules
import android.util.SparseIntArray; //导入方法依赖的package包/类
/**
* Extract id from view , build id rules and inflate rules if needed.
*
* @param v
* @param array
*/
protected void buildIdRules(Context context, View v, SparseIntArray array) {
if (v.getId() != View.NO_ID) {
//Get mapped id by id name.
String idName = getResourceEntryName(v.getId());
int mappedId = getAppResources().getIdentifier(idName, "id", context.getPackageName());
//Add custom id to avoid id conflict when mapped id not exist.
//Key as skin id and value as mapped id.
array.put(v.getId(), mappedId > 0 ? mappedId : generateId());
}
if (v instanceof ViewGroup) {
ViewGroup vp = (ViewGroup) v;
int childCount = vp.getChildCount();
for (int i = 0; i < childCount; i++) {
buildIdRules(context, vp.getChildAt(i), array);
}
}
buildInflateRules(v, array);
}
示例7: getSections
import android.util.SparseIntArray; //导入方法依赖的package包/类
@Override
public Object[] getSections() {
positionOfSection = new SparseIntArray();
sectionOfPosition = new SparseIntArray();
int count = getCount();
list = new ArrayList<String>();
list.add(getContext().getString(R.string.search_header));
positionOfSection.put(0, 0);
sectionOfPosition.put(0, 0);
for (int i = 1; i < count; i++) {
String letter = getItem(i).getInitialLetter();
int section = list.size() - 1;
if (list.get(section) != null && !list.get(section).equals(letter)) {
list.add(letter);
section++;
positionOfSection.put(section, i);
}
sectionOfPosition.put(i, section);
}
return list.toArray(new String[list.size()]);
}
示例8: get
import android.util.SparseIntArray; //导入方法依赖的package包/类
/**
* Get default {@link PoolParams}.
*/
public static PoolParams get() {
// This pool supports only one bucket size: DEFAULT_IO_BUFFER_SIZE
SparseIntArray defaultBuckets = new SparseIntArray();
defaultBuckets.put(DEFAULT_IO_BUFFER_SIZE, DEFAULT_BUCKET_SIZE);
return new PoolParams(
MAX_SIZE_SOFT_CAP,
MAX_SIZE_HARD_CAP,
defaultBuckets);
}
示例9: generateBuckets
import android.util.SparseIntArray; //导入方法依赖的package包/类
public static SparseIntArray generateBuckets(int min, int max, int numThreads) {
SparseIntArray buckets = new SparseIntArray();
for (int i = min; i <= max; i*=2) {
buckets.put(i, numThreads);
}
return buckets;
}
示例10: setup
import android.util.SparseIntArray; //导入方法依赖的package包/类
@Before
public void setup() {
final SparseIntArray bucketSizes = new SparseIntArray();
bucketSizes.put(32, 2);
bucketSizes.put(64, 1);
bucketSizes.put(128, 1);
mPool = new FakeNativeMemoryChunkPool(
new PoolParams(128, bucketSizes));
}
示例11: setup
import android.util.SparseIntArray; //导入方法依赖的package包/类
@Before
public void setup() {
final SparseIntArray bucketSizes = new SparseIntArray();
bucketSizes.put(32, 2);
bucketSizes.put(64, 1);
bucketSizes.put(128, 1);
mPool = new GenericByteArrayPool(
mock(MemoryTrimmableRegistry.class),
new PoolParams(128, bucketSizes),
mock(PoolStatsTracker.class));
}
示例12: getBucketSizes
import android.util.SparseIntArray; //导入方法依赖的package包/类
private static SparseIntArray getBucketSizes() {
final SparseIntArray bucketSizes = new SparseIntArray();
bucketSizes.put(4, 10);
bucketSizes.put(8, 10);
bucketSizes.put(16, 10);
bucketSizes.put(32, 10);
return bucketSizes;
}
示例13: loadOrdered
import android.util.SparseIntArray; //导入方法依赖的package包/类
public LiveData<List<Repo>> loadOrdered(List<Integer> repoIds) {
SparseIntArray order = new SparseIntArray();
int index = 0;
for (Integer repoId : repoIds) {
order.put(repoId, index++);
}
return Transformations.map(loadById(repoIds), repositories -> {
Collections.sort(repositories, (r1, r2) -> {
int pos1 = order.get(r1.id);
int pos2 = order.get(r2.id);
return pos1 - pos2;
});
return repositories;
});
}
示例14: updateSparseArray
import android.util.SparseIntArray; //导入方法依赖的package包/类
static void updateSparseArray(@NonNull SparseIntArray array, int position, int value) {
if (position == Spacing.ALL) {
array.put(Spacing.ALL, value);
array.put(Spacing.TOP, value);
array.put(Spacing.LEFT, value);
array.put(Spacing.RIGHT, value);
array.put(Spacing.BOTTOM, value);
} else {
array.put(position, value);
}
}
示例15: onTranslationsUpdated
import android.util.SparseIntArray; //导入方法依赖的package包/类
public void onTranslationsUpdated(List<TranslationItem> items) {
translationSwipeRefresh.setRefreshing(false);
SparseIntArray itemsSparseArray = new SparseIntArray(items.size());
for (int i = 0, itemsSize = items.size(); i < itemsSize; i++) {
TranslationItem item = items.get(i);
itemsSparseArray.put(item.translation.id, i);
}
allItems = items;
translationPositions = itemsSparseArray;
generateListItems();
}