android.util.SparseBooleanArray#indexOfKey ( )源码实例Demo

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

源代码1 项目: deltachat-android   文件: GroupCreateActivity.java
private void updateGroupParticipants() {
  SparseBooleanArray currentChatContactIds = new SparseBooleanArray();
  for(int chatContactId : dcContext.getChatContacts(groupChatId)) {
    currentChatContactIds.put(chatContactId, false);
  }

  Set<Recipient> recipients = getAdapter().getRecipients();
  for(Recipient recipient : recipients) {
    Address address = recipient.getAddress();
    if(address.isDcContact()) {
      int contactId = address.getDcContactId();
      if(currentChatContactIds.indexOfKey(contactId) < 0) {
        dcContext.addContactToChat(groupChatId, contactId);
      } else {
        currentChatContactIds.put(contactId, true);
      }
    }
  }
  for(int index = 0; index < currentChatContactIds.size(); index++) {
    if (!currentChatContactIds.valueAt(index)) {
      dcContext.removeContactFromChat(groupChatId, currentChatContactIds.keyAt(index));
    }
  }
}
 
public void onListItemClick(ListView listView, View view, int position, long id) {
	SparseBooleanArray checkedItems = getListView().getCheckedItemPositions();

	if (checkedItems.indexOfKey(position) >=0 && checkedItems.valueAt(checkedItems.indexOfKey(position))) {
		if (position == 0 || position == 2) {
			getListView().setItemChecked(1, true);
		}
	} else if (position == 1) {
		if ((checkedItems.indexOfKey(0) >=0 && checkedItems.valueAt(checkedItems.indexOfKey(0))) || (checkedItems.indexOfKey(2) >=0 && checkedItems.valueAt(checkedItems.indexOfKey(2)))) {
			getListView().setItemChecked(position, true);
		}
	}

	for(int i = 0, size = getListView().getCheckedItemPositions().size(); i < size; i++) {
		Boolean b = getListView().getCheckedItemPositions().valueAt(i);
		if(b) {
			clearDataButton.setEnabled(true);
			return;
		}
	}

	clearDataButton.setEnabled(false);
}
 
源代码3 项目: MediaSDK   文件: DefaultTrackSelector.java
private static boolean areRendererDisabledFlagsEqual(
    SparseBooleanArray first, SparseBooleanArray second) {
  int firstSize = first.size();
  if (second.size() != firstSize) {
    return false;
  }
  // Only true values are put into rendererDisabledFlags, so we don't need to compare values.
  for (int indexInFirst = 0; indexInFirst < firstSize; indexInFirst++) {
    if (second.indexOfKey(first.keyAt(indexInFirst)) < 0) {
      return false;
    }
  }
  return true;
}
 
源代码4 项目: TelePlus-Android   文件: DefaultTrackSelector.java
private static boolean areRendererDisabledFlagsEqual(
    SparseBooleanArray first, SparseBooleanArray second) {
  int firstSize = first.size();
  if (second.size() != firstSize) {
    return false;
  }
  // Only true values are put into rendererDisabledFlags, so we don't need to compare values.
  for (int indexInFirst = 0; indexInFirst < firstSize; indexInFirst++) {
    if (second.indexOfKey(first.keyAt(indexInFirst)) < 0) {
      return false;
    }
  }
  return true;
}
 
源代码5 项目: TelePlus-Android   文件: DefaultTrackSelector.java
private static boolean areRendererDisabledFlagsEqual(
    SparseBooleanArray first, SparseBooleanArray second) {
  int firstSize = first.size();
  if (second.size() != firstSize) {
    return false;
  }
  // Only true values are put into rendererDisabledFlags, so we don't need to compare values.
  for (int indexInFirst = 0; indexInFirst < firstSize; indexInFirst++) {
    if (second.indexOfKey(first.keyAt(indexInFirst)) < 0) {
      return false;
    }
  }
  return true;
}
 
源代码6 项目: android-topeka   文件: AnswerHelper.java
/**
 * Checks whether a provided answer is correct.
 *
 * @param checkedItems The items that were selected.
 * @param answerIds The actual correct answer ids.
 * @return <code>true</code> if correct else <code>false</code>.
 */
public static boolean isAnswerCorrect(SparseBooleanArray checkedItems, int[] answerIds) {
    if (null == checkedItems || null == answerIds) {
        Log.i(TAG, "isAnswerCorrect got a null parameter input.");
        return false;
    }
    for (int answer : answerIds) {
        if (0 > checkedItems.indexOfKey(answer)) {
            return false;
        }
    }
    return checkedItems.size() == answerIds.length;
}
 
源代码7 项目: Telegram-FOSS   文件: DefaultTrackSelector.java
private static boolean areRendererDisabledFlagsEqual(
    SparseBooleanArray first, SparseBooleanArray second) {
  int firstSize = first.size();
  if (second.size() != firstSize) {
    return false;
  }
  // Only true values are put into rendererDisabledFlags, so we don't need to compare values.
  for (int indexInFirst = 0; indexInFirst < firstSize; indexInFirst++) {
    if (second.indexOfKey(first.keyAt(indexInFirst)) < 0) {
      return false;
    }
  }
  return true;
}
 
源代码8 项目: Telegram   文件: DefaultTrackSelector.java
private static boolean areRendererDisabledFlagsEqual(
    SparseBooleanArray first, SparseBooleanArray second) {
  int firstSize = first.size();
  if (second.size() != firstSize) {
    return false;
  }
  // Only true values are put into rendererDisabledFlags, so we don't need to compare values.
  for (int indexInFirst = 0; indexInFirst < firstSize; indexInFirst++) {
    if (second.indexOfKey(first.keyAt(indexInFirst)) < 0) {
      return false;
    }
  }
  return true;
}