List of usage examples for android.util SparseBooleanArray valueAt
public boolean valueAt(int index)
0...size()-1
, returns the value from the index
th key-value mapping that this SparseBooleanArray stores. From source file:de.vanita5.twittnuker.popup.AccountSelectorPopupWindow.java
@NonNull public long[] getSelectedAccountIds() { final long[] accountIds = new long[mGridView.getCheckedItemCount()]; final SparseBooleanArray positions = mGridView.getCheckedItemPositions(); for (int i = 0, j = positions.size(), k = 0; i < j; i++) { if (positions.valueAt(i)) { accountIds[k++] = mAdapter.getItem(positions.keyAt(i)).account_id; }/*from ww w . j ava 2s . c o m*/ } return accountIds; }
From source file:com.nagopy.android.mypkgs.ApplicationListFragment.java
@SuppressWarnings("unchecked") @NonNull//w w w . ja v a2 s . c o m <T> List<T> getCheckedItemList(@NonNull ListView listView) { List<T> checkedItemList = new ArrayList<>(); SparseBooleanArray checkedItemPositions = listView.getCheckedItemPositions(); for (int i = 0; i < checkedItemPositions.size(); i++) { if (checkedItemPositions.valueAt(i)) { checkedItemList.add((T) listView.getItemAtPosition(checkedItemPositions.keyAt(i))); } } return checkedItemList; }
From source file:br.com.hojeti.wizardpager.ui.MultipleChoiceFragment.java
@Override public void onListItemClick(ListView l, View v, int position, long id) { SparseBooleanArray checkedPositions = getListView().getCheckedItemPositions(); ArrayList<String> selections = new ArrayList<String>(); for (int i = 0; i < checkedPositions.size(); i++) { if (checkedPositions.valueAt(i)) { selections.add(getListAdapter().getItem(checkedPositions.keyAt(i)).toString()); }// ww w . j a v a 2 s . c om } mPage.getData().putStringArrayList(Page.SIMPLE_DATA_KEY, selections); mPage.notifyDataChanged(); }
From source file:com.grottworkshop.gwswizardpager.ui.MultipleChoiceFragment.java
@Override public void onListItemClick(ListView l, View v, int position, long id) { SparseBooleanArray checkedPositions = getListView().getCheckedItemPositions(); ArrayList<String> selections = new ArrayList<>(); for (int i = 0; i < checkedPositions.size(); i++) { if (checkedPositions.valueAt(i)) { selections.add(getListAdapter().getItem(checkedPositions.keyAt(i)).toString()); }//from ww w .j a va 2 s. com } mPage.getData().putStringArrayList(Page.SIMPLE_DATA_KEY, selections); mPage.notifyDataChanged(); }
From source file:com.btmura.android.reddit.app.SubredditActionModeController.java
@Override public boolean onPrepareActionMode(ActionMode mode, Menu menu, ListView lv) { int count = lv.getCheckedItemCount(); boolean aboutItemVisible = count == 1; boolean shareItemsVisible = count == 1; SparseBooleanArray checked = lv.getCheckedItemPositions(); int size = checked.size(); for (int i = 0; i < size; i++) { if (checked.valueAt(i)) { int position = checked.keyAt(i); String subreddit = adapter.getName(position); boolean hasSidebar = Subreddits.hasSidebar(subreddit); aboutItemVisible &= hasSidebar; shareItemsVisible &= hasSidebar; }/*from w w w . j a v a 2 s . c o m*/ } prepareMode(count); prepareAddItem(menu); prepareAboutItem(menu, lv, aboutItemVisible); prepareDeleteItem(menu); prepareShareItems(menu, shareItemsVisible); return true; }
From source file:com.sharpcart.android.wizardpager.wizard.ui.MultipleChoiceFragment.java
@Override public void onListItemClick(final ListView l, final View v, final int position, final long id) { final SparseBooleanArray checkedPositions = getListView().getCheckedItemPositions(); final ArrayList<String> selections = new ArrayList<String>(); for (int i = 0; i < checkedPositions.size(); i++) { if (checkedPositions.valueAt(i)) { selections.add(getListAdapter().getItem(checkedPositions.keyAt(i)).toString()); }//from ww w . ja v a 2 s. c o m } mPage.getData().putStringArrayList(Page.SIMPLE_DATA_KEY, selections); mPage.notifyDataChanged(); }
From source file:ch.hesso.master.sweetcity.activity.tag.TagSelectionActivity.java
@Override public void onClick(View v) { SparseBooleanArray checked = listView.getCheckedItemPositions(); ArrayList<Integer> selectedItems = new ArrayList<Integer>(); for (int i = 0; i < checked.size(); i++) { int position = checked.keyAt(i); if (checked.valueAt(i)) { selectedItems.add(CurrentTagList.getInstance().getPosition(adapter.getItem(position))); }//from w w w. ja v a 2 s .c om } // Return tag selection list to the parent activity Intent resultIntent = new Intent(); Bundle bundle = new Bundle(); bundle.putIntegerArrayList("selectedItems", selectedItems); resultIntent.putExtras(bundle); setResult(Activity.RESULT_OK, resultIntent); finish(); }
From source file:com.school.mailclient.app.fragment.InboxFragment.java
@Override public void onClick(View v) { ArrayList<Mail> mails = new ArrayList<Mail>(); SparseBooleanArray selected = adapter.getSelectedIds(); short size = (short) selected.size(); for (byte I = 0; I < size; I++) { if (selected.valueAt(I)) { Mail selectedItem = adapter.getItem(selected.keyAt(I)); mails.add(selectedItem);/* www .j a v a 2 s. c o m*/ } } Intent i = new Intent(getContext(), MapsActivity.class); i.putExtra("selectedMails", mails); startActivity(i); }
From source file:com.pentapus.pentapusdmh.Fragments.EncounterPrep.AddMonster.WizardMonsterEdit.DmgVulFragment.java
@Override public void onListItemClick(ListView l, View v, int position, long id) { SparseBooleanArray checkedPositions = getListView().getCheckedItemPositions(); if (selections != null) { selections = new ArrayList<String>(); }/*from w w w .j a v a2s .co m*/ for (int i = 0; i < checkedPositions.size(); i++) { if (checkedPositions.valueAt(i)) { selections.add(getListAdapter().getItem(checkedPositions.keyAt(i)).toString()); } } mPage.getData().putStringArrayList(Page.SIMPLE_DATA_KEY, selections); mPage.notifyDataChanged(); }
From source file:org.akop.crosswords.fragment.BaseFragment.java
protected void putSparseBooleanArray(Bundle bundle, String prefix, SparseBooleanArray array) { int size = array.size(); int keys[] = new int[size]; boolean values[] = new boolean[size]; for (int i = 0; i < size; i++) { keys[i] = array.keyAt(i);//from ww w . j av a 2 s . c o m values[i] = array.valueAt(i); } bundle.putIntArray(prefix + "_keys", keys); bundle.putBooleanArray(prefix + "_values", values); }