use of android.util.SparseBooleanArray in project SeriesGuide by UweTrottmann.
the class ManageListsDialogFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View layout = inflater.inflate(R.layout.dialog_manage_lists, container, false);
// buttons
Button dontAddButton = (Button) layout.findViewById(R.id.buttonNegative);
dontAddButton.setText(android.R.string.cancel);
dontAddButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
Button addButton = (Button) layout.findViewById(R.id.buttonPositive);
addButton.setText(android.R.string.ok);
addButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// add item to selected lists, remove from previously selected lists
SparseBooleanArray checkedLists = mAdapter.getCheckedPositions();
List<String> addToTheseLists = new ArrayList<>();
List<String> removeFromTheseLists = new ArrayList<>();
for (int position = 0; position < mAdapter.getCount(); position++) {
final Cursor listEntry = (Cursor) mAdapter.getItem(position);
boolean wasListChecked = !TextUtils.isEmpty(listEntry.getString(ListsQuery.LIST_ITEM_ID));
boolean isListChecked = checkedLists.get(position);
String listId = listEntry.getString(ListsQuery.LIST_ID);
if (wasListChecked && !isListChecked) {
// remove from list
removeFromTheseLists.add(listId);
} else if (!wasListChecked && isListChecked) {
// add to list
addToTheseLists.add(listId);
}
}
int itemTvdbId = getArguments().getInt(InitBundle.INT_ITEM_TVDB_ID);
int itemType = getArguments().getInt(InitBundle.INT_ITEM_TYPE);
ListsTools.changeListsOfItem(SgApp.from(getActivity()), itemTvdbId, itemType, addToTheseLists, removeFromTheseLists);
dismiss();
}
});
// lists list
mListView = (ListView) layout.findViewById(R.id.list);
/*
* As using CHOICE_MODE_MULTIPLE does not seem to work before Jelly
* Bean, do everything ourselves.
*/
mListView.setOnItemClickListener(this);
return layout;
}
use of android.util.SparseBooleanArray in project android_frameworks_base by ParanoidAndroid.
the class NetworkPolicyManagerService method computeUidForegroundLocked.
/**
* Foreground for PID changed; recompute foreground at UID level. If
* changed, will trigger {@link #updateRulesForUidLocked(int)}.
*/
private void computeUidForegroundLocked(int uid) {
final SparseBooleanArray pidForeground = mUidPidForeground.get(uid);
// current pid is dropping foreground; examine other pids
boolean uidForeground = false;
final int size = pidForeground.size();
for (int i = 0; i < size; i++) {
if (pidForeground.valueAt(i)) {
uidForeground = true;
break;
}
}
final boolean oldUidForeground = mUidForeground.get(uid, false);
if (oldUidForeground != uidForeground) {
// foreground changed, push updated rules
mUidForeground.put(uid, uidForeground);
updateRulesForUidLocked(uid);
}
}
use of android.util.SparseBooleanArray in project android_frameworks_base by ParanoidAndroid.
the class UsbSettingsManager method dump.
public void dump(FileDescriptor fd, PrintWriter pw) {
synchronized (mLock) {
pw.println(" Device permissions:");
for (String deviceName : mDevicePermissionMap.keySet()) {
pw.print(" " + deviceName + ": ");
SparseBooleanArray uidList = mDevicePermissionMap.get(deviceName);
int count = uidList.size();
for (int i = 0; i < count; i++) {
pw.print(Integer.toString(uidList.keyAt(i)) + " ");
}
pw.println("");
}
pw.println(" Accessory permissions:");
for (UsbAccessory accessory : mAccessoryPermissionMap.keySet()) {
pw.print(" " + accessory + ": ");
SparseBooleanArray uidList = mAccessoryPermissionMap.get(accessory);
int count = uidList.size();
for (int i = 0; i < count; i++) {
pw.print(Integer.toString(uidList.keyAt(i)) + " ");
}
pw.println("");
}
pw.println(" Device preferences:");
for (DeviceFilter filter : mDevicePreferenceMap.keySet()) {
pw.println(" " + filter + ": " + mDevicePreferenceMap.get(filter));
}
pw.println(" Accessory preferences:");
for (AccessoryFilter filter : mAccessoryPreferenceMap.keySet()) {
pw.println(" " + filter + ": " + mAccessoryPreferenceMap.get(filter));
}
}
}
use of android.util.SparseBooleanArray in project android_frameworks_base by ParanoidAndroid.
the class UsbSettingsManager method grantDevicePermission.
public void grantDevicePermission(UsbDevice device, int uid) {
synchronized (mLock) {
String deviceName = device.getDeviceName();
SparseBooleanArray uidList = mDevicePermissionMap.get(deviceName);
if (uidList == null) {
uidList = new SparseBooleanArray(1);
mDevicePermissionMap.put(deviceName, uidList);
}
uidList.put(uid, true);
}
}
use of android.util.SparseBooleanArray in project RoboBinding by RoboBinding.
the class SparseBooleanArrayCheckedItemPositionsAttributeTest method whenObserveChangesOnTheView_thenValueModelShouldReceiveTheChange.
@Test
public void whenObserveChangesOnTheView_thenValueModelShouldReceiveTheChange() {
SparseBooleanArray emptySparseBooleanArray = new SparseBooleanArray();
ValueModel<SparseBooleanArray> valueModel = ValueModelUtils.create(emptySparseBooleanArray);
attribute.observeChangesOnTheView(viewAddOn, valueModel, view);
setItemsChecked(SparseBooleanArrayUtils.toSet(checkedItemPositions));
assertSparseBooleanArrayEquals(checkedItemPositions, valueModel.getValue());
}
Aggregations