/** Set the sim state for the given {@code slotIndex}. */ public void setSimState(int slotIndex, int state) { simStates.put(slotIndex, state); }
/** Sets the phone type for the given {@code subId}. */ public void setCurrentPhoneType(int subId, int phoneType) { currentPhoneTypes.put(subId, phoneType); }
@Implementation protected int load(Context context, int resId, int priority) { int soundId = soundIds.getAndIncrement(); idToRes.put(soundId, resId); return soundId; }
/** Clears {@code slotIndex} to state mapping and resets to default state. */ public void resetSimStates() { simStates.clear(); simStates.put(0, TelephonyManager.SIM_STATE_READY); }
/** * 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); } } }
/** * 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 int getColor(int index) { int color = marginColors.get(index); if (color == 0) color = colors.get(marginColors.size() % colors.size()); marginColors.put(index, color); return color; } }
public void expandItems(int position, boolean notify) { int count = 0; int index = indexList.get(position); int insert = position; for (int i=index+1; i<allItems.size() && allItems.get(i).ItemType != TYPE_HEADER; i++) { insert++; count++; visibleItems.add(insert, allItems.get(i)); indexList.add(insert, i); } notifyItemRangeInserted(position + 1, count); int allItemsPosition = indexList.get(position); expandMap.put(allItemsPosition, 1); if (notify) { notifyItemChanged(position); } }
public int wrapItemViewType(int segment, int viewType) { final int packedSegments = (segment << 16) | ItemViewTypeComposer.extractSegmentPart(viewType); final int flattenSegments; final int index = mWrapSegmentMap.indexOfKey(packedSegments); if (index >= 0) { flattenSegments = mWrapSegmentMap.valueAt(index); } else { flattenSegments = mWrapSegmentMap.size() + 1; if (flattenSegments > ItemViewTypeComposer.MAX_SEGMENT) { throw new IllegalStateException("Failed to allocate a new wrapped view type."); } mWrapSegmentMap.put(packedSegments, flattenSegments); mUnwrapSegmentMap.put(flattenSegments, packedSegments); } return ItemViewTypeComposer.composeSegment(flattenSegments, viewType); }
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 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; }
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)); }