android.util.SparseIntArray#append ( )源码实例Demo

下面列出了android.util.SparseIntArray#append ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Study_Android_Demo   文件: GenerationRegistry.java
private static int getKeyIndexLocked(int key, SparseIntArray keyToIndexMap,
        MemoryIntArray backingStore) throws IOException {
    int index = keyToIndexMap.get(key, -1);
    if (index < 0) {
        index = findNextEmptyIndex(backingStore);
        if (index >= 0) {
            backingStore.set(index, 1);
            keyToIndexMap.append(key, index);
            if (DEBUG) {
                Slog.i(LOG_TAG, "Allocated index:" + index + " for key:"
                        + SettingsProvider.keyToString(key));
            }
        } else {
            Slog.e(LOG_TAG, "Could not allocate generation index");
        }
    }
    return index;
}
 
源代码2 项目: android_9.0.0_r45   文件: Parcel.java
private void readSparseIntArrayInternal(SparseIntArray outVal, int N) {
    while (N > 0) {
        int key = readInt();
        int value = readInt();
        outVal.append(key, value);
        N--;
    }
}
 
源代码3 项目: BaldPhone   文件: AppsRecyclerViewAdapter.java
public AppsRecyclerViewAdapter(List<App> appList, BaldActivity activity, AppsActivity.ChangeAppListener changeAppListener, RecyclerView caller) {
    this.caller = caller;
    this.activity = activity;
    this.layoutInflater = LayoutInflater.from(activity);
    selectedDrawable = ContextCompat.getDrawable(activity, R.drawable.btn_selected);
    elevation =
            TypedValue.applyDimension(
                    TypedValue.COMPLEX_UNIT_DIP,
                    16,
                    activity.getResources().getDisplayMetrics());
    this.changeAppListener = changeAppListener;
    this.appsOneGrid = BPrefs.get(activity).getBoolean(BPrefs.APPS_ONE_GRID_KEY, BPrefs.APPS_ONE_GRID_DEFAULT_VALUE);
    letterToPosition = new SparseIntArray();
    dataList = new ArrayList<>((int) (appList.size() * 1.5));
    String lastChar = "";
    String disChar;
    for (int i = 0; i < appList.size(); i++) {
        disChar = appList.get(i).getLabel().substring(0, 1).toUpperCase();
        if (!appsOneGrid && !disChar.equals(lastChar)) {
            dataList.add(new AppStickyHeader(disChar));
            letterToPosition.append(disChar.charAt(0), dataList.size() - 1);
        }
        dataList.add(appList.get(i));
        lastChar = disChar;
    }

    final TypedValue typedValue = new TypedValue();
    Resources.Theme theme = activity.getTheme();
    theme.resolveAttribute(R.attr.bald_text_on_selected, typedValue, true);
    textColorOnSelected = typedValue.data;
    theme.resolveAttribute(R.attr.bald_text_on_background, typedValue, true);
    textColorOnBackground = typedValue.data;
}
 
源代码4 项目: Collection-Android   文件: FlexboxHelper.java
private int[] sortOrdersIntoReorderedIndices(int childCount, List<Order> orders,
                                             SparseIntArray orderCache) {
    Collections.sort(orders);
    orderCache.clear();
    int[] reorderedIndices = new int[childCount];
    int i = 0;
    for (Order order : orders) {
        reorderedIndices[i] = order.index;
        orderCache.append(order.index, order.order);
        i++;
    }
    return reorderedIndices;
}
 
源代码5 项目: materialup   文件: UserPagerAdapter.java
public UserPagerAdapter(Activity context, User user, FragmentManager fm) {
    super(fm);
    mActivity = context;
    mUser = user;
    mArray = new SparseIntArray(6);
    mId = User.getUserId(mUser.path);
    int key = 0;
    if (user.getUpvoted() > 0) {
        mArray.append(key, UPVOTED);
        key++;
    }
    if (user.getCreated() > 0) {
        mArray.append(key, CREATED);
        key++;
    }
    if (user.getShowcased() > 0) {
        mArray.append(key, SHOWCASED);
        key++;
    }
    if (user.getCollections() > 0) {
        mArray.append(key, COLLECTIONS);
        key++;
    }
    if (user.getFollowers() > 0) {
        mArray.append(key, FOLLOWERS);
        key++;
    }
    if (user.getFollowing() > 0) {
        mArray.append(key, FOLLOWING);
        key++;
    }
}
 
源代码6 项目: Hentoid   文件: ObjectBoxDB.java
SparseIntArray countAvailableAttributesPerType(List<Attribute> attributeFilter) {
    // Get Content filtered by current selection
    long[] filteredContent = selectFilteredContent(attributeFilter, false);
    // Get available attributes of the resulting content list
    QueryBuilder<Attribute> query = store.boxFor(Attribute.class).query();

    if (filteredContent.length > 0)
        query.link(Attribute_.contents).in(Content_.id, filteredContent).in(Content_.status, libraryStatus);
    else
        query.link(Attribute_.contents).in(Content_.status, libraryStatus);

    List<Attribute> attributes = query.build().find();

    SparseIntArray result = new SparseIntArray();
    // SELECT field, COUNT(*) GROUP BY (field) is not implemented in ObjectBox v2.3.1
    // (see https://github.com/objectbox/objectbox-java/issues/422)
    // => Group by and count have to be done manually (thanks God Stream exists !)
    // Group and count by type
    Map<AttributeType, List<Attribute>> map = Stream.of(attributes).collect(Collectors.groupingBy(Attribute::getType));

    for (Map.Entry<AttributeType, List<Attribute>> entry : map.entrySet()) {
        AttributeType t = entry.getKey();
        int size = (null == entry.getValue()) ? 0 : entry.getValue().size();
        result.append(t.getCode(), size);
    }

    return result;
}
 
源代码7 项目: fresco   文件: BasePoolTest.java
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;
}
 
源代码8 项目: fdroidclient   文件: MainViewAdapter.java
MainViewAdapter(AppCompatActivity activity) {
    this.activity = activity;
    setHasStableIds(true);

    PopupMenu p = new PopupMenu(activity, null);
    Menu menu = p.getMenu();
    activity.getMenuInflater().inflate(R.menu.main_activity_screens, menu);
    positionToId = new SparseIntArray(menu.size());
    for (int i = 0; i < menu.size(); i++) {
        positionToId.append(i, menu.getItem(i).getItemId());
    }
}
 
源代码9 项目: Battery-Metrics   文件: CpuFrequencyMetrics.java
private static void copyArrayInto(SparseIntArray source, SparseIntArray destination) {
  destination.clear();
  for (int i = 0; i < source.size(); i++) {
    destination.append(source.keyAt(i), source.valueAt(i));
  }
}