Java Code Examples for android.util.SparseIntArray#append()
The following examples show how to use
android.util.SparseIntArray#append() .
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: GenerationRegistry.java From Study_Android_Demo with Apache License 2.0 | 6 votes |
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; }
Example 2
Source File: Parcel.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void readSparseIntArrayInternal(SparseIntArray outVal, int N) { while (N > 0) { int key = readInt(); int value = readInt(); outVal.append(key, value); N--; } }
Example 3
Source File: AppsRecyclerViewAdapter.java From BaldPhone with Apache License 2.0 | 5 votes |
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; }
Example 4
Source File: FlexboxHelper.java From Collection-Android with MIT License | 5 votes |
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; }
Example 5
Source File: UserPagerAdapter.java From materialup with Apache License 2.0 | 5 votes |
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++; } }
Example 6
Source File: ObjectBoxDB.java From Hentoid with Apache License 2.0 | 5 votes |
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; }
Example 7
Source File: BasePoolTest.java From fresco with MIT License | 5 votes |
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; }
Example 8
Source File: MainViewAdapter.java From fdroidclient with GNU General Public License v3.0 | 5 votes |
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()); } }
Example 9
Source File: CpuFrequencyMetrics.java From Battery-Metrics with MIT License | 4 votes |
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)); } }