List of usage examples for android.util SparseBooleanArray size
public int size()
From source file:net.naonedbus.fragment.impl.GroupesFragment.java
private void deleteCheckedItems() { final SparseBooleanArray checked = mListView.getCheckedItemPositions(); for (int i = 0; i < checked.size(); i++) { if (checked.valueAt(i)) { final int position = checked.keyAt(i); final int idGroupe = (int) mListView.getItemIdAtPosition(position); mGroupeManager.delete(getActivity().getContentResolver(), idGroupe); }//from w w w . j a v a 2s.c o m } }
From source file:net.naonedbus.fragment.impl.GroupesFragment.java
private int getFirstSelectedItemPosition() { final SparseBooleanArray checkedPositions = mListView.getCheckedItemPositions(); for (int i = 0; i < checkedPositions.size(); i++) { if (checkedPositions.valueAt(i)) { return checkedPositions.keyAt(i); }//from w w w.j a v a 2 s. com } return -1; }
From source file:com.fusionx.lightirc.ui.UserListFragment.java
protected List<WorldUser> getCheckedItems() { final List<WorldUser> checkedSessionPositions = new ArrayList<>(); if (mStickyListView == null) { return checkedSessionPositions; }/*from w w w . j a v a 2 s . c o m*/ final SparseBooleanArray checkedPositionsBool = mStickyListView.getCheckedItemPositions(); for (int i = 0; i < checkedPositionsBool.size(); i++) { if (checkedPositionsBool.valueAt(i)) { checkedSessionPositions.add(mAdapter.getItem(checkedPositionsBool.keyAt(i))); } } return checkedSessionPositions; }
From source file:com.muzima.view.cohort.FormTemplateWizardActivity.java
private boolean hasRegistrationFormSelected() { SparseBooleanArray checkedItemPositions = listView.getCheckedItemPositions(); boolean registrationFormSelected = false; for (int i = 0; i < checkedItemPositions.size(); i++) { if (checkedItemPositions.valueAt(i)) { AvailableForm selectedForm = (AvailableForm) listView .getItemAtPosition(checkedItemPositions.keyAt(i)); if (selectedForm.isRegistrationForm()) { registrationFormSelected = true; }//from w ww .j ava 2s. c om } } return registrationFormSelected; }
From source file:com.miz.mizuu.UnidentifiedTvShows.java
private void identifySelectedFiles() { SparseBooleanArray sba = mList.getCheckedItemPositions(); ArrayList<String> filepaths = new ArrayList<String>(); for (int i = 0; i < sba.size(); i++) { filepaths.add(mFilepaths.get(sba.keyAt(i)).getFullFilepath()); }//from w w w. j a va 2s.c om Intent i = new Intent(); i.setClass(this, IdentifyTvShowEpisode.class); i.putExtra("filepaths", filepaths); i.putExtra("showTitle", ""); i.putExtra("showId", ""); // Unidentified startActivity(i); }
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 w ww. j av a 2s.co m*/ 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);/*from w w w . jav a2s . co m*/ } } ContactPickerListener parent = (ContactPickerListener) getActivity(); if (parent != null) { parent.onContactsSelected(this, selected); } }
From source file:com.miz.mizuu.UnidentifiedFiles.java
private void identifySelectedFiles() { SparseBooleanArray sba = mList.getCheckedItemPositions(); ArrayList<String> filepaths = new ArrayList<String>(), rowIds = new ArrayList<String>(); for (int i = 0; i < sba.size(); i++) { filepaths.add(episodes.get(sba.keyAt(i)).getFullFilepath()); rowIds.add(episodes.get(sba.keyAt(i)).getRowId()); }//from w ww. ja va 2s . c om Intent i = new Intent(); i.setClass(this, IdentifyTvShow.class); i.putExtra("rowIds", rowIds.toArray(new String[rowIds.size()])); i.putExtra("rowId", "0"); i.putExtra("files", filepaths.toArray(new String[filepaths.size()])); i.putExtra("showName", ""); i.putExtra("oldShowId", "0"); i.putExtra("includeShowData", true); startActivity(i); }
From source file:org.spinsuite.bchat.view.FV_ThreadIndex.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); getListView().setMultiChoiceModeListener(new MultiChoiceModeListener() { @Override//from www .j av a 2 s.co m public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { // Capture total checked items final int checkedCount = getListView().getCheckedItemCount(); // Set the CAB title according to total checked items mode.setTitle(checkedCount + " " + getString(R.string.BChat_Selected)); // Calls toggleSelection method from ListViewAdapter Class m_Adapter.toggleSelection(position); } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.action_delete: SparseBooleanArray selectedItems = m_Adapter.getSelectedItems(); String[] ids = new String[selectedItems.size()]; for (int i = (selectedItems.size() - 1); i >= 0; i--) { if (selectedItems.valueAt(i)) { DisplayBChatThreadListItem selectedItem = m_Adapter.getItem(selectedItems.keyAt(i)); // Add Value ids[i] = selectedItem.getSPS_BC_Request_UUID(); // Remove Item m_Adapter.remove(selectedItem); } } // Delete Records in DB if (ids.length > 0) { BCMessageHandle.getInstance(m_ctx).deleteRequest(ids); } mode.finish(); return true; default: return false; } } @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { mode.getMenuInflater().inflate(R.menu.bc_thread_list_selected, menu); return true; } @Override public void onDestroyActionMode(ActionMode mode) { m_Adapter.removeSelection(); } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } }); }
From source file:cat.wuyingren.rorhelper.fragments.GameListFragment.java
private void deleteItems(SparseBooleanArray positions) { SparseBooleanArray chkItems = positions; //ArrayList<Game> selItems = new ArrayList<Game>(); ArrayList<Long> selItems = new ArrayList<Long>(); for (int i = 0; i < chkItems.size(); i++) { int position = chkItems.keyAt(i); if (chkItems.valueAt(i)) { selItems.add(adapter.getItem(position).getId()); }/* w ww.j a v a2 s . c o m*/ } DeleteGameTask task = new DeleteGameTask(); Long[] longs = new Long[selItems.size()]; longs = selItems.toArray(longs); task.execute(longs); /* for(Game g:selItems) { dataSource.deleteGame(g); mListener.onMultipleItemsDeletion(); //dataSource.deleteSchedule(context, s); //updateDB(); }*/ }