Search in sources :

Example 1 with ListAdapter

use of android.widget.ListAdapter in project cw-omnibus by commonsguy.

the class RowController method measureContentWidth.

// based on http://stackoverflow.com/a/26814964/115145
private int measureContentWidth(Context ctxt, ListAdapter listAdapter) {
    ViewGroup mMeasureParent = null;
    int maxWidth = 0;
    View itemView = null;
    int itemType = 0;
    final ListAdapter adapter = listAdapter;
    final int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    final int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    final int count = adapter.getCount();
    for (int i = 0; i < count; i++) {
        final int positionType = adapter.getItemViewType(i);
        if (positionType != itemType) {
            itemType = positionType;
            itemView = null;
        }
        if (mMeasureParent == null) {
            mMeasureParent = new FrameLayout(ctxt);
        }
        itemView = adapter.getView(i, itemView, mMeasureParent);
        itemView.measure(widthMeasureSpec, heightMeasureSpec);
        final int itemWidth = itemView.getMeasuredWidth();
        if (itemWidth > maxWidth) {
            maxWidth = itemWidth;
        }
    }
    return maxWidth;
}
Also used : ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListAdapter(android.widget.ListAdapter)

Example 2 with ListAdapter

use of android.widget.ListAdapter in project AndroidTraining by mixi-inc.

the class IcsListPopupWindow 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();
    }
    // Include the padding of the list
    int returnedHeight = mDropDownList.getListPaddingTop() + mDropDownList.getListPaddingBottom();
    final int dividerHeight = ((mDropDownList.getDividerHeight() > 0) && mDropDownList.getDivider() != null) ? mDropDownList.getDividerHeight() : 0;
    // The previous height value that was less than maxHeight and contained
    // no partial children
    int prevHeightWithoutPartialChild = 0;
    int i;
    View child;
    // mItemCount - 1 since endPosition parameter is inclusive
    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) {
            // Count the divider for all but one child
            returnedHeight += dividerHeight;
        }
        returnedHeight += child.getMeasuredHeight();
        if (returnedHeight >= maxHeight) {
            // then the i'th position did not fit completely.
            return // Disallowing is enabled (> -1)
            (disallowPartialChildPosition >= 0) && // We've past the min pos
            (i > disallowPartialChildPosition) && // We have a prev height
            (prevHeightWithoutPartialChild > 0) && // i'th child did not fit completely
            (returnedHeight != maxHeight) ? prevHeightWithoutPartialChild : maxHeight;
        }
        if ((disallowPartialChildPosition >= 0) && (i >= disallowPartialChildPosition)) {
            prevHeightWithoutPartialChild = returnedHeight;
        }
    }
    // completely fit, so return the returnedHeight
    return returnedHeight;
}
Also used : AbsListView(android.widget.AbsListView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ListAdapter(android.widget.ListAdapter)

Example 3 with ListAdapter

use of android.widget.ListAdapter in project Android-ObservableScrollView by ksoichiro.

the class ObservableGridView method removeFooterView.

public boolean removeFooterView(View v) {
    if (mFooterViewInfos.size() > 0) {
        boolean result = false;
        ListAdapter adapter = getAdapter();
        if (adapter != null && ((HeaderViewGridAdapter) adapter).removeFooter(v)) {
            result = true;
        }
        removeFixedViewInfo(v, mFooterViewInfos);
        return result;
    }
    return false;
}
Also used : ListAdapter(android.widget.ListAdapter) WrapperListAdapter(android.widget.WrapperListAdapter)

Example 4 with ListAdapter

use of android.widget.ListAdapter in project SeriesGuide by UweTrottmann.

the class HeaderGridView method addHeaderView.

/**
     * Add a fixed view to appear at the top of the grid. If addHeaderView is called more than once,
     * the views will appear in the order they were added. Views added using this call can take
     * focus if they want. <p> NOTE: Call this before calling setAdapter. This is so HeaderGridView
     * can wrap the supplied cursor with one that will also account for header views.
     *
     * @param v The view to add.
     * @param data Data to associate with this view
     * @param isSelectable whether the item is selectable
     */
public void addHeaderView(View v, Object data, boolean isSelectable) {
    ListAdapter adapter = getAdapter();
    if (adapter != null && !(adapter instanceof HeaderViewGridAdapter)) {
        throw new IllegalStateException("Cannot add header view to grid -- setAdapter has already been called.");
    }
    FixedViewInfo info = new FixedViewInfo();
    FrameLayout fl = new FullWidthFixedViewLayout(getContext());
    fl.addView(v);
    info.view = v;
    info.viewContainer = fl;
    info.data = data;
    info.isSelectable = isSelectable;
    mHeaderViewInfos.add(info);
    // we need to notify the observer
    if (adapter != null) {
        ((HeaderViewGridAdapter) adapter).notifyDataSetChanged();
    }
}
Also used : FrameLayout(android.widget.FrameLayout) ListAdapter(android.widget.ListAdapter) WrapperListAdapter(android.widget.WrapperListAdapter)

Example 5 with ListAdapter

use of android.widget.ListAdapter in project SeriesGuide by UweTrottmann.

the class HeaderGridView method onMeasure.

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    ListAdapter adapter = getAdapter();
    if (adapter != null && adapter instanceof HeaderViewGridAdapter) {
        ((HeaderViewGridAdapter) adapter).setNumColumns(getNumColumns());
    }
}
Also used : ListAdapter(android.widget.ListAdapter) WrapperListAdapter(android.widget.WrapperListAdapter)

Aggregations

ListAdapter (android.widget.ListAdapter)441 View (android.view.View)151 ListView (android.widget.ListView)144 ViewGroup (android.view.ViewGroup)75 WrapperListAdapter (android.widget.WrapperListAdapter)72 TextView (android.widget.TextView)70 AdapterView (android.widget.AdapterView)68 AbsListView (android.widget.AbsListView)66 HeaderViewListAdapter (android.widget.HeaderViewListAdapter)47 Paint (android.graphics.Paint)32 Point (android.graphics.Point)30 ArrayAdapter (android.widget.ArrayAdapter)30 ImageView (android.widget.ImageView)25 ArrayList (java.util.ArrayList)24 SuppressLint (android.annotation.SuppressLint)23 FrameLayout (android.widget.FrameLayout)20 DialogInterface (android.content.DialogInterface)18 GridView (android.widget.GridView)17 BaseAdapter (android.widget.BaseAdapter)16 SimpleCursorAdapter (android.widget.SimpleCursorAdapter)16