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

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

源代码1 项目: unity-ads-android   文件: AdUnitRelativeLayout.java
public SparseArray<SparseArray<AdUnitMotionEvent>> getEvents(SparseArray<ArrayList<Integer>> requestedInfos) {
	SparseIntArray countTable = new SparseIntArray();
	SparseArray<SparseArray<AdUnitMotionEvent>> returnData = new SparseArray<>();

	synchronized (_motionEvents) {
		for (AdUnitMotionEvent currentEvent : _motionEvents) {
			ArrayList<Integer> currentRequestedInfos = requestedInfos.get(currentEvent.getAction());
			if (currentRequestedInfos != null) {
				int currentRequestedInfoIndex = currentRequestedInfos.get(0);

				if (countTable.get(currentEvent.getAction(), 0) == currentRequestedInfoIndex) {
					if (returnData.get(currentEvent.getAction()) == null) {
						returnData.put(currentEvent.getAction(), new SparseArray<AdUnitMotionEvent>());
					}

					returnData.get(currentEvent.getAction()).put(currentRequestedInfoIndex, currentEvent);
					currentRequestedInfos.remove(0);
				}

				countTable.put(currentEvent.getAction(), countTable.get(currentEvent.getAction()) + 1);
			}
		}
	}

	return returnData;
}
 
源代码2 项目: 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;
}
 
源代码3 项目: Camera2   文件: ExifInterface.java
protected int[] getTagDefinitionsForTagId(short tagId)
{
    int[] ifds = IfdData.getIfds();
    int[] defs = new int[ifds.length];
    int counter = 0;
    SparseIntArray infos = getTagInfo();
    for (int i : ifds)
    {
        int def = defineTag(i, tagId);
        if (infos.get(def) != DEFINITION_NULL)
        {
            defs[counter++] = def;
        }
    }
    if (counter == 0)
    {
        return null;
    }

    return Arrays.copyOfRange(defs, 0, counter);
}
 
源代码4 项目: cannonball-android   文件: ThemeAdapter.java
private void setUpItemsDrawableId(int[] itemsDrawableId, Theme[] objects) {
    final Random random = new Random();
    int index = 0;
    for (Theme theme : objects) {
        final SparseIntArray drawables = theme.getImageList();
        final int randomIndex = random.nextInt(drawables.size()) + 1;
        itemsDrawableId[index] = drawables.get(randomIndex);
        index++;
    }
}
 
源代码5 项目: DoraemonKit   文件: TagColorUtil.java
public static int getTextColor(Context context, int level, boolean expand) {
    SparseIntArray map = expand ? TEXT_COLOR_EXPAND : TEXT_COLOR;
    Integer result = map.get(level);
    if (result == null) {
        result = map.get(Log.VERBOSE);
    }
    return ContextCompat.getColor(context, result);
}
 
源代码6 项目: Hentoid   文件: SearchActivity.java
/**
 * Update the text of a given attribute type button based on the given SparseIntArray and relevant type(s)
 *
 * @param button    Button whose text to update
 * @param attrCount Entry count in every attribute type (key = attribute type code; value = count)
 * @param types     Type(s) to fetch the count for
 */
private void updateAttributeTypeButton(@NonNull final TextView button, @NonNull final SparseIntArray attrCount, AttributeType... types) {
    if (0 == types.length) return;

    int count = 0;
    for (AttributeType type : types) count += attrCount.get(type.getCode(), 0);

    button.setText(format("%s (%s)", Helper.capitalizeString(types[0].getDisplayName()), count));
    button.setEnabled(count > 0);
}
 
源代码7 项目: cannonball-android   文件: ThemeAdapter.java
private void setUpItemsDrawableId(int[] itemsDrawableId, Theme[] objects) {
    final Random random = new Random();
    int index = 0;
    for (Theme theme : objects) {
        final SparseIntArray drawables = theme.getImageList();
        final int randomIndex = random.nextInt(drawables.size()) + 1;
        itemsDrawableId[index] = drawables.get(randomIndex);
        index++;
    }
}
 
源代码8 项目: Huochexing12306   文件: BgdService2.java
private TargetInfo getTargetInfo(){
	mBgdBInfo.setTrain_date(mCurrMInfo.getStart_time());
	mBgdBInfo.setFrom_station(mCurrMInfo
			.getFrom_station_telecode());
	mBgdBInfo.setTo_station(mCurrMInfo.getTo_station_telecode());
	mBgdBInfo.setPurpose_codes(mCurrMInfo.getPurpose_codes());
	A6Info<List<QueryLeftNewInfo>> a6Info = A6Util.queryTickets(mBgdBInfo);
	if (a6Info == null || a6Info.getData() == null){
		return null;
	}
	for (QueryLeftNewInfo qlnInfo : a6Info.getDataObject()) {
		QueryLeftNewDTOInfo qlndInfo = qlnInfo
				.getQueryLeftNewDTO();
		int trainIndex = mCurrMInfo.getLstTrainNames().indexOf(qlndInfo.getStation_train_code());
		if (trainIndex != -1 && mCurrMInfo.getSelectedTrainsNames()[trainIndex]){
			SeatHelper sHelper = new SeatHelper(qlndInfo);
			SparseIntArray saNums = sHelper
					.getSeatReferenceNums();
			int num = mCurrMInfo.getLstPNativeIndexes().size();
			for (int i = 0; i < mCurrMInfo.getLstSeatTypes()
					.size(); i++) {
				Integer seatType = mCurrMInfo.getLstSeatTypes()
						.get(i);
				Integer seatNum = saNums.get(seatType);
				if (seatNum != null && (seatNum >= num)) {
					TargetInfo tInfo = new TargetInfo();
					tInfo.setQlnInfo(qlnInfo);
					tInfo.setSeatHelper(sHelper);
					tInfo.setSeatType(seatType);
					tInfo.setNum(num);
					return tInfo;
				}
			}
		}
	}
	return null;
}
 
源代码9 项目: sdl_java_suite   文件: SdlRouterServiceTests.java
/**
 * Test router service correctly picks up Hash ID from start service ACK (prior to V5)
 */
public void testStartSessionAckHashId() {
	if (Looper.myLooper() == null) {
		Looper.prepare();
	}
	Method method;
	try {
		SdlRouterService sdlRouterService = new SdlRouterService();

		initFields(sdlRouterService);
		addDummyRegisteredApp(sdlRouterService, "12345", sessionId);

		// create packet and invoke sendPacketToRegisteredApp
		int hashId = 0x123456;
		byte[] payload = new byte[]{0x00, 0x12, 0x34, 0x56};
		SdlPacket packet = new SdlPacket(4, false, SdlPacket.FRAME_TYPE_CONTROL, SdlPacket.SERVICE_TYPE_RPC, SdlPacket.FRAME_INFO_START_SERVICE_ACK, sessionId, payload.length, 2, payload);
		packet.setTransportRecord(new TransportRecord(TransportType.BLUETOOTH,null));

		method = sdlRouterService.getClass().getDeclaredMethod("sendPacketToRegisteredApp", SdlPacket.class);
		method.setAccessible(true);
		Boolean success = (Boolean) method.invoke(sdlRouterService, packet);
		Assert.assertTrue(success);

		// verify hash id map contains the correct ID
		Field field = sdlRouterService.getClass().getDeclaredField("sessionHashIdMap");
		field.setAccessible(true);
		SparseIntArray sessionHashIdMap = (SparseIntArray)field.get(sdlRouterService);

		Assert.assertTrue(sessionHashIdMap.indexOfKey(sessionId) >= 0);
		int value = sessionHashIdMap.get(sessionId, -1);
		Assert.assertEquals(hashId, value);
	} catch (Exception e) {
		Assert.fail("Exception in sendPacketToRegisteredApp, " + e);
	}
}
 
源代码10 项目: Study_Android_Demo   文件: GenerationRegistry.java
private static void resetSlotForKeyLocked(int key, SparseIntArray keyToIndexMap,
        MemoryIntArray backingStore) throws IOException {
    final int index = keyToIndexMap.get(key, -1);
    if (index >= 0) {
        keyToIndexMap.delete(key);
        backingStore.set(index, 0);
        if (DEBUG) {
            Slog.i(LOG_TAG, "Freed index:" + index + " for key:"
                    + SettingsProvider.keyToString(key));
        }
    }
}
 
源代码11 项目: MediaSDK   文件: DashMediaPeriod.java
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);
  }

  int[][] groupedAdaptationSetIndices = new int[adaptationSetCount][];
  boolean[] adaptationSetUsedFlags = new boolean[adaptationSetCount];

  int groupCount = 0;
  for (int i = 0; i < adaptationSetCount; i++) {
    if (adaptationSetUsedFlags[i]) {
      // This adaptation set has already been included in a group.
      continue;
    }
    adaptationSetUsedFlags[i] = true;
    Descriptor adaptationSetSwitchingProperty = findAdaptationSetSwitchingProperty(
        adaptationSets.get(i).supplementalProperties);
    if (adaptationSetSwitchingProperty == null) {
      groupedAdaptationSetIndices[groupCount++] = new int[] {i};
    } else {
      String[] extraAdaptationSetIds = Util.split(adaptationSetSwitchingProperty.value, ",");
      int[] adaptationSetIndices = new int[1 + extraAdaptationSetIds.length];
      adaptationSetIndices[0] = i;
      int outputIndex = 1;
      for (String adaptationSetId : extraAdaptationSetIds) {
        int extraIndex =
            idToIndexMap.get(Integer.parseInt(adaptationSetId), /* valueIfKeyNotFound= */ -1);
        if (extraIndex != -1) {
          adaptationSetUsedFlags[extraIndex] = true;
          adaptationSetIndices[outputIndex] = extraIndex;
          outputIndex++;
        }
      }
      if (outputIndex < adaptationSetIndices.length) {
        adaptationSetIndices = Arrays.copyOf(adaptationSetIndices, outputIndex);
      }
      groupedAdaptationSetIndices[groupCount++] = adaptationSetIndices;
    }
  }

  return groupCount < adaptationSetCount
      ? Arrays.copyOf(groupedAdaptationSetIndices, groupCount) : groupedAdaptationSetIndices;
}
 
源代码12 项目: LB-Launcher   文件: ExifInterface.java
/**
 * Creates a new tag definition in this ExifInterface object for a given TID
 * and default IFD. Creating a definition with the same TID and default IFD
 * as a previous definition will override it.
 *
 * @param tagId the TID for the tag.
 * @param defaultIfd the default IFD for the tag.
 * @param tagType the type of the tag (see {@link ExifTag#getDataType()}).
 * @param defaultComponentCount the number of elements of this tag's type in
 *            the tags value.
 * @param allowedIfds the IFD's this tag is allowed to be put in.
 * @return the defined tag constant (e.g. {@link #TAG_IMAGE_WIDTH}) or
 *         {@link #TAG_NULL} if the definition could not be made.
 */
public int setTagDefinition(short tagId, int defaultIfd, short tagType,
        short defaultComponentCount, int[] allowedIfds) {
    if (sBannedDefines.contains(tagId)) {
        return TAG_NULL;
    }
    if (ExifTag.isValidType(tagType) && ExifTag.isValidIfd(defaultIfd)) {
        int tagDef = defineTag(defaultIfd, tagId);
        if (tagDef == TAG_NULL) {
            return TAG_NULL;
        }
        int[] otherDefs = getTagDefinitionsForTagId(tagId);
        SparseIntArray infos = getTagInfo();
        // Make sure defaultIfd is in allowedIfds
        boolean defaultCheck = false;
        for (int i : allowedIfds) {
            if (defaultIfd == i) {
                defaultCheck = true;
            }
            if (!ExifTag.isValidIfd(i)) {
                return TAG_NULL;
            }
        }
        if (!defaultCheck) {
            return TAG_NULL;
        }

        int ifdFlags = getFlagsFromAllowedIfds(allowedIfds);
        // Make sure no identical tags can exist in allowedIfds
        if (otherDefs != null) {
            for (int def : otherDefs) {
                int tagInfo = infos.get(def);
                int allowedFlags = getAllowedIfdFlagsFromInfo(tagInfo);
                if ((ifdFlags & allowedFlags) != 0) {
                    return TAG_NULL;
                }
            }
        }
        getTagInfo().put(tagDef, ifdFlags << 24 | (tagType << 16) | defaultComponentCount);
        return tagDef;
    }
    return TAG_NULL;
}
 
源代码13 项目: android_9.0.0_r45   文件: WakeupStats.java
private static void increment(SparseIntArray counters, int key) {
    int newcount = counters.get(key, 0) + 1;
    counters.put(key, newcount);
}
 
源代码14 项目: memoir   文件: NumberEffect.java
@Override
 public synchronized void applyToSelection(RTEditText editor, Selection selectedParagraphs, Boolean enable) {
     final Spannable str = editor.getText();

     mSpans2Process.clear();

     int lineNr = 1;
     SparseIntArray indentations = new SparseIntArray();
     SparseIntArray numbers = new SparseIntArray();
     for (Paragraph paragraph : editor.getParagraphs()) {

/*
          * We need to know the indentation for each paragraph to be able
 * to determine which paragraphs belong together (same indentation)
 */
         int currentIndentation = 0;
         List<RTSpan<Integer>> indentationSpans = Effects.INDENTATION.getSpans(str, paragraph, SpanCollectMode.EXACT);
         if (! indentationSpans.isEmpty()) {
             for (RTSpan<Integer> span : indentationSpans) {
                 currentIndentation += span.getValue();
             }
         }
         indentations.put(lineNr, currentIndentation);

         // find existing NumberSpans and add them to mSpans2Process to be removed
         List<RTSpan<Boolean>> existingSpans = getSpans(str, paragraph, SpanCollectMode.SPAN_FLAGS);
         mSpans2Process.removeSpans(existingSpans, paragraph);

/*
 * If the paragraph is selected then we sure have a number
 */
         boolean hasExistingSpans = ! existingSpans.isEmpty();
         boolean hasNumber = paragraph.isSelected(selectedParagraphs) ? enable : hasExistingSpans;

/*
 * If we have a number then apply a new span
 */
         if (hasNumber) {
             // let's determine the number for this paragraph
             int nr = 1;
             for (int line = 1; line < lineNr; line++) {
                 int indentation = indentations.get(line);
                 int number = numbers.get(line);
                 if (indentation < currentIndentation) {
                     // 1) less indentation -> number 1
                     nr = 1;
                 } else if (indentation == currentIndentation) {
                     // 2) same indentation + no numbering -> number 1
                     // 3) same indentation + numbering -> increment number
                     nr = number == 0 ? 1 : number + 1;
                 }
             }
             numbers.put(lineNr, nr);

             int margin = Helper.getLeadingMarging();
             NumberSpan numberSpan = new NumberSpan(nr++, margin, paragraph.isEmpty(), paragraph.isFirst(), paragraph.isLast());
             mSpans2Process.addSpan(numberSpan, paragraph);

             // if the paragraph has bullet spans, then remove them
             Effects.BULLET.findSpans2Remove(str, paragraph, mSpans2Process);
         }

         lineNr++;
     }

     // add or remove spans
     mSpans2Process.process(str);
 }
 
源代码15 项目: memoir   文件: NumberEffect.java
@Override
 public synchronized void applyToSelection(RTEditText editor, Selection selectedParagraphs, Boolean enable) {
     final Spannable str = editor.getText();

     mSpans2Process.clear();

     int lineNr = 1;
     SparseIntArray indentations = new SparseIntArray();
     SparseIntArray numbers = new SparseIntArray();
     for (Paragraph paragraph : editor.getParagraphs()) {

/*
          * We need to know the indentation for each paragraph to be able
 * to determine which paragraphs belong together (same indentation)
 */
         int currentIndentation = 0;
         List<RTSpan<Integer>> indentationSpans = Effects.INDENTATION.getSpans(str, paragraph, SpanCollectMode.EXACT);
         if (! indentationSpans.isEmpty()) {
             for (RTSpan<Integer> span : indentationSpans) {
                 currentIndentation += span.getValue();
             }
         }
         indentations.put(lineNr, currentIndentation);

         // find existing NumberSpans and add them to mSpans2Process to be removed
         List<RTSpan<Boolean>> existingSpans = getSpans(str, paragraph, SpanCollectMode.SPAN_FLAGS);
         mSpans2Process.removeSpans(existingSpans, paragraph);

/*
 * If the paragraph is selected then we sure have a number
 */
         boolean hasExistingSpans = ! existingSpans.isEmpty();
         boolean hasNumber = paragraph.isSelected(selectedParagraphs) ? enable : hasExistingSpans;

/*
 * If we have a number then apply a new span
 */
         if (hasNumber) {
             // let's determine the number for this paragraph
             int nr = 1;
             for (int line = 1; line < lineNr; line++) {
                 int indentation = indentations.get(line);
                 int number = numbers.get(line);
                 if (indentation < currentIndentation) {
                     // 1) less indentation -> number 1
                     nr = 1;
                 } else if (indentation == currentIndentation) {
                     // 2) same indentation + no numbering -> number 1
                     // 3) same indentation + numbering -> increment number
                     nr = number == 0 ? 1 : number + 1;
                 }
             }
             numbers.put(lineNr, nr);

             int margin = Helper.getLeadingMarging();
             NumberSpan numberSpan = new NumberSpan(nr++, margin, paragraph.isEmpty(), paragraph.isFirst(), paragraph.isLast());
             mSpans2Process.addSpan(numberSpan, paragraph);

             // if the paragraph has bullet spans, then remove them
             Effects.BULLET.findSpans2Remove(str, paragraph, mSpans2Process);
         }

         lineNr++;
     }

     // add or remove spans
     mSpans2Process.process(str);
 }
 
源代码16 项目: TurboLauncher   文件: ExifInterface.java
/**
 * Creates a new tag definition in this ExifInterface object for a given TID
 * and default IFD. Creating a definition with the same TID and default IFD
 * as a previous definition will override it.
 *
 * @param tagId the TID for the tag.
 * @param defaultIfd the default IFD for the tag.
 * @param tagType the type of the tag (see {@link ExifTag#getDataType()}).
 * @param defaultComponentCount the number of elements of this tag's type in
 *            the tags value.
 * @param allowedIfds the IFD's this tag is allowed to be put in.
 * @return the defined tag constant (e.g. {@link #TAG_IMAGE_WIDTH}) or
 *         {@link #TAG_NULL} if the definition could not be made.
 */
public int setTagDefinition(short tagId, int defaultIfd, short tagType,
        short defaultComponentCount, int[] allowedIfds) {
    if (sBannedDefines.contains(tagId)) {
        return TAG_NULL;
    }
    if (ExifTag.isValidType(tagType) && ExifTag.isValidIfd(defaultIfd)) {
        int tagDef = defineTag(defaultIfd, tagId);
        if (tagDef == TAG_NULL) {
            return TAG_NULL;
        }
        int[] otherDefs = getTagDefinitionsForTagId(tagId);
        SparseIntArray infos = getTagInfo();
        // Make sure defaultIfd is in allowedIfds
        boolean defaultCheck = false;
        for (int i : allowedIfds) {
            if (defaultIfd == i) {
                defaultCheck = true;
            }
            if (!ExifTag.isValidIfd(i)) {
                return TAG_NULL;
            }
        }
        if (!defaultCheck) {
            return TAG_NULL;
        }

        int ifdFlags = getFlagsFromAllowedIfds(allowedIfds);
        // Make sure no identical tags can exist in allowedIfds
        if (otherDefs != null) {
            for (int def : otherDefs) {
                int tagInfo = infos.get(def);
                int allowedFlags = getAllowedIfdFlagsFromInfo(tagInfo);
                if ((ifdFlags & allowedFlags) != 0) {
                    return TAG_NULL;
                }
            }
        }
        getTagInfo().put(tagDef, ifdFlags << 24 | (tagType << 16) | defaultComponentCount);
        return tagDef;
    }
    return TAG_NULL;
}
 
源代码17 项目: Android-RTEditor   文件: NumberEffect.java
@Override
public synchronized void applyToSelection(RTEditText editor, Selection selectedParagraphs, Boolean enable) {
    final Spannable str = editor.getText();

    mSpans2Process.clear();

    int lineNr = 1;
    SparseIntArray indentations = new SparseIntArray();
    SparseIntArray numbers = new SparseIntArray();

    // a manual for loop is faster than the for-each loop for an ArrayList:
    // see https://developer.android.com/training/articles/perf-tips.html#Loops
    ArrayList<Paragraph> paragraphs = editor.getParagraphs();
    for (int i = 0, size = paragraphs.size(); i < size; i++) {
        Paragraph paragraph = paragraphs.get(i);

        /*
         * We need to know the indentation for each paragraph to be able
         * to determine which paragraphs belong together (same indentation)
         */
        int currentIndentation = 0;
        List<RTSpan<Integer>> indentationSpans = Effects.INDENTATION.getSpans(str, paragraph, SpanCollectMode.EXACT);
        if (! indentationSpans.isEmpty()) {
            for (RTSpan<Integer> span : indentationSpans) {
                currentIndentation += span.getValue();
            }
        }
        indentations.put(lineNr, currentIndentation);

        // find existing NumberSpans and add them to mSpans2Process to be removed
        List<RTSpan<Boolean>> existingSpans = getSpans(str, paragraph, SpanCollectMode.SPAN_FLAGS);
        mSpans2Process.removeSpans(existingSpans, paragraph);

        /*
         * If the paragraph is selected then we sure have a number
         */
        boolean hasExistingSpans = ! existingSpans.isEmpty();
        boolean hasNumber = paragraph.isSelected(selectedParagraphs) ? enable : hasExistingSpans;

        /*
         * If we have a number then apply a new span
         */
        if (hasNumber) {
            // let's determine the number for this paragraph
            int nr = 1;
            for (int line = 1; line < lineNr; line++) {
                int indentation = indentations.get(line);
                int number = numbers.get(line);
                if (indentation < currentIndentation) {
                    // 1) less indentation -> number 1
                    nr = 1;
                } else if (indentation == currentIndentation) {
                    // 2) same indentation + no numbering -> number 1
                    // 3) same indentation + numbering -> increment number
                    nr = number == 0 ? 1 : number + 1;
                }
            }
            numbers.put(lineNr, nr);

            int margin = Helper.getLeadingMarging();
            NumberSpan numberSpan = new NumberSpan(nr++, margin, paragraph.isEmpty(), paragraph.isFirst(), paragraph.isLast());
            mSpans2Process.addSpan(numberSpan, paragraph);

            // if the paragraph has bullet spans, then remove them
            Effects.BULLET.findSpans2Remove(str, paragraph, mSpans2Process);
        }

        lineNr++;
    }

    // add or remove spans
    mSpans2Process.process(str);
}
 
源代码18 项目: Camera2   文件: ExifInterface.java
/**
 * Creates a new tag definition in this ExifInterface object for a given TID
 * and default IFD. Creating a definition with the same TID and default IFD
 * as a previous definition will override it.
 *
 * @param tagId                 the TID for the tag.
 * @param defaultIfd            the default IFD for the tag.
 * @param tagType               the type of the tag (see {@link ExifTag#getDataType()}).
 * @param defaultComponentCount the number of elements of this tag's type in
 *                              the tags value.
 * @param allowedIfds           the IFD's this tag is allowed to be put in.
 * @return the defined tag constant (e.g. {@link #TAG_IMAGE_WIDTH}) or
 * {@link #TAG_NULL} if the definition could not be made.
 */
public int setTagDefinition(short tagId, int defaultIfd, short tagType,
                            short defaultComponentCount, int[] allowedIfds)
{
    if (sBannedDefines.contains(tagId))
    {
        return TAG_NULL;
    }
    if (ExifTag.isValidType(tagType) && ExifTag.isValidIfd(defaultIfd))
    {
        int tagDef = defineTag(defaultIfd, tagId);
        if (tagDef == TAG_NULL)
        {
            return TAG_NULL;
        }
        int[] otherDefs = getTagDefinitionsForTagId(tagId);
        SparseIntArray infos = getTagInfo();
        // Make sure defaultIfd is in allowedIfds
        boolean defaultCheck = false;
        for (int i : allowedIfds)
        {
            if (defaultIfd == i)
            {
                defaultCheck = true;
            }
            if (!ExifTag.isValidIfd(i))
            {
                return TAG_NULL;
            }
        }
        if (!defaultCheck)
        {
            return TAG_NULL;
        }

        int ifdFlags = getFlagsFromAllowedIfds(allowedIfds);
        // Make sure no identical tags can exist in allowedIfds
        if (otherDefs != null)
        {
            for (int def : otherDefs)
            {
                int tagInfo = infos.get(def);
                int allowedFlags = getAllowedIfdFlagsFromInfo(tagInfo);
                if ((ifdFlags & allowedFlags) != 0)
                {
                    return TAG_NULL;
                }
            }
        }
        getTagInfo().put(tagDef, ifdFlags << 24 | (tagType << 16) | defaultComponentCount);
        return tagDef;
    }
    return TAG_NULL;
}
 
源代码19 项目: Telegram-FOSS   文件: DashMediaPeriod.java
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);
  }

  int[][] groupedAdaptationSetIndices = new int[adaptationSetCount][];
  boolean[] adaptationSetUsedFlags = new boolean[adaptationSetCount];

  int groupCount = 0;
  for (int i = 0; i < adaptationSetCount; i++) {
    if (adaptationSetUsedFlags[i]) {
      // This adaptation set has already been included in a group.
      continue;
    }
    adaptationSetUsedFlags[i] = true;
    Descriptor adaptationSetSwitchingProperty = findAdaptationSetSwitchingProperty(
        adaptationSets.get(i).supplementalProperties);
    if (adaptationSetSwitchingProperty == null) {
      groupedAdaptationSetIndices[groupCount++] = new int[] {i};
    } else {
      String[] extraAdaptationSetIds = Util.split(adaptationSetSwitchingProperty.value, ",");
      int[] adaptationSetIndices = new int[1 + extraAdaptationSetIds.length];
      adaptationSetIndices[0] = i;
      int outputIndex = 1;
      for (int j = 0; j < extraAdaptationSetIds.length; j++) {
        int extraIndex =
            idToIndexMap.get(
                Integer.parseInt(extraAdaptationSetIds[j]), /* valueIfKeyNotFound= */ -1);
        if (extraIndex != -1) {
          adaptationSetUsedFlags[extraIndex] = true;
          adaptationSetIndices[outputIndex] = extraIndex;
          outputIndex++;
        }
      }
      if (outputIndex < adaptationSetIndices.length) {
        adaptationSetIndices = Arrays.copyOf(adaptationSetIndices, outputIndex);
      }
      groupedAdaptationSetIndices[groupCount++] = adaptationSetIndices;
    }
  }

  return groupCount < adaptationSetCount
      ? Arrays.copyOf(groupedAdaptationSetIndices, groupCount) : groupedAdaptationSetIndices;
}
 
源代码20 项目: ucar-weex-core   文件: BorderUtil.java
static int fetchFromSparseArray(@Nullable SparseIntArray array, int position, int fallback) {
  return array == null ? fallback :
         array.get(position, array.get(Spacing.ALL));
}