/** * Constructs a new popup with the given history information. * * @param profile The profile used for fetching favicons. * @param context The context used for building the popup. * @param navigationController The controller which takes care of page navigations. * @param isForward Whether to request forward navigation entries. */ public NavigationPopup(Profile profile, Context context, NavigationController navigationController, boolean isForward) { super(context, null, android.R.attr.popupMenuStyle); mProfile = profile; mContext = context; mNavigationController = navigationController; mHistory = mNavigationController.getDirectedNavigationHistory( isForward, MAXIMUM_HISTORY_ITEMS); mAdapter = new NavigationAdapter(); mFaviconSize = mContext.getResources().getDimensionPixelSize(R.dimen.default_favicon_size); setModal(true); setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED); setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); setOnItemClickListener(this); setAdapter(new HeaderViewListAdapter(null, null, mAdapter)); mListItemFactory = new ListItemFactory(context); }
public void onItemClick(AdapterView<?> adapterView, View view, int rawPosition, long id) { SectionedBaseAdapter adapter; if (adapterView.getAdapter().getClass().equals(HeaderViewListAdapter.class)) { adapter = (SectionedBaseAdapter) ((HeaderViewListAdapter) adapterView.getAdapter ()).getWrappedAdapter(); } else { adapter = (SectionedBaseAdapter) adapterView.getAdapter(); } int section = adapter.getSectionForPosition(rawPosition); int position = adapter.getPositionInSectionForPosition(rawPosition); if (position == -1) { onSectionClick(adapterView, view, section, id); } else { onItemClick(adapterView, view, section, position, id); } }
public void setListAdapter(ListAdapter adapter) { headerInfo = list.new FixedViewInfo(); headerInfo.view = LayoutInflater.from(getActivity()).inflate(R.layout.layout_header_project, null); headerInfo.isSelectable = false; ArrayList<ListView.FixedViewInfo> headers = new ArrayList<>(1); ArrayList<ListView.FixedViewInfo> footers = new ArrayList<>(0); headers.add(headerInfo); HeaderViewListAdapter wrapper = new HeaderViewListAdapter(headers, footers, adapter) { @Override public boolean areAllItemsEnabled() { return false; } }; list.setAdapter(wrapper); }
private void disposeFooterView() { if (mFooterView == null || mAbsListView == null) { return; } if (canAddFooter()) { mFooterView.setVisibility(View.VISIBLE); mAbsListView.addFooterView(mFooterView); } else { if (mAbsListView.getAdapter() instanceof HeaderViewListAdapter) { Log.d(VIEW_LOG_TAG, "### 移除footer "); mFooterView.setVisibility(View.GONE); mAbsListView.removeFooterView(mFooterView); } else { Log.d(VIEW_LOG_TAG, "### 隐藏footer "); mFooterView.setVisibility(View.GONE); } } }
/** * @param loading */ public void setLoading(boolean loading) { isLoading = loading; if (isLoading && mListView.getFooterViewsCount() == 0) { mListView.addFooterView(mListViewFooter); } else { if (mListView.getAdapter() instanceof HeaderViewListAdapter) { mListView.removeFooterView(mListViewFooter); } else { mListViewFooter.setVisibility(View.GONE); } mYDown = 0; mLastY = 0; } }
final void d() { ListAdapter localListAdapter = (ListAdapter)this.f.getAdapter(); this.C = null; if ((localListAdapter instanceof HeaderViewListAdapter)) { this.w = ((HeaderViewListAdapter)localListAdapter).getHeadersCount(); localListAdapter = ((HeaderViewListAdapter)localListAdapter).getWrappedAdapter(); } this.B = localListAdapter; if ((localListAdapter instanceof SectionIndexer)) { this.C = ((SectionIndexer)localListAdapter); this.z = this.C.getSections(); return; } this.z = new String[] { " " }; }
public void setLoading(boolean loading) { isLoading = loading; if (isLoading) { if (isRefreshing()) setRefreshing(false); if (mListView.getFooterViewsCount() == 0) { mListView.addFooterView(mListViewFooter); mListView.setSelection(mListView.getAdapter().getCount() - 1); } else { mListViewFooter.setVisibility(VISIBLE); //mListView.addFooterView(mListViewFooter); } } else { if (mListView.getAdapter() instanceof HeaderViewListAdapter) { mListView.removeFooterView(mListViewFooter); } else { mListViewFooter.setVisibility(View.GONE); } mYDown = 0; mLastY = 0; } }
@Override public void onScroll(final AbsListView view, final int firstVisibleItem, final int visibleItemCount, final int totalItemCount) { ListAdapter a = getAdapter(); SectionListAdapter adapter = null; if (a instanceof HeaderViewListAdapter) adapter = (SectionListAdapter)((HeaderViewListAdapter) a).getWrappedAdapter(); else adapter = (SectionListAdapter) getAdapter(); if (adapter != null) { adapter.makeSectionInvisibleIfFirstInList(firstVisibleItem); } // More activities will be automatically loaded if: // - the user has scrolled AND // - the user has reached the bottom of the list if (hasScrolled && totalItemCount > 0 && firstVisibleItem+visibleItemCount==totalItemCount) { autoLoadProgress.setVisibility(View.VISIBLE); parentFragment.onLoadMore(ExoConstants.NUMBER_OF_ACTIVITY, totalItemCount-1, firstVisibleItem); // set back to false to avoid multiple calls to the onLoadMore(...) method hasScrolled = false; } }
@Override public void onItemClick(AdapterView<?> adapterView, View view, int rawPosition, long id) { SectionedBaseAdapter adapter; if (adapterView.getAdapter().getClass().equals(HeaderViewListAdapter.class)) { HeaderViewListAdapter wrapperAdapter = (HeaderViewListAdapter) adapterView.getAdapter(); adapter = (SectionedBaseAdapter) wrapperAdapter.getWrappedAdapter(); } else { adapter = (SectionedBaseAdapter) adapterView.getAdapter(); } int section = adapter.getSectionForPosition(rawPosition); int position = adapter.getPositionInSectionForPosition(rawPosition); if (position == -1) { onSectionClick(adapterView, view, section, id); } else { onItemClick(adapterView, view, section, position, id); } }
public void updateContacts(MainActivity activity) { if (MainActivity.getContacts() == null) MainActivity.setContacts(readSMSContacts(getActivity())); if (MainActivity.getListItems() == null || MainActivity.getListItems().size() == 0) MainActivity.setListItems(getNames(MainActivity.getContacts(), activity)); if (contactList != null && contactList.getAdapter() == null) { ContactAdapter arrayAdapter = new ContactAdapter(activity, MainActivity.getListItems(), 0); arrayAdapter.notifyDataSetChanged(); contactList.setAdapter(arrayAdapter); contactList.setSelection(0); } else if (MainActivity.getListItems().size() > 0 && contactList != null) { ((ContactAdapter) ((HeaderViewListAdapter) contactList.getAdapter()).getWrappedAdapter()).refill( MainActivity.getListItems(), 0); } if (swipe != null) swipe.setRefreshing(false); if (progressbar != null) progressbar.setVisibility(View.INVISIBLE); }
public void updateContacts(ArrayList<FacebookContact> fbcontacts) { if (fbcontacts == null) { return; } for (FacebookContact contact : fbcontacts) { contacts.add(new ContactModel(fb_img.get(contact.getName()), contact.getName(), contact.getLastMessage(), "", false).drawOnline(false)); } if (contactList != null && contactList.getAdapter() == null) { ContactAdapter arrayAdapter = new ContactAdapter(this, contacts, 1); contactList.setAdapter(arrayAdapter); contactList.setSelection(0); } else { if (contactList != null) { ((ContactAdapter) ((HeaderViewListAdapter) contactList.getAdapter()).getWrappedAdapter()).refill( contacts, 1); } } progressbar.setVisibility(View.INVISIBLE); }
public void updateContacts() { if (contacts == null) contacts = readSMSContacts(this); if (contactList != null && contactList.getAdapter() != null) { if (contacts.size() > 0 && contactList != null) { ((ContactAdapter) ((HeaderViewListAdapter) contactList.getAdapter()).getWrappedAdapter()).refill( contacts, 0); } } else { if (contactList != null) { ContactAdapter arrayAdapter = new ContactAdapter(this, contacts, 0); contactList.setAdapter(arrayAdapter); } } }
/** * 得到当前绑定的adapter对象 * * @return */ private PinnedHeaderAdapter getCurrAdapter() { // 如果该ListView有addHeaderView()或addFooterView()时,在ListView.setAdapter()时,会将原本的adapter包装成一个HeaderViewListAdapter对象 ListAdapter adapter = getAdapter(); if (adapter == null) return null; PinnedHeaderAdapter pinnedHeaderAdapter = null; if (adapter instanceof HeaderViewListAdapter) { if (((HeaderViewListAdapter) adapter).getWrappedAdapter() instanceof PinnedHeaderAdapter) pinnedHeaderAdapter = (PinnedHeaderAdapter) ((HeaderViewListAdapter) adapter).getWrappedAdapter(); } else { if (adapter instanceof PinnedHeaderAdapter) pinnedHeaderAdapter = (PinnedHeaderAdapter) adapter; } return pinnedHeaderAdapter; }
@Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (firstVisibleItem < this.topVisibleItem - DISTANCE_TO_HIDE_ACTIONBAR) { setActionbarVisibility(true); this.topVisibleItem = firstVisibleItem; } else if (firstVisibleItem > this.topVisibleItem + DISTANCE_TO_HIDE_ACTIONBAR) { setActionbarVisibility(false); this.topVisibleItem = firstVisibleItem; } ListAdapter adapter = view.getAdapter(); if (adapter instanceof HeaderViewListAdapter) { HeaderViewListAdapter headerViewListAdapter = (HeaderViewListAdapter) adapter; if (headerViewListAdapter.getWrappedAdapter() instanceof FileCardAdapter) { int startPrefetch = firstVisibleItem + visibleItemCount-headerViewListAdapter.getHeadersCount(); ((FileCardAdapter) headerViewListAdapter.getWrappedAdapter()).prefetchImages(startPrefetch, visibleItemCount); } } }
/** * Add a fixed view to appear at the top of the list. 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 ListView can wrap the supplied cursor with one that will also account for header and footer 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) { if (mAdapter != null && !(mAdapter instanceof HeaderViewListAdapter)) { throw new IllegalStateException("Cannot add header view to list -- setAdapter has already been called."); } FixedViewInfo info = new FixedViewInfo(); info.view = v; info.data = data; info.isSelectable = isSelectable; mHeaderViewInfos.add(info); // in the case of re-adding a header view, or adding one later on, // we need to notify the observer if (mAdapter != null && mObserver != null) { mObserver.onChanged(); } }
/** * Removes a previously-added header view. * * @param v * The view to remove * @return true if the view was removed, false if the view was not a header * view */ public boolean removeHeaderView(View v) { if (mHeaderViewInfos.size() > 0) { boolean result = false; if (mAdapter != null && ((HeaderViewListAdapter) mAdapter).removeHeader(v)) { if (mObserver != null) { mObserver.onChanged(); } result = true; } removeFixedViewInfo(v, mHeaderViewInfos); return result; } return false; }
/** * Removes a previously-added footer view. * * @param v * The view to remove * @return true if the view was removed, false if the view was not a footer view */ public boolean removeFooterView(View v) { if (mFooterViewInfos.size() > 0) { boolean result = false; if (mAdapter != null && ((HeaderViewListAdapter) mAdapter).removeFooter(v)) { if (mObserver != null) { mObserver.onChanged(); } result = true; } removeFixedViewInfo(v, mFooterViewInfos); return result; } return false; }
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Adapter adapter = parent.getAdapter(); if (adapter instanceof HeaderViewListAdapter) { adapter = ((HeaderViewListAdapter) adapter).getWrappedAdapter(); } RowType rowType; if (adapter instanceof CursorRowAdapter) { CursorRowAdapter cursorAdapter = (CursorRowAdapter) adapter; rowType = cursorAdapter.getItem(position); } else { rowType = (RowType) adapter.getItem(position); } onRowClick(rowType, view, position); }
@SuppressWarnings("unchecked") @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Adapter adapter = parent.getAdapter(); message = (DirectMessage)adapter.getItem(position); if (message == null || (message instanceof LocalDirectMessage && ((LocalDirectMessage)message).isDivider())) { return; } if (adapter instanceof HeaderViewListAdapter) { adapter = ((HeaderViewListAdapter)adapter).getWrappedAdapter(); } CacheAdapter<DirectMessage> cacheAdapter = (CacheAdapter<DirectMessage>)adapter; Dialog dialog = onCreateDialog(cacheAdapter, position); if (dialog != null) { dialog.show(); } }
@SuppressWarnings("unchecked") @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Adapter adapter = parent.getAdapter(); comment = (Comment)adapter.getItem(position); if (comment == null || (comment instanceof LocalComment && ((LocalComment)comment).isDivider())) { return; } if (adapter instanceof HeaderViewListAdapter) { adapter = ((HeaderViewListAdapter)adapter).getWrappedAdapter(); } CacheAdapter<Comment> cacheAdapter = (CacheAdapter<Comment>)adapter; Dialog dialog = onCreateDialog(cacheAdapter, position); if (dialog != null) { dialog.show(); } }
public static BaseAdapter getAdapter(Adapter adapter) { if (adapter == null) { return null; } BaseAdapter baseAdapter = null; if (adapter instanceof BaseAdapter) { baseAdapter = (BaseAdapter)adapter; } else if (adapter instanceof HeaderViewListAdapter) { HeaderViewListAdapter headerViewAdapter = (HeaderViewListAdapter)adapter; if (headerViewAdapter.getWrappedAdapter() instanceof BaseAdapter) { baseAdapter = (BaseAdapter)headerViewAdapter.getWrappedAdapter(); } } return baseAdapter; }
public static CacheAdapter<?> getCacheAdapter(Adapter adapter) { if (adapter == null) { return null; } CacheAdapter<?> cacheAdapter = null; if (adapter instanceof CacheAdapter<?>) { cacheAdapter = (CacheAdapter<?>)adapter; } else if (adapter instanceof HeaderViewListAdapter) { HeaderViewListAdapter headerViewAdapter = (HeaderViewListAdapter)adapter; if (headerViewAdapter.getWrappedAdapter() instanceof CacheAdapter<?>) { cacheAdapter = (CacheAdapter<?>)headerViewAdapter.getWrappedAdapter(); } } return cacheAdapter; }
public static BaseListAdapter<?> getBaseListAdapter(Adapter adapter) { if (adapter == null) { return null; } BaseListAdapter<?> baseListAdapter = null; if (adapter instanceof BaseListAdapter<?>) { baseListAdapter = (BaseListAdapter<?>)adapter; } else if (adapter instanceof HeaderViewListAdapter) { HeaderViewListAdapter headerViewAdapter = (HeaderViewListAdapter)adapter; if (headerViewAdapter.getWrappedAdapter() instanceof BaseListAdapter<?>) { baseListAdapter = (BaseListAdapter<?>)headerViewAdapter.getWrappedAdapter(); } } return baseListAdapter; }
/** * Constructs a new popup with the given history information. * * @param context The context used for building the popup. * @param navigationClient The owner of the history being displayed. * @param isForward Whether to request forward navigation entries. */ public NavigationPopup( Context context, NavigationClient navigationClient, boolean isForward) { super(context, null, android.R.attr.popupMenuStyle); mContext = context; mNavigationClient = navigationClient; mHistory = mNavigationClient.getDirectedNavigationHistory( isForward, MAXIMUM_HISTORY_ITEMS); mAdapter = new NavigationAdapter(); float density = mContext.getResources().getDisplayMetrics().density; mFaviconSize = (int) (density * FAVICON_SIZE_DP); setModal(true); setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED); setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); setOnItemClickListener(this); setAdapter(new HeaderViewListAdapter(null, null, mAdapter)); mListItemFactory = new ListItemFactory(context); }
@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); }
@Override public void onLoaderReset(Loader<Cursor> loader) { //isLoaderWork = false; if (getView() != null) { if (IS_CHECK_STATUS_LOG_ENABLED) Log.d("empty_view", loader.isAbandoned() + " " + loader.isReset() + " " + loader.isStarted()); Adapter adapter = getListView().getAdapter(); if (adapter != null) { if (adapter instanceof HeaderViewListAdapter) { adapter = ((HeaderViewListAdapter) adapter).getWrappedAdapter(); } if (adapter instanceof CursorAdapter) { ((CursorAdapter) adapter).swapCursor(null); } } } checkStatus("onLoaderReset"); }
public ATableViewAdapter getInternalAdapter() { // fixes bugs for tables which includes headers or footers. ATableViewAdapter adapter = null; if (getAdapter() instanceof HeaderViewListAdapter) { HeaderViewListAdapter headerAdapter = (HeaderViewListAdapter) getAdapter(); adapter = (ATableViewAdapter) headerAdapter.getWrappedAdapter(); } else { adapter = (ATableViewAdapter) getAdapter(); } return adapter; }
public ListAdapter getAdapter() { final ListAdapter adapter = getListView().getAdapter(); if (adapter instanceof HeaderViewListAdapter) { return ((HeaderViewListAdapter) adapter).getWrappedAdapter(); } return adapter; }
private void getSections() { Adapter adapter = mList.getAdapter(); if (adapter instanceof HeaderViewListAdapter) { mListOffset = ((HeaderViewListAdapter)adapter).getHeadersCount(); adapter = ((HeaderViewListAdapter)adapter).getWrappedAdapter(); } if (adapter instanceof SectionIndexer) { mListAdapter = (BaseAdapter) adapter; mSections = ((SectionIndexer) mListAdapter).getSections(); } }
protected ExAdapter getAdapter() { ListAdapter adapter = mListView.getAdapter(); if (adapter instanceof HeaderViewListAdapter) return (ExAdapter) ((HeaderViewListAdapter) adapter).getWrappedAdapter(); else return (ExAdapter) adapter; }
@Override protected void onPostExecute(Void param) { HeaderViewListAdapter t = (HeaderViewListAdapter)mListView.getAdapter(); MyListAdapter adapter = (MyListAdapter)t.getWrappedAdapter(); adapter.addLoadedData(mData); mListView.notifyLoaded(); }