Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ad28bed5 authored by Romain Guy's avatar Romain Guy Committed by The Android Open Source Project
Browse files

AI 144042: Fixes #1742109. Add a new API to ListView to return the list of checked items ids.

  BUG=1742109

Automated import of CL 144042
parent 096f41d5
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -122838,7 +122838,7 @@
<method name="setOrientation"
 return="void"
 abstract="false"
 native="true"
 native="false"
 synchronized="false"
 static="true"
 final="false"
@@ -150981,6 +150981,17 @@
 visibility="public"
>
</method>
<method name="getCheckItemIds"
 return="long[]"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getCheckedItemPosition"
 return="int"
 abstract="false"
+23 −0
Original line number Diff line number Diff line
@@ -3219,6 +3219,29 @@ public class ListView extends AbsListView {
        return null;
    }

    /**
     * Returns the set of checked items ids. The result is only valid if
     * the choice mode has not been set to {@link #CHOICE_MODE_SINGLE}.
     *
     * @return A new array which contains the id of each checked item in the list.
     */
    public long[] getCheckItemIds() {
        if (mChoiceMode != CHOICE_MODE_NONE && mCheckStates != null && mAdapter != null) {
            final SparseBooleanArray states = mCheckStates;
            final int count = states.size();
            final long[] ids = new long[count];
            final ListAdapter adapter = mAdapter;

            for (int i = 0; i < count; i++) {
                ids[i]= adapter.getItemId(states.keyAt(i));
            }

            return ids;
        }

        return new long[0];
    }

    /**
     * Clear any choices previously set
     */