Java Code Examples for android.util.SparseBooleanArray#indexOfKey()

The following examples show how to use android.util.SparseBooleanArray#indexOfKey() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GroupCreateActivity.java    From deltachat-android with GNU General Public License v3.0 6 votes vote down vote up
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));
    }
  }
}
 
Example 2
Source File: ClearDataPreferenceActivity.java    From mage-android with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 3
Source File: DefaultTrackSelector.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 4
Source File: DefaultTrackSelector.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 5
Source File: DefaultTrackSelector.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 6
Source File: AnswerHelper.java    From android-topeka with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 7
Source File: DefaultTrackSelector.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 8
Source File: DefaultTrackSelector.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
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;
}