Search in sources :

Example 1 with SparseBooleanArray

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;
}
Also used : Button(android.widget.Button) SparseBooleanArray(android.util.SparseBooleanArray) OnClickListener(android.view.View.OnClickListener) ArrayList(java.util.ArrayList) List(java.util.List) Cursor(android.database.Cursor) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) CheckedTextView(android.widget.CheckedTextView) ListView(android.widget.ListView)

Example 2 with SparseBooleanArray

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);
    }
}
Also used : SparseBooleanArray(android.util.SparseBooleanArray)

Example 3 with SparseBooleanArray

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));
        }
    }
}
Also used : SparseBooleanArray(android.util.SparseBooleanArray) UsbAccessory(android.hardware.usb.UsbAccessory)

Example 4 with SparseBooleanArray

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);
    }
}
Also used : SparseBooleanArray(android.util.SparseBooleanArray)

Example 5 with SparseBooleanArray

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());
}
Also used : SparseBooleanArray(android.util.SparseBooleanArray) Test(org.junit.Test)

Aggregations

SparseBooleanArray (android.util.SparseBooleanArray)283 ArrayList (java.util.ArrayList)43 View (android.view.View)32 Selection (com.android.documentsui.dirlist.MultiSelectManager.Selection)30 Point (android.graphics.Point)28 ViewGroup (android.view.ViewGroup)20 ListView (android.widget.ListView)15 HashMap (java.util.HashMap)15 Paint (android.graphics.Paint)13 Intent (android.content.Intent)11 Map (java.util.Map)11 File (java.io.File)10 SparseArray (android.util.SparseArray)8 SuppressLint (android.annotation.SuppressLint)7 SparseIntArray (android.util.SparseIntArray)7 AdapterView (android.widget.AdapterView)7 Cursor (android.database.Cursor)6 ActionMenuChildView (com.actionbarsherlock.internal.view.menu.ActionMenuView.ActionMenuChildView)6 IndentingPrintWriter (com.android.internal.util.IndentingPrintWriter)6 List (java.util.List)6