Example usage for android.util SparseBooleanArray size

List of usage examples for android.util SparseBooleanArray size

Introduction

In this page you can find the example usage for android.util SparseBooleanArray size.

Prototype

public int size() 

Source Link

Document

Returns the number of key-value mappings that this SparseBooleanArray currently stores.

Usage

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;
        }// ww w.j av  a2  s. c  om
    }

    prepareMode(count);
    prepareAddItem(menu);
    prepareAboutItem(menu, lv, aboutItemVisible);
    prepareDeleteItem(menu);
    prepareShareItems(menu, shareItemsVisible);
    return true;
}

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());
        }/*from w w w.  ja  va 2s.  c o  m*/
    }

    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  w  w  w  .  ja  v a 2  s  .  co  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 ww.  jav a  2  s. c o m
    }

    // 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);//from   w ww. j a  v a2s.  com
        }
    }

    Intent i = new Intent(getContext(), MapsActivity.class);
    i.putExtra("selectedMails", mails);
    startActivity(i);
}

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());
        }/*w  ww .j a v a 2s.  c  o  m*/
    }

    mPage.getData().putStringArrayList(Page.SIMPLE_DATA_KEY, selections);
    mPage.notifyDataChanged();
}

From source file:com.connectsdk.smarthomesampler.fragment.SetupMultiChoiceFragment.java

@OnClick(R.id.btnNext)
public void onNextStep() {
    SparseBooleanArray checked = listView.getCheckedItemPositions();
    ids.clear();// ww w.  j  av a 2s .c o m
    if (adapter != null) {
        for (int i = 0; i < checked.size(); i++) {
            if (checked.get(checked.keyAt(i))) {
                T device = adapter.getItem(checked.keyAt(i));
                ids.add(getDeviceId(device));
            }
        }
    }
    save();
}

From source file:de.vanita5.twittnuker.fragment.support.DataExportImportTypeSelectorDialogFragment.java

private int getCheckedFlags() {
    final SparseBooleanArray checked = mListView.getCheckedItemPositions();
    int flags = 0;
    for (int i = 0, j = checked.size(); i < j; i++) {
        final Type type = (Type) mListView.getItemAtPosition(i);
        if (checked.valueAt(i)) {
            flags |= type.flag;//ww w .j  av a2s .  c o  m
        }
    }
    return flags;
}

From source file:org.spinsuite.bchat.view.V_BChat_AddGroup.java

/**
 * Valid the Group Name/*w  ww .  j a va 2s . c om*/
 * @author Yamel Senih, ysenih@erpcya.com, ERPCyA http://www.erpcya.com
 * @return void
 */
private void okAction() {
    if (et_GroupName.getText() == null || et_GroupName.getText().toString().trim().length() == 0) {
        Msg.alertMsg(this, getString(R.string.BChat_MustFillGroupName));
    } else {
        SparseBooleanArray itemsChecked = lv_Contacts.getCheckedItemPositions();
        if (itemsChecked.size() == 0) {
            Msg.alertMsg(this, getString(R.string.BChat_MustFillGroupName));
        } else {
            //   Create Request
            SyncRequest_BC request = new SyncRequest_BC(null, String.valueOf(Env.getAD_User_ID()), null,
                    et_GroupName.getText().toString(), null, null, true);
            for (int i = 0; i < itemsChecked.size(); i++) {
                boolean selected = itemsChecked.get(i);
                if (selected) {
                    DisplayBChatContactItem contact = m_ContactAdapter.getItem(i);
                    request.addUser(new Invited(contact.getRecord_ID(), MQTTDefaultValues.STATUS_CREATED));
                }
            }
            //   Add Local User
            request.addUser(new Invited(Env.getAD_User_ID(), MQTTDefaultValues.STATUS_CREATED));
            //   Save Request
            BCMessageHandle.getInstance(this).sendRequest(request);
            //   Add Param
            Intent intent = getIntent();
            intent.putExtra("SPS_BC_Request_UUID", request.getSPS_BC_Request_UUID());
            setResult(Activity.RESULT_OK, intent);
            finish();
        }
    }
}

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  ww  .  j a v a 2  s.  c o 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();
}