Search in sources :

Example 56 with ListAdapter

use of android.widget.ListAdapter in project HoloEverywhere by Prototik.

the class GridFragment method ensureGrid.

private void ensureGrid() {
    if (mGrid != null) {
        return;
    }
    View root = getView();
    if (root == null) {
        throw new IllegalStateException("Content view not yet created");
    }
    if (root instanceof GridView) {
        mGrid = (GridView) root;
    } else {
        mStandardEmptyView = (TextView) root.findViewById(R.id.internalEmpty);
        if (mStandardEmptyView == null) {
            mEmptyView = root.findViewById(android.R.id.empty);
        } else {
            mStandardEmptyView.setVisibility(View.GONE);
        }
        mProgressContainer = root.findViewById(R.id.progressContainer);
        mGridContainer = root.findViewById(R.id.listContainer);
        View rawGridVIew = root.findViewById(android.R.id.list);
        if (!(rawGridVIew instanceof GridView)) {
            if (rawGridVIew == null) {
                throw new RuntimeException("Your content must have a GridVIew whose id attribute is " + "'android.R.id.list'");
            }
            throw new RuntimeException("Content has view with id attribute 'android.R.id.list' " + "that is not a GridVIew class");
        }
        mGrid = (GridView) rawGridVIew;
        if (mEmptyView != null) {
            mGrid.setEmptyView(mEmptyView);
        } else if (mEmptyText != null) {
            mStandardEmptyView.setText(mEmptyText);
            mGrid.setEmptyView(mStandardEmptyView);
        }
    }
    mGridShown = true;
    mGrid.setOnItemClickListener(mOnClickListener);
    if (mAdapter != null) {
        ListAdapter adapter = mAdapter;
        mAdapter = null;
        setGridAdapter(adapter);
    } else {
        if (mProgressContainer != null) {
            setGridShown(false, false);
        }
    }
    mHandler.post(mRequestFocus);
}
Also used : GridView(org.holoeverywhere.widget.GridView) TextView(android.widget.TextView) View(android.view.View) GridView(org.holoeverywhere.widget.GridView) AdapterView(android.widget.AdapterView) ListAdapter(android.widget.ListAdapter)

Example 57 with ListAdapter

use of android.widget.ListAdapter in project HoloEverywhere by Prototik.

the class ListFragment method ensureList.

private void ensureList() {
    if (mList != null) {
        return;
    }
    View root = getView();
    if (root == null) {
        throw new IllegalStateException("Content view not yet created");
    }
    if (root instanceof ListView) {
        mList = (ListView) root;
    } else {
        mStandardEmptyView = (TextView) root.findViewById(R.id.internalEmpty);
        if (mStandardEmptyView == null) {
            mEmptyView = root.findViewById(android.R.id.empty);
        } else {
            mStandardEmptyView.setVisibility(View.GONE);
        }
        mProgressContainer = root.findViewById(R.id.progressContainer);
        mListContainer = root.findViewById(R.id.listContainer);
        View rawListView = root.findViewById(android.R.id.list);
        if (!(rawListView instanceof ListView)) {
            if (rawListView == null) {
                throw new RuntimeException("Your content must have a ListView whose id attribute is " + "'android.R.id.list'");
            }
            throw new RuntimeException("Content has view with id attribute 'android.R.id.list' " + "that is not a ListView class");
        }
        mList = (ListView) rawListView;
        if (mEmptyView != null) {
            mList.setEmptyView(mEmptyView);
        } else if (mEmptyText != null) {
            mStandardEmptyView.setText(mEmptyText);
            mList.setEmptyView(mStandardEmptyView);
        }
    }
    mListShown = true;
    mList.setOnItemClickListener(mOnClickListener);
    if (mAdapter != null) {
        ListAdapter adapter = mAdapter;
        mAdapter = null;
        setListAdapter(adapter);
    } else {
        if (mProgressContainer != null) {
            setListShown(false, false);
        }
    }
    mHandler.post(mRequestFocus);
}
Also used : ListView(org.holoeverywhere.widget.ListView) ListView(org.holoeverywhere.widget.ListView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListAdapter(android.widget.ListAdapter)

Example 58 with ListAdapter

use of android.widget.ListAdapter in project HoloEverywhere by Prototik.

the class ListPopupWindow method performItemClick.

public boolean performItemClick(int position) {
    if (isShowing()) {
        if (mItemClickListener != null) {
            final DropDownListView list = mDropDownList;
            final View child = list.getChildAt(position - list.getFirstVisiblePosition());
            final ListAdapter adapter = list.getAdapter();
            mItemClickListener.onItemClick(list, child, position, adapter.getItemId(position));
        }
        return true;
    }
    return false;
}
Also used : AbsListView(android.widget.AbsListView) View(android.view.View) AdapterView(android.widget.AdapterView) ListAdapter(android.widget.ListAdapter)

Example 59 with ListAdapter

use of android.widget.ListAdapter in project HoloEverywhere by Prototik.

the class ListPopupWindow method measureHeightOfChildren.

private int measureHeightOfChildren(int widthMeasureSpec, int startPosition, int endPosition, final int maxHeight, int disallowPartialChildPosition) {
    final ListAdapter adapter = mAdapter;
    if (adapter == null) {
        return mDropDownList.getListPaddingTop() + mDropDownList.getListPaddingBottom();
    }
    int returnedHeight = mDropDownList.getListPaddingTop() + mDropDownList.getListPaddingBottom();
    final int dividerHeight = mDropDownList.getDividerHeight() > 0 && mDropDownList.getDivider() != null ? mDropDownList.getDividerHeight() : 0;
    int prevHeightWithoutPartialChild = 0;
    int i;
    View child;
    endPosition = endPosition == -1 ? adapter.getCount() - 1 : endPosition;
    for (i = startPosition; i <= endPosition; ++i) {
        child = mAdapter.getView(i, null, mDropDownList);
        if (mDropDownList.getCacheColorHint() != 0) {
            child.setDrawingCacheBackgroundColor(mDropDownList.getCacheColorHint());
        }
        measureScrapChild(child, i, widthMeasureSpec);
        if (i > 0) {
            returnedHeight += dividerHeight;
        }
        returnedHeight += child.getMeasuredHeight();
        if (returnedHeight >= maxHeight) {
            return disallowPartialChildPosition >= 0 && i > disallowPartialChildPosition && prevHeightWithoutPartialChild > 0 && returnedHeight != maxHeight ? prevHeightWithoutPartialChild : maxHeight;
        }
        if (disallowPartialChildPosition >= 0 && i >= disallowPartialChildPosition) {
            prevHeightWithoutPartialChild = returnedHeight;
        }
    }
    return returnedHeight;
}
Also used : AbsListView(android.widget.AbsListView) View(android.view.View) AdapterView(android.widget.AdapterView) ListAdapter(android.widget.ListAdapter) SuppressLint(android.annotation.SuppressLint)

Example 60 with ListAdapter

use of android.widget.ListAdapter in project HoloEverywhere by Prototik.

the class ListPopupWindow method onKeyDown.

public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (isShowing()) {
        if (keyCode != KeyEvent.KEYCODE_SPACE && (mDropDownList.getSelectedItemPosition() >= 0 || keyCode != KeyEvent.KEYCODE_ENTER && keyCode != KeyEvent.KEYCODE_DPAD_CENTER)) {
            int curIndex = mDropDownList.getSelectedItemPosition();
            boolean consumed;
            final boolean below = !mPopup.isAboveAnchor();
            final ListAdapter adapter = mAdapter;
            int firstItem = Integer.MAX_VALUE;
            int lastItem = Integer.MIN_VALUE;
            if (adapter != null) {
                adapter.areAllItemsEnabled();
                firstItem = 0;
                lastItem = adapter.getCount() - 1;
            /*
                     * TODO firstItem = allEnabled ? 0 : mDropDownList
                     * .lookForSelectablePosition(0, true); lastItem =
                     * allEnabled ? adapter.getCount() - 1 :
                     * mDropDownList.lookForSelectablePosition(
                     * adapter.getCount() - 1, false);
                     */
            }
            if (below && keyCode == KeyEvent.KEYCODE_DPAD_UP && curIndex <= firstItem || !below && keyCode == KeyEvent.KEYCODE_DPAD_DOWN && curIndex >= lastItem) {
                clearListSelection();
                mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
                show();
                return true;
            } else {
                mDropDownList.mListSelectionHidden = false;
            }
            consumed = mDropDownList.onKeyDown(keyCode, event);
            if (ListPopupWindow.DEBUG) {
                Log.v(ListPopupWindow.TAG, "Key down: code=" + keyCode + " list consumed=" + consumed);
            }
            if (consumed) {
                mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
                mDropDownList.requestFocusFromTouch();
                show();
                switch(keyCode) {
                    case KeyEvent.KEYCODE_ENTER:
                    case KeyEvent.KEYCODE_DPAD_CENTER:
                    case KeyEvent.KEYCODE_DPAD_DOWN:
                    case KeyEvent.KEYCODE_DPAD_UP:
                        return true;
                }
            } else {
                if (below && keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
                    if (curIndex == lastItem) {
                        return true;
                    }
                } else if (!below && keyCode == KeyEvent.KEYCODE_DPAD_UP && curIndex == firstItem) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : SuppressLint(android.annotation.SuppressLint) ListAdapter(android.widget.ListAdapter)

Aggregations

ListAdapter (android.widget.ListAdapter)298 ListView (android.widget.ListView)105 View (android.view.View)96 AdapterView (android.widget.AdapterView)55 AbsListView (android.widget.AbsListView)48 WrapperListAdapter (android.widget.WrapperListAdapter)47 HeaderViewListAdapter (android.widget.HeaderViewListAdapter)44 TextView (android.widget.TextView)42 ViewGroup (android.view.ViewGroup)37 Paint (android.graphics.Paint)22 ArrayAdapter (android.widget.ArrayAdapter)21 Point (android.graphics.Point)19 SuppressLint (android.annotation.SuppressLint)16 SimpleCursorAdapter (android.widget.SimpleCursorAdapter)16 Cursor (android.database.Cursor)12 SectionIndexer (android.widget.SectionIndexer)11 DialogInterface (android.content.DialogInterface)10 Bundle (android.os.Bundle)10 FrameLayout (android.widget.FrameLayout)10 GridView (android.widget.GridView)10