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

Commit 1f09c831 authored by Adam Powell's avatar Adam Powell
Browse files

Spinner now allows disabled adapter items

parent 1aec20b6
Loading
Loading
Loading
Loading
+21 −9
Original line number Original line Diff line number Diff line
@@ -295,14 +295,18 @@ public class Spinner extends AbsSpinner implements OnClickListener {
     */
     */
    private static class DropDownAdapter implements ListAdapter, SpinnerAdapter {
    private static class DropDownAdapter implements ListAdapter, SpinnerAdapter {
        private SpinnerAdapter mAdapter;
        private SpinnerAdapter mAdapter;
        private ListAdapter mListAdapter;


        /**
        /**
         * <p>Creates a new ListAddapter wrapper for the specified adapter.</p>
         * <p>Creates a new ListAdapter wrapper for the specified adapter.</p>
         *
         *
         * @param adapter the Adapter to transform into a ListAdapter
         * @param adapter the Adapter to transform into a ListAdapter
         */
         */
        public DropDownAdapter(SpinnerAdapter adapter) {
        public DropDownAdapter(SpinnerAdapter adapter) {
            this.mAdapter = adapter;
            this.mAdapter = adapter;
            if (adapter instanceof ListAdapter) {
                this.mListAdapter = (ListAdapter) adapter;
            }
        }
        }


        public int getCount() {
        public int getCount() {
@@ -343,22 +347,30 @@ public class Spinner extends AbsSpinner implements OnClickListener {
        }
        }


        /**
        /**
         * <p>Always returns false.</p>
         * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call.
         *
         * Otherwise, return true. 
         * @return false
         */
         */
        public boolean areAllItemsEnabled() {
        public boolean areAllItemsEnabled() {
            final ListAdapter adapter = mListAdapter;
            if (adapter != null) {
                return adapter.areAllItemsEnabled();
            } else {
                return true;
                return true;
            }
            }
        }


        /**
        /**
         * <p>Always returns false.</p>
         * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call.
         *
         * Otherwise, return true.
         * @return false
         */
         */
        public boolean isEnabled(int position) {
        public boolean isEnabled(int position) {
            final ListAdapter adapter = mListAdapter;
            if (adapter != null) {
                return adapter.isEnabled(position);
            } else {
                return true;
                return true;
            }
            }
        }


        public int getItemViewType(int position) {
        public int getItemViewType(int position) {
            return 0;
            return 0;