public PmtReader(int pid) { pmtScratch = new ParsableBitArray(new byte[5]); trackIdToReaderScratch = new SparseArray<>(); trackIdToPidScratch = new SparseIntArray(); this.pid = pid; }
private void init() { mChildrenHeights = new SparseIntArray(); super.setOnScrollListener(mScrollListener); }
private void init() { mChildrenHeights = new SparseIntArray(); checkLibraryVersion(); }
/** * Called by CREATOR. */ private SavedState(Parcel in) { super(in); 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); } } }
/** * Called by CREATOR. */ private SavedState(Parcel in) { super(in); 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); } } }
private void init() { mChildrenHeights = new SparseIntArray(); mHeaderViewInfos = new ArrayList<>(); mFooterViewInfos = new ArrayList<>(); super.setClipChildren(false); super.setOnScrollListener(mScrollListener); }
/** * Called by CREATOR. */ private SavedState(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); } } }
public void setSpecialInterval(JSONObject jsonObject) { if (jsonObject != null) { this.mSpecialInterval = new SparseIntArray(); Iterator<String> itr = jsonObject.keys(); while (itr.hasNext()) { String key = itr.next(); try { int index = Integer.parseInt(key); int value = jsonObject.optInt(key); if (value > 0) { this.mSpecialInterval.put(index, value); } } catch (NumberFormatException e) { } } } }
private static int[][] getGroupedAdaptationSetIndices(List<AdaptationSet> adaptationSets) { int adaptationSetCount = adaptationSets.size(); SparseIntArray idToIndexMap = new SparseIntArray(adaptationSetCount); for (int i = 0; i < adaptationSetCount; i++) { idToIndexMap.put(adaptationSets.get(i).id, i);
public void setSpecialInterval(JSONObject jsonObject) { if (jsonObject != null) { this.mSpecialInterval = new SparseIntArray(); for (String key : jsonObject.keySet()) { try { int index = Integer.parseInt(key); int value = jsonObject.getIntValue(key); if (value > 0) { this.mSpecialInterval.put(index, value); } } catch (Exception e) { } } } }
MyOnNavigationItemSelectedListener(ViewPager viewPager, BottomNavigationViewEx bnve, boolean smoothScroll, OnNavigationItemSelectedListener listener) { this.viewPagerRef = new WeakReference<>(viewPager); this.listener = listener; this.smoothScroll = smoothScroll; // create items Menu menu = bnve.getMenu(); int size = menu.size(); items = new SparseIntArray(size); for (int i = 0; i < size; i++) { int itemId = menu.getItem(i).getItemId(); items.put(itemId, i); } }
private void incrementExpandMapAfter(int position, int direction) { SparseIntArray newExpandMap = new SparseIntArray(); for (int i=0; i<expandMap.size(); i++) { int index = expandMap.keyAt(i); newExpandMap.put(index < position ? index : index + direction, 1); } expandMap = newExpandMap; }
/** * Returns the number of children of a given type {@code this} component has and then increments * it by 1. * * @param component the child component * @return the number of children of {@param component} type */ private int getChildCountAndIncrement(Component component) { if (mChildCounters == null) { mChildCounters = new SparseIntArray(); } final int typeId = component.getTypeId(); final int count = mChildCounters.get(typeId, 0); mChildCounters.put(typeId, count + 1); return count; }
/** * @param mode Mode for the extractor. One of {@link #MODE_MULTI_PMT}, {@link #MODE_SINGLE_PMT} * and {@link #MODE_HLS}. * @param timestampAdjuster A timestamp adjuster for offsetting and scaling sample timestamps. * @param payloadReaderFactory Factory for injecting a custom set of payload readers. */ public TsExtractor( @Mode int mode, TimestampAdjuster timestampAdjuster, TsPayloadReader.Factory payloadReaderFactory) { this.payloadReaderFactory = Assertions.checkNotNull(payloadReaderFactory); this.mode = mode; if (mode == MODE_SINGLE_PMT || mode == MODE_HLS) { timestampAdjusters = Collections.singletonList(timestampAdjuster); } else { timestampAdjusters = new ArrayList<>(); timestampAdjusters.add(timestampAdjuster); } tsPacketBuffer = new ParsableByteArray(new byte[BUFFER_SIZE], 0); trackIds = new SparseBooleanArray(); trackPids = new SparseBooleanArray(); tsPayloadReaders = new SparseArray<>(); continuityCounters = new SparseIntArray(); durationReader = new TsDurationReader(); pcrPid = -1; resetPayloadReaders(); }
/** * @param items A list of cast media queue items to represent. * @param contentIdToDurationUsMap A map of content id to duration in microseconds. */ public CastTimeline(List<MediaQueueItem> items, Map<String, Long> contentIdToDurationUsMap) { int itemCount = items.size(); int index = 0; idsToIndex = new SparseIntArray(itemCount); ids = new int[itemCount]; durationsUs = new long[itemCount]; defaultPositionsUs = new long[itemCount]; for (MediaQueueItem item : items) { int itemId = item.getItemId(); ids[index] = itemId; idsToIndex.put(itemId, index); MediaInfo mediaInfo = item.getMedia(); String contentId = mediaInfo.getContentId(); durationsUs[index] = contentIdToDurationUsMap.containsKey(contentId) ? contentIdToDurationUsMap.get(contentId) : CastUtils.getStreamDurationUs(mediaInfo); defaultPositionsUs[index] = (long) (item.getStartTime() * C.MICROS_PER_SECOND); index++; } }
/** * 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() { SparseIntArray expandedItems = new SparseIntArray(); Item item; for (int i = 0, size = mFastAdapter.getItemCount(); i < size; i++) { item = mFastAdapter.getItem(i); if (item instanceof IExpandable && ((IExpandable) item).isExpanded()) { expandedItems.put(i, ((IExpandable) item).getSubItems().size()); } } return expandedItems; }
items = new SparseIntArray(3);
public void testListViewSavedState() throws Throwable { Parcel parcel = Parcel.obtain(); ObservableListView.SavedState state1 = new ObservableListView.SavedState(AbsSavedState.EMPTY_STATE); state1.prevFirstVisiblePosition = 1; state1.prevFirstVisibleChildHeight = 2; state1.prevScrolledChildrenHeight = 3; state1.prevScrollY = 4; state1.scrollY = 5; state1.childrenHeights = new SparseIntArray(); state1.childrenHeights.put(0, 10); state1.childrenHeights.put(1, 20); state1.childrenHeights.put(2, 30); state1.writeToParcel(parcel, 0); parcel.setDataPosition(0); ObservableListView.SavedState state2 = ObservableListView.SavedState.CREATOR.createFromParcel(parcel); assertNotNull(state2); assertEquals(state1.prevFirstVisiblePosition, state2.prevFirstVisiblePosition); assertEquals(state1.prevFirstVisibleChildHeight, state2.prevFirstVisibleChildHeight); assertEquals(state1.prevScrolledChildrenHeight, state2.prevScrolledChildrenHeight); assertEquals(state1.prevScrollY, state2.prevScrollY); assertEquals(state1.scrollY, state2.scrollY); assertNotNull(state1.childrenHeights); assertEquals(3, state1.childrenHeights.size()); assertEquals(10, state1.childrenHeights.get(0)); assertEquals(20, state1.childrenHeights.get(1)); assertEquals(30, state1.childrenHeights.get(2)); }
public void testRecyclerViewSavedState() throws Throwable { Parcel parcel = Parcel.obtain(); ObservableRecyclerView.SavedState state1 = new ObservableRecyclerView.SavedState(AbsSavedState.EMPTY_STATE); state1.prevFirstVisiblePosition = 1; state1.prevFirstVisibleChildHeight = 2; state1.prevScrolledChildrenHeight = 3; state1.prevScrollY = 4; state1.scrollY = 5; state1.childrenHeights = new SparseIntArray(); state1.childrenHeights.put(0, 10); state1.childrenHeights.put(1, 20); state1.childrenHeights.put(2, 30); state1.writeToParcel(parcel, 0); parcel.setDataPosition(0); ObservableRecyclerView.SavedState state2 = ObservableRecyclerView.SavedState.CREATOR.createFromParcel(parcel); assertNotNull(state2); assertEquals(state1.prevFirstVisiblePosition, state2.prevFirstVisiblePosition); assertEquals(state1.prevFirstVisibleChildHeight, state2.prevFirstVisibleChildHeight); assertEquals(state1.prevScrolledChildrenHeight, state2.prevScrolledChildrenHeight); assertEquals(state1.prevScrollY, state2.prevScrollY); assertEquals(state1.scrollY, state2.scrollY); assertNotNull(state1.childrenHeights); assertEquals(3, state1.childrenHeights.size()); assertEquals(10, state1.childrenHeights.get(0)); assertEquals(20, state1.childrenHeights.get(1)); assertEquals(30, state1.childrenHeights.get(2)); }
public void testGridViewSavedState() throws Throwable { Parcel parcel = Parcel.obtain(); ObservableGridView.SavedState state1 = new ObservableGridView.SavedState(AbsSavedState.EMPTY_STATE); state1.prevFirstVisiblePosition = 1; state1.prevFirstVisibleChildHeight = 2; state1.prevScrolledChildrenHeight = 3; state1.prevScrollY = 4; state1.scrollY = 5; state1.childrenHeights = new SparseIntArray(); state1.childrenHeights.put(0, 10); state1.childrenHeights.put(1, 20); state1.childrenHeights.put(2, 30); state1.writeToParcel(parcel, 0); parcel.setDataPosition(0); ObservableGridView.SavedState state2 = ObservableGridView.SavedState.CREATOR.createFromParcel(parcel); assertNotNull(state2); assertEquals(state1.prevFirstVisiblePosition, state2.prevFirstVisiblePosition); assertEquals(state1.prevFirstVisibleChildHeight, state2.prevFirstVisibleChildHeight); assertEquals(state1.prevScrolledChildrenHeight, state2.prevScrolledChildrenHeight); assertEquals(state1.prevScrollY, state2.prevScrollY); assertEquals(state1.scrollY, state2.scrollY); assertNotNull(state1.childrenHeights); assertEquals(3, state1.childrenHeights.size()); assertEquals(10, state1.childrenHeights.get(0)); assertEquals(20, state1.childrenHeights.get(1)); assertEquals(30, state1.childrenHeights.get(2)); }