@Override public int getIndexOfPeriod(Object uid) { return uid instanceof Integer ? idsToIndex.get((int) uid, C.INDEX_UNSET) : C.INDEX_UNSET; }
/** * Retrieves the JPEG orientation from the specified screen rotation. * * @param rotation The screen rotation. * @return The JPEG orientation (one of 0, 90, 270, and 360) */ private int getOrientation(int rotation) { // Sensor orientation is 90 for most devices, or 270 for some devices (eg. Nexus 5X) // We have to take that into account and rotate JPEG properly. // For devices with orientation of 90, we simply return our mapping from ORIENTATIONS. // For devices with orientation of 270, we need to rotate the JPEG 180 degrees. return (ORIENTATIONS.get(rotation) + mSensorOrientation + 270) % 360; }
private static int getEmojiResource(Context context, int codePoint) { return sEmojisMap.get(codePoint); }
private static int getSoftbankEmojiResource(char c) { return sSoftbanksMap.get(c); }
private static int getEmojiResource(Context context, int codePoint) { return sEmojisMap.get(codePoint); }
private static int getSoftbankEmojiResource(char c) { return sSoftbanksMap.get(c); }
protected boolean isExpanded(int position) { int allItemsPosition = indexList.get(position); return expandMap.get(allItemsPosition, -1) >= 0; }
@Override public void onOrientationChanged(int orientation) { if (orientation == OrientationEventListener.ORIENTATION_UNKNOWN || mDisplay == null) { return; } final int rotation = mDisplay.getRotation(); if (mLastKnownRotation != rotation) { mLastKnownRotation = rotation; dispatchOnDisplayOrientationChanged(DISPLAY_ORIENTATIONS.get(rotation)); } } };
@Implementation(minSdk = O) protected int getSimState(int slotIndex) { return simStates.get(slotIndex, TelephonyManager.SIM_STATE_UNKNOWN); }
private boolean idIsForResource(int soundId, int resId) { return idToRes.indexOfKey(soundId) >= 0 && idToRes.get(soundId) == resId; }
@Override public void onOrientationChanged(int orientation) { if (orientation == OrientationEventListener.ORIENTATION_UNKNOWN || mDisplay == null) { return; } final int rotation = mDisplay.getRotation(); if (mLastKnownRotation != rotation) { mLastKnownRotation = rotation; dispatchOnDisplayOrientationChanged(DISPLAY_ORIENTATIONS.get(rotation)); } } };
public void enable(Display display) { mDisplay = display; mOrientationEventListener.enable(); // Immediately dispatch the first callback dispatchOnDisplayOrientationChanged(DISPLAY_ORIENTATIONS.get(display.getRotation())); }
public void enable(Display display) { mDisplay = display; mOrientationEventListener.enable(); // Immediately dispatch the first callback dispatchOnDisplayOrientationChanged(DISPLAY_ORIENTATIONS.get(display.getRotation())); }
@Implementation(minSdk = M) @HiddenApi protected int getCurrentPhoneType(int subId) { return currentPhoneTypes.get(subId, TelephonyManager.PHONE_TYPE_NONE); }
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; } }
private static @Nullable Pair<Integer, Integer> getAacCodecProfileAndLevel( String codec, String[] parts) { if (parts.length != 3) { Log.w(TAG, "Ignoring malformed MP4A codec string: " + codec); return null; } try { // Get the object type indication, which is a hexadecimal value (see RFC 6381/ISO 14496-1). int objectTypeIndication = Integer.parseInt(parts[1], 16); String mimeType = MimeTypes.getMimeTypeFromMp4ObjectType(objectTypeIndication); if (MimeTypes.AUDIO_AAC.equals(mimeType)) { // For MPEG-4 audio this is followed by an audio object type indication as a decimal number. int audioObjectTypeIndication = Integer.parseInt(parts[2]); int profile = MP4A_AUDIO_OBJECT_TYPE_TO_PROFILE.get(audioObjectTypeIndication, -1); if (profile != -1) { // Level is set to zero in AAC decoder CodecProfileLevels. return new Pair<>(profile, 0); } } } catch (NumberFormatException e) { Log.w(TAG, "Ignoring malformed MP4A codec string: " + codec); } return null; }
/** * 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; }
private void layoutByCoords() { final int count = Math.min(getChildCount(), cardsXCoords.size()); for (int i = 0; i < count; i++) { final View view = getChildAt(i); final int viewLeft = cardsXCoords.get(getPosition(view)); layoutDecorated(view, viewLeft, 0, viewLeft + cardWidth, getDecoratedBottom(view)); } cardsXCoords.clear(); }
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)); }
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)); }