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

Commit 2614c6c1 authored by Adam Powell's avatar Adam Powell
Browse files

Fix bug 3167099 and bug 3009490 - GridView choice modes and

getCheckedItemCount after orientation change

Remove the restriction on choice modes for GridView - this is handled
by common code in AbsListView. Persist the checked item count in saved
instance state.

Change-Id: Iebb964bb3c43779c082a458ea3f2754ab694b69d
parent d7120ed6
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1210,6 +1210,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
        int position;
        int height;
        String filter;
        int checkedItemCount;
        SparseBooleanArray checkState;
        LongSparseArray<Boolean> checkIdState;

@@ -1231,6 +1232,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
            position = in.readInt();
            height = in.readInt();
            filter = in.readString();
            checkedItemCount = in.readInt();
            checkState = in.readSparseBooleanArray();
            long[] idState = in.createLongArray();

@@ -1249,6 +1251,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
            out.writeInt(position);
            out.writeInt(height);
            out.writeString(filter);
            out.writeInt(checkedItemCount);
            out.writeSparseBooleanArray(checkState);
            out.writeLongArray(checkIdState != null ? checkIdState.getKeys() : new long[0]);
        }
@@ -1329,6 +1332,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te

        ss.checkState = mCheckStates;
        ss.checkIdState = mCheckedIdStates;
        ss.checkedItemCount = mCheckedItemCount;

        return ss;
    }
@@ -1370,6 +1374,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
            mCheckedIdStates = ss.checkIdState;
        }

        mCheckedItemCount = ss.checkedItemCount;

        requestLayout();
    }

+0 −20
Original line number Diff line number Diff line
@@ -107,26 +107,6 @@ public class GridView extends AbsListView {
        a.recycle();
    }

    /**
     * Set how the user may select items from the grid.
     *
     * <p>GridView only supports {@link AbsListView#CHOICE_MODE_NONE} and
     * {@link AbsListView#CHOICE_MODE_MULTIPLE_MODAL}. Attempting to set an unsupported choice
     * mode will throw an UnsupportedOperationException.
     */
    @Override
    public void setChoiceMode(int choiceMode) {
        switch (choiceMode) {
        case CHOICE_MODE_NONE:
        case CHOICE_MODE_MULTIPLE_MODAL:
            super.setChoiceMode(choiceMode);
            break;

        default:
            throw new UnsupportedOperationException("Unsupported choice mode " + choiceMode);
        }
    }

    @Override
    public ListAdapter getAdapter() {
        return mAdapter;