List of usage examples for android.util SparseBooleanArray get
public boolean get(int key)
false
if no such mapping has been made. From source file:in.rab.bildkort.SentenceFragment.java
public ArrayList<String> getSelected() { ArrayList<String> selected = new ArrayList<>(); ListView listView = getListView(); SparseBooleanArray items = listView.getCheckedItemPositions(); if (items == null) { return selected; }// w w w . jav a2s . c om for (int i = 0; i < mSentences.size(); i++) { if (!items.get(i)) { continue; } selected.add(mSentences.get(i).replace("strong>", "em>")); } return selected; }
From source file:com.kyakujin.android.tagnotepad.ui.TagDialogListFragment.java
/** * MappingTable?/* ww w . ja va 2 s . c om*/ * ????ID?????mapping? * ?????ID????ON???? */ private void updateMappingTable() { // ????ID?? String noteId = Notes.getId(mCurrentNote); String where = Mapping.NOTEID + " = " + noteId; getActivity().getContentResolver().delete(Mapping.CONTENT_URI, where, null); // ??????? SparseBooleanArray checkedArray = mTagListView.getCheckedItemPositions(); ContentValues values = new ContentValues(); Cursor c; for (int i = 0; i < mTagListView.getCount(); i++) { if (checkedArray.get(i)) { c = (Cursor) mTagListView.getItemAtPosition(i); values.put(Mapping.NOTEID, noteId); values.put(Mapping.TAGID, c.getString(TagsQuery.TAGS_ID)); getActivity().getContentResolver().insert(Mapping.CONTENT_URI, values); } } checkedArray.clear(); }
From source file:com.example.android.bluetoothchat.DeviceListActivity.java
private void connect() { // ????/*from ww w . j a va 2 s. co m*/ mBtAdapter.cancelDiscovery(); // ???MAC address??, ???View???17?char ? // ArrayList<String> address = new ArrayList<>(); SparseBooleanArray checkeditempositions = pairedListView.getCheckedItemPositions(); String[] address = new String[pairedListView.getCheckedItemCount()]; for (int i = 0; i < pairedListView.getCount(); i++) { if (checkeditempositions.get(i) == true) { //???(????)???????? int key = checkeditempositions.keyAt(i); String info = pairedListView.getItemAtPosition(key).toString(); // address.add(info.substring(info.length() - 17)); address[i] = info.substring(info.length() - 17); } } // for(int i=0; i<address.size();i++) // Toast.makeText(this, i +"?"+ address.get(i),Toast.LENGTH_SHORT).show(); for (int i = 0; i < address.length; i++) Toast.makeText(this, i + "?" + address[i], Toast.LENGTH_SHORT).show(); // IntentMAC address? // Intent intent = new Intent(); // intent.putStringArrayListExtra(EXTRA_DEVICE_ADDRESS, address); // result???? // setResult(Activity.RESULT_OK, intent); finish(); }
From source file:org.getlantern.firetweet.fragment.BaseFiltersFragment.java
@Override public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) { switch (item.getItemId()) { case MENU_DELETE: { final Expression where = Expression.in(new Column(Filters._ID), new RawItemArray(mListView.getCheckedItemIds())); mResolver.delete(getContentUri(), where.getSQL(), null); break;//from ww w . ja va 2 s. c om } case MENU_INVERSE_SELECTION: { final SparseBooleanArray positions = mListView.getCheckedItemPositions(); for (int i = 0, j = mListView.getCount(); i < j; i++) { mListView.setItemChecked(i, !positions.get(i)); } return true; } default: { return false; } } mode.finish(); return true; }
From source file:com.openerp.addons.note.AddFollowerFragment.java
public void getSelecetedPartners() { SparseBooleanArray checked = partner_list.getCheckedItemPositions(); for (int i = 0; i < checked.size(); i++) { int key = checked.keyAt(i); boolean value = checked.get(key); if (value) { res_partners = new Res_PartnerDBHelper(scope.context()); if (!res_partners.hasRecord(res_partners, listRows.get(key).getRow_id())) { ContentValues values = new ContentValues(); ArrayList<Fields> cols = new Res_PartnerDBHelper(scope.context()).getServerColumns(); for (Fields field : cols) { values.put(field.getName(), listRows.get(key).getRow_data().get(field.getName()).toString()); }/*from ww w . j a v a 2 s . com*/ res_partners.create(res_partners, values); } addFollowers(listRows.get(key).getRow_id()); } } flag = false; getActivity().getSupportFragmentManager().popBackStack(); }
From source file:org.kontalk.ui.ContactsListFragment.java
private void openSelectedContacts(SparseBooleanArray checked) { List<Contact> selected = new ArrayList<>(checked.size()); for (int i = 0, c = mListAdapter.getCount(); i < c; ++i) { if (checked.get(i)) { Cursor cursor = (Cursor) mListAdapter.getItem(i); Contact contact = Contact.fromUsersCursor(getContext(), cursor); selected.add(contact);/* www. j ava2 s .c o m*/ } } ContactPickerListener parent = (ContactPickerListener) getActivity(); if (parent != null) { parent.onContactsSelected(this, selected); } }
From source file:com.stepstone.stepper.internal.widget.TabsContainer.java
/** * Changes the position of the current step and updates the UI based on it. * @param currentStepPosition new current step * @param stepErrors map containing error state for step positions *//* w ww . j a v a 2 s. c o m*/ public void updateSteps(int currentStepPosition, SparseBooleanArray stepErrors) { int size = mStepTitles.size(); for (int i = 0; i < size; i++) { StepTab childTab = (StepTab) mTabsInnerContainer.getChildAt(i); boolean done = i < currentStepPosition; final boolean current = i == currentStepPosition; boolean hasError = stepErrors.get(i); childTab.updateState(hasError, done, current); if (current) { mTabsScrollView.smoothScrollTo(childTab.getLeft() - mContainerLateralPadding, 0); } } }
From source file:pl.bcichecki.rms.client.android.fragments.DevicesListFragment.java
private Device getFirstCheckedItem() { if (getListView().getCheckedItemCount() != 1) { return null; }/*from www . j a v a 2 s . c o m*/ SparseBooleanArray checkedItemPositions = getListView().getCheckedItemPositions(); for (int i = 0; i < getListAdapter().getCount(); i++) { if (checkedItemPositions.get(i)) { return (Device) getListAdapter().getItem(i); } } return null; }
From source file:android.preference.MultiSelectDragListPreference.java
private void refreshNewValues() { mNewValues.clear();/*from w ww. jav a 2s. c o m*/ int n = adapter.getCount(); SparseBooleanArray checkedPositions = listView.getCheckedItemPositions(); for (int i = 0; i < n; i++) { if (checkedPositions.get(i) == true) { mNewValues.add((String) mEntryValues[ArrayUtils.indexOf(mEntries, adapter.getItem(i))]); } } }
From source file:com.tinfoil.sms.sms.KeyExchangeManager.java
/** * The onClick action for when a for when the reject button has been * clicked. Deletes every key exchange message selected. * @param view The View/* w w w . j ava 2s . c o m*/ */ public void reject(View view) { if (runThread.getEntries() != null) { ListView list = (ListView) this.findViewById(R.id.key_exchange_list); SparseBooleanArray sba = list.getCheckedItemPositions(); for (int i = 0; i < runThread.getEntries().size(); i++) { if (sba.get(i)) { dba.deleteKeyExchangeMessage(runThread.getEntries().get(i).getNumber()); runThread.getEntries().remove(runThread.getEntries().get(i)); } } //finish(); } updateList(); }