/** * Remove all headers * * @return true if headers were removed, false otherwise */ public boolean clearHeaders(boolean dispatchDetach) { boolean removed = false; if (!headers.isEmpty()) { FixedViewInfo[] infos = headers.toArray(new FixedViewInfo[headers .size()]); for (FixedViewInfo info : infos) { removed = super.removeHeader(info.view) || removed; if (dispatchDetach && ViewUtils.isAttachedToWindow(info.view)) { ViewUtils.callDispatchDetachedFromWindow(info.view); } } } if (removed) wrapped.notifyDataSetChanged(); return removed; }
/** * Remove all footers * * @return true if headers were removed, false otherwise */ public boolean clearFooters(boolean dispatchDetach) { boolean removed = false; if (!footers.isEmpty()) { FixedViewInfo[] infos = footers.toArray(new FixedViewInfo[footers .size()]); for (FixedViewInfo info : infos) { removed = super.removeFooter(info.view) || removed; if (dispatchDetach && ViewUtils.isAttachedToWindow(info.view)) { ViewUtils.callDispatchDetachedFromWindow(info.view); } } } if (removed) wrapped.notifyDataSetChanged(); return removed; }
public void addHeaderView(View v, Object data, boolean isSelectable) { FixedViewInfo info = new ListView(getContext()).new FixedViewInfo(); info.view = v; info.data = data; info.isSelectable = isSelectable; mHeaderViewInfos.add(info); setupView(v); int topPadding = this.getPaddingTop(); if(initialTopPadding == 0){ initialTopPadding = topPadding; } this.setPadding(this.getPaddingLeft(), topPadding+v.getMeasuredHeight(), this.getPaddingRight(), this.getPaddingBottom()); // in the case of re-adding a header view, or adding one later on, // we need to notify the observer this.notifiyChanged(); }
public void addHeaderView(View v, Object data, boolean isSelectable) { FixedViewInfo info = new ListView(getContext()).new FixedViewInfo(); info.view = v; info.data = data; info.isSelectable = isSelectable; mHeaderViewInfos.add(info); setupView(v); int topPadding = this.getPaddingTop(); if (initialTopPadding == 0) { initialTopPadding = topPadding; } this.setPadding(this.getPaddingLeft(), topPadding + v.getMeasuredHeight(), this.getPaddingRight(), this.getPaddingBottom()); // in the case of re-adding a header view, or adding one later on, // we need to notify the observer this.notifiyChanged(); }
@Override public Builder setSingleChoiceItems(Cursor cursor, int checkedItem, String labelColumn, OnClickListener listener) { ListAdapter sourceAdapter = new SimpleCursorAdapter(activity, android.R.layout.select_dialog_singlechoice, cursor, new String[] { labelColumn }, new int[] { android.R.id.text1 }); View view = activity.getLayoutInflater().inflate( android.R.layout.select_dialog_singlechoice, null, false); ((TextView) view.findViewById(android.R.id.text1)) .setText(R.string.nothing); FixedViewInfo info = new ExtendedListView(activity).info; info.view = view; info.data = null; info.isSelectable = true; ArrayList<FixedViewInfo> header = new ArrayList<FixedViewInfo>(); ArrayList<FixedViewInfo> footer = new ArrayList<FixedViewInfo>(); footer.add(info); adapter = new HeaderViewListAdapter(header, footer, sourceAdapter); if (checkedItem == -1) checkedItem = adapter.getWrappedAdapter().getCount(); return setSingleChoiceItems(adapter, checkedItem, this); }
private HeaderFooterListAdapter(ArrayList<FixedViewInfo> headerViewInfos, ArrayList<FixedViewInfo> footerViewInfos, ListView view, E adapter) { super(headerViewInfos, footerViewInfos, adapter); headers = headerViewInfos; footers = footerViewInfos; list = view; wrapped = adapter; }
/** * Add header * * @param view * @param data * @param isSelectable * @return this adapter */ public HeaderFooterListAdapter<E> addHeader(View view, Object data, boolean isSelectable) { FixedViewInfo info = list.new FixedViewInfo(); info.view = view; info.data = data; info.isSelectable = isSelectable; headers.add(info); wrapped.notifyDataSetChanged(); return this; }
/** * Add footer * * @param view * @param data * @param isSelectable * @return this adapter */ public HeaderFooterListAdapter<E> addFooter(View view, Object data, boolean isSelectable) { FixedViewInfo info = list.new FixedViewInfo(); info.view = view; info.data = data; info.isSelectable = isSelectable; footers.add(info); wrapped.notifyDataSetChanged(); return this; }
private HeaderFooterListAdapter(final ArrayList<FixedViewInfo> headerViewInfos, final ArrayList<FixedViewInfo> footerViewInfos, final ListView view, final E adapter) { super(headerViewInfos, footerViewInfos, adapter); headers = headerViewInfos; footers = footerViewInfos; list = view; wrapped = adapter; }
/** * Add header * * @param view * @param data * @param isSelectable * @return this adapter */ public HeaderFooterListAdapter<E> addHeader(final View view, final Object data, final boolean isSelectable) { final FixedViewInfo info = list.new FixedViewInfo(); info.view = view; info.data = data; info.isSelectable = isSelectable; headers.add(info); wrapped.notifyDataSetChanged(); return this; }
/** * Add footer * * @param view * @param data * @param isSelectable * @return this adapter */ public HeaderFooterListAdapter<E> addFooter(final View view, final Object data, final boolean isSelectable) { final FixedViewInfo info = list.new FixedViewInfo(); info.view = view; info.data = data; info.isSelectable = isSelectable; footers.add(info); wrapped.notifyDataSetChanged(); return this; }
/** * Remove all headers * * @return true if headers were removed, false otherwise */ public boolean clearHeaders() { boolean removed = false; if (!headers.isEmpty()) { final FixedViewInfo[] infos = headers.toArray(new FixedViewInfo[headers .size()]); for (final FixedViewInfo info : infos) { removed = super.removeHeader(info.view) || removed; } } if (removed) { wrapped.notifyDataSetChanged(); } return removed; }
/** * Remove all footers * * @return true if headers were removed, false otherwise */ public boolean clearFooters() { boolean removed = false; if (!footers.isEmpty()) { final FixedViewInfo[] infos = footers.toArray(new FixedViewInfo[footers .size()]); for (final FixedViewInfo info : infos) { removed = super.removeFooter(info.view) || removed; } } if (removed) { wrapped.notifyDataSetChanged(); } return removed; }
/** * Remove all headers * * @return true if headers were removed, false otherwise */ public boolean clearHeaders() { boolean removed = false; if (!headers.isEmpty()) { FixedViewInfo[] infos = headers.toArray(new FixedViewInfo[headers .size()]); for (FixedViewInfo info : infos) removed = super.removeHeader(info.view) || removed; } if (removed) wrapped.notifyDataSetChanged(); return removed; }
/** * Remove all footers * * @return true if headers were removed, false otherwise */ public boolean clearFooters() { boolean removed = false; if (!footers.isEmpty()) { FixedViewInfo[] infos = footers.toArray(new FixedViewInfo[footers .size()]); for (FixedViewInfo info : infos) removed = super.removeFooter(info.view) || removed; } if (removed) wrapped.notifyDataSetChanged(); return removed; }
private void drawHeaders(Canvas canvas) { int startPos = -mScrollOfsset; // translate view all way up first... int saveCount = canvas.save(); for(FixedViewInfo header: mHeaderViewInfos){ View view = header.view; canvas.translate(0, startPos); startPos = view.getMeasuredHeight(); view.draw(canvas); } canvas.restoreToCount(saveCount); }
private int getTotalHeaderHeight(){ int totalHeaderHeight = 0; for(FixedViewInfo h: mHeaderViewInfos){ totalHeaderHeight += h.view.getMeasuredHeight(); } return totalHeaderHeight; }
private boolean removeFixedViewInfo(View v, ArrayList<FixedViewInfo> where) { int len = where.size(); int count = 0; for (int i = 0; i < len; ++i) { FixedViewInfo info = where.get(i); if (info.view == v) { this.setPadding(this.getPaddingLeft(), getPaddingTop()-v.getMeasuredHeight(), this.getPaddingRight(), this.getPaddingBottom()); where.remove(i); count++; break; } } return count > 0; }
private HeaderFooterListAdapter(ArrayList<FixedViewInfo> headerViewInfos, ArrayList<FixedViewInfo> footerViewInfos, Context context, E adapter) { super(headerViewInfos, footerViewInfos, adapter); headers = headerViewInfos; footers = footerViewInfos; list = new ListView(context); wrapped = adapter; }
private void drawHeaders(Canvas canvas) { int startPos = -mScrollOfsset; // translate view all way up first... int saveCount = canvas.save(); for (FixedViewInfo header : mHeaderViewInfos) { View view = header.view; canvas.translate(0, startPos); startPos = view.getMeasuredHeight(); view.draw(canvas); } canvas.restoreToCount(saveCount); }
private int getTotalHeaderHeight() { int totalHeaderHeight = 0; for (FixedViewInfo h : mHeaderViewInfos) { totalHeaderHeight += h.view.getMeasuredHeight(); } return totalHeaderHeight; }
private boolean removeFixedViewInfo(View v, ArrayList<FixedViewInfo> where) { int len = where.size(); int count = 0; for (int i = 0; i < len; ++i) { FixedViewInfo info = where.get(i); if (info.view == v) { this.setPadding(this.getPaddingLeft(), getPaddingTop() - v.getMeasuredHeight(), this.getPaddingRight(), this.getPaddingBottom()); where.remove(i); count++; break; } } return count > 0; }