Here are the examples of the java api class android.widget.Adapter taken from open source projects.
1. AdapterViewAnimator#beforeDataSetChanged()
Project: adapterviewanimator
File: AdapterViewAnimator.java
File: AdapterViewAnimator.java
private void beforeDataSetChanged() { Adapter adapter = adapterView.getAdapter(); final int firstVisiblePosition = adapterView.getFirstVisiblePosition(); for (int i = 0, childCount = adapterView.getChildCount(); i < childCount; i++) { final int position = firstVisiblePosition + i; final long id = adapter.getItemId(position); final View child = adapterView.getChildAt(i); Rect r = new Rect(child.getLeft(), child.getTop(), child.getRight(), child.getBottom()); child.setHasTransientState(true); viewBounds.put(id, r); idToViewMap.put(id, child); } }
2. AppPickerActivity#onListItemClick()
Project: zxingfragmentlib
File: AppPickerActivity.java
File: AppPickerActivity.java
@Override protected void onListItemClick(ListView l, View view, int position, long id) { Adapter adapter = getListAdapter(); if (position >= 0 && position < adapter.getCount()) { String packageName = ((AppInfo) adapter.getItem(position)).getPackageName(); Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.putExtra(Browser.BookmarkColumns.URL, "market://details?id=" + packageName); setResult(RESULT_OK, intent); } else { setResult(RESULT_CANCELED); } finish(); }
3. AppPickerActivity#onListItemClick()
Project: zxing
File: AppPickerActivity.java
File: AppPickerActivity.java
@Override protected void onListItemClick(ListView l, View view, int position, long id) { Adapter adapter = getListAdapter(); if (position >= 0 && position < adapter.getCount()) { String packageName = ((AppInfo) adapter.getItem(position)).getPackageName(); Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); // Browser.BookmarkColumns.URL intent.putExtra("url", "market://details?id=" + packageName); setResult(RESULT_OK, intent); } else { setResult(RESULT_CANCELED); } finish(); }
4. UserContextMenuListener#onCreateContextMenu()
Project: YiBo
File: UserContextMenuListener.java
File: UserContextMenuListener.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; Adapter adapter = lvUser.getAdapter(); this.position = info.position; User user = (User) adapter.getItem(position); if (user == null) { return; } Context context = v.getContext(); analyzeUserMenu(adapter, user, menu, context); }
5. MicroBlogContextMenuListener#onCreateContextMenu()
Project: YiBo
File: MicroBlogContextMenuListener.java
File: MicroBlogContextMenuListener.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; Adapter adapter = lvMicroBlog.getAdapter(); this.position = info.position; targetView = info.targetView; Status status = (Status) adapter.getItem(position); if (status == null || (status instanceof LocalStatus && ((LocalStatus) status).isDivider())) { return; } Context context = v.getContext(); analyzeStatusMenu(adapter, status, menu, context); }
6. DirectMessagesItemClickListener#onItemClick()
Project: YiBo
File: DirectMessagesItemClickListener.java
File: DirectMessagesItemClickListener.java
@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(); } }
7. ConversationItemClickListener#onItemClick()
Project: YiBo
File: ConversationItemClickListener.java
File: ConversationItemClickListener.java
@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(); } }
8. CommentsItemClickListener#onItemClick()
Project: YiBo
File: CommentsItemClickListener.java
File: CommentsItemClickListener.java
@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(); } }
9. AddAccountConfigAppItemSelectedListener#onItemSelected()
Project: YiBo
File: AddAccountConfigAppItemSelectedListener.java
File: AddAccountConfigAppItemSelectedListener.java
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { Adapter adapter = parent.getAdapter(); Authorization auth = context.getAuth(); if (auth == null) { Logger.error("auth can't be null"); return; } ConfigApp configApp = (ConfigApp) adapter.getItem(position); if (configApp.getAppId() == -2l) { Intent intent = new Intent(); intent.setClass(context, AddConfigAppActivity.class); intent.putExtra("spNo", auth.getServiceProvider().getSpNo()); context.startActivityForResult(intent, Constants.REQUEST_CODE_CONFIG_APP_ADD); return; } OAuthConfig oauthConfig = auth.getoAuthConfig(); oauthConfig.setConsumerKey(configApp.getAppKey()); oauthConfig.setConsumerSecret(configApp.getAppSecret()); oauthConfig.setCallbackUrl(configApp.getCallbackUrl()); Logger.debug("callback:{}", oauthConfig.getCallbackUrl()); }
10. AppPickerActivity#onListItemClick()
Project: weex
File: AppPickerActivity.java
File: AppPickerActivity.java
@Override protected void onListItemClick(ListView l, View view, int position, long id) { Adapter adapter = getListAdapter(); if (position >= 0 && position < adapter.getCount()) { String packageName = ((AppInfo) adapter.getItem(position)).getPackageName(); Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.putExtra("url", "market://details?id=" + packageName); setResult(RESULT_OK, intent); } else { setResult(RESULT_CANCELED); } finish(); }
11. ShadowAdapterView#addViews()
Project: robolectric
File: ShadowAdapterView.java
File: ShadowAdapterView.java
protected void addViews() { Adapter adapter = getAdapter(); if (adapter != null) { if (valid && (previousItems.size() - ignoreRowsAtEndOfList != adapter.getCount() - ignoreRowsAtEndOfList)) { throw new ArrayIndexOutOfBoundsException("view is valid but adapter.getCount() has changed from " + previousItems.size() + " to " + adapter.getCount()); } List<Object> newItems = new ArrayList<Object>(); for (int i = 0; i < adapter.getCount() - ignoreRowsAtEndOfList; i++) { newItems.add(adapter.getItem(i)); View view = adapter.getView(i, null, realAdapterView); // don't add null views if (view != null) { addView(view); } } if (valid && !newItems.equals(previousItems)) { throw new RuntimeException("view is valid but current items <" + newItems + "> don't match previous items <" + previousItems + ">"); } previousItems = newItems; } }
12. PullToZoomListViewEx#isFirstItemVisible()
Project: PullZoomView
File: PullToZoomListViewEx.java
File: PullToZoomListViewEx.java
private boolean isFirstItemVisible() { final Adapter adapter = mRootView.getAdapter(); if (null == adapter || adapter.isEmpty()) { return true; } else { /** * This check should really just be: * mRootView.getFirstVisiblePosition() == 0, but PtRListView * internally use a HeaderView which messes the positions up. For * now we'll just add one to account for it and rely on the inner * condition which checks getTop(). */ if (mRootView.getFirstVisiblePosition() <= 1) { final View firstVisibleChild = mRootView.getChildAt(0); if (firstVisibleChild != null) { return firstVisibleChild.getTop() >= mRootView.getTop(); } } } return false; }
13. PullToRefreshAdapterViewBase#isLastItemVisible()
Project: MagicHeaderViewPager
File: PullToRefreshAdapterViewBase.java
File: PullToRefreshAdapterViewBase.java
private boolean isLastItemVisible() { final Adapter adapter = mRefreshableView.getAdapter(); if (null == adapter || adapter.isEmpty()) { return true; } else { final int lastItemPosition = mRefreshableView.getCount() - 1; final int lastVisiblePosition = mRefreshableView.getLastVisiblePosition(); /** * This check should really just be: lastVisiblePosition == lastItemPosition, but PtRListView internally uses a * FooterView which messes the positions up. For me we'll just subtract one to account for it and rely on the inner * condition which checks getBottom(). */ if (lastVisiblePosition >= lastItemPosition - 1) { final int childIndex = lastVisiblePosition - mRefreshableView.getFirstVisiblePosition(); final View lastVisibleChild = mRefreshableView.getChildAt(childIndex); if (lastVisibleChild != null) { return lastVisibleChild.getBottom() <= mRefreshableView.getBottom(); } } } return false; }
14. PullToRefreshAdapterViewBase#isFirstItemVisible()
Project: MagicHeaderViewPager
File: PullToRefreshAdapterViewBase.java
File: PullToRefreshAdapterViewBase.java
private boolean isFirstItemVisible() { final Adapter adapter = mRefreshableView.getAdapter(); if (null == adapter || adapter.isEmpty()) { return true; } else { /** * This check should really just be: mRefreshableView.getFirstVisiblePosition() == 0, but PtRListView internally use a * HeaderView which messes the positions up. For now we'll just add one to account for it and rely on the inner * condition which checks getTop(). */ if (mRefreshableView.getFirstVisiblePosition() <= 1) { final View firstVisibleChild = mRefreshableView.getChildAt(0); if (firstVisibleChild != null) { return firstVisibleChild.getTop() >= mRefreshableView.getTop(); } } } return false; }
15. PullToZoomListViewEx#isFirstItemVisible()
Project: light-novel-library_Wenku8_Android
File: PullToZoomListViewEx.java
File: PullToZoomListViewEx.java
private boolean isFirstItemVisible() { final Adapter adapter = mRootView.getAdapter(); if (null == adapter || adapter.isEmpty()) { return true; } else { /** * This check should really just be: * mRootView.getFirstVisiblePosition() == 0, but PtRListView * internally use a HeaderView which messes the positions up. For * now we'll just add one to account for it and rely on the inner * condition which checks getTop(). */ if (mRootView.getFirstVisiblePosition() <= 1) { final View firstVisibleChild = mRootView.getChildAt(0); if (firstVisibleChild != null) { return firstVisibleChild.getTop() >= mRootView.getTop(); } } } return false; }
16. PullToRefreshList#isFirstItemVisible()
Project: KJFrameForAndroid
File: PullToRefreshList.java
File: PullToRefreshList.java
/** * ?????child???????? * * @return true?????????false */ private boolean isFirstItemVisible() { final Adapter adapter = mfakeListView.getAdapter(); if (null == adapter || adapter.isEmpty()) { return true; } int mostTop = (mfakeListView.getChildCount() > 0) ? mfakeListView.getChildAt(0).getTop() : mfakeListView.getTop(); if (mostTop >= 0) { return true; } return false; }
17. PullToRefreshList#isFirstItemVisible()
Project: KJBlog
File: PullToRefreshList.java
File: PullToRefreshList.java
/** * ?????child???????? * * @return true?????????false */ private boolean isFirstItemVisible() { final Adapter adapter = mfakeListView.getAdapter(); if (null == adapter || adapter.isEmpty()) { return true; } int mostTop = (mfakeListView.getChildCount() > 0) ? mfakeListView.getChildAt(0).getTop() : mfakeListView.getTop(); if (mostTop >= 0) { return true; } return false; }
18. InboxLayoutListView#isReadyForDragEnd()
Project: InboxLayout
File: InboxLayoutListView.java
File: InboxLayoutListView.java
protected boolean isReadyForDragEnd() { final Adapter adapter = dragableView.getAdapter(); if (null == adapter || adapter.isEmpty()) { return true; } else { final int lastItemPosition = dragableView.getCount() - 1; final int lastVisiblePosition = dragableView.getLastVisiblePosition(); if (lastVisiblePosition >= lastItemPosition - 1) { final int childIndex = lastVisiblePosition - dragableView.getFirstVisiblePosition(); final View lastVisibleChild = dragableView.getChildAt(childIndex); if (lastVisibleChild != null) { return lastVisibleChild.getBottom() <= dragableView.getBottom(); } } } return false; }
19. InboxLayoutListView#isReadyForDragStart()
Project: InboxLayout
File: InboxLayoutListView.java
File: InboxLayoutListView.java
protected boolean isReadyForDragStart() { final Adapter adapter = dragableView.getAdapter(); if (null == adapter || adapter.isEmpty()) { return true; } else { if (dragableView.getFirstVisiblePosition() <= 1) { final View firstVisibleChild = dragableView.getChildAt(0); if (firstVisibleChild != null) { return firstVisibleChild.getTop() >= dragableView.getTop(); } } } return false; }
20. PXHierarchyListener#setAdapterProxy()
Project: pixate-freestyle-android
File: PXHierarchyListener.java
File: PXHierarchyListener.java
@SuppressWarnings({ "rawtypes", "unchecked" }) private static void setAdapterProxy(final AdapterView adapterView) { Adapter adapter = adapterView.getAdapter(); if (adapter == null || Proxy.isProxyClass(adapter.getClass())) { // Thou shalt not Proxy a Proxy! return; } if (adapterView instanceof ExpandableListView) { // a special adapter that only works with it.... Lame API break! return; } // Collect the Adapter sub-interfaces that we // would like to proxy. List<Class<?>> interfaces = new ArrayList<Class<?>>(4); interfaces.add(Adapter.class); if (adapter instanceof ListAdapter) { interfaces.add(ListAdapter.class); } if (adapter instanceof WrapperListAdapter) { interfaces.add(WrapperListAdapter.class); } if (adapter instanceof SpinnerAdapter) { interfaces.add(SpinnerAdapter.class); } // Create a proxy for the adapter to intercept // the 'getView' Adapter newAdapter = (Adapter) PXAdapterInvocationHandler.newInstance(adapterView, interfaces.toArray(new Class<?>[interfaces.size()])); // Set the proxy as the adapter adapterView.setAdapter(newAdapter); }
21. PullToRefreshAdapterViewBase#isFirstItemVisible()
Project: Android-PullToRefresh
File: PullToRefreshAdapterViewBase.java
File: PullToRefreshAdapterViewBase.java
private boolean isFirstItemVisible() { final Adapter adapter = mRefreshableView.getAdapter(); if (null == adapter || adapter.isEmpty()) { if (DEBUG) { Log.d(LOG_TAG, "isFirstItemVisible. Empty View."); } return true; } else { /** * This check should really just be: * mRefreshableView.getFirstVisiblePosition() == 0, but PtRListView * internally use a HeaderView which messes the positions up. For * now we'll just add one to account for it and rely on the inner * condition which checks getTop(). */ if (mRefreshableView.getFirstVisiblePosition() <= 1) { final View firstVisibleChild = mRefreshableView.getChildAt(0); if (firstVisibleChild != null) { return firstVisibleChild.getTop() >= mRefreshableView.getTop(); } } } return false; }
22. LoadableDecorator#isEmpty()
Project: android-oauth-client
File: LoadableDecorator.java
File: LoadableDecorator.java
private boolean isEmpty() { Adapter adapter = mAdapterView.getAdapter(); return adapter == null || adapter.isEmpty(); }
23. PullToRefreshAdapterViewBase#isLastItemVisible()
Project: AcFun-Area63
File: PullToRefreshAdapterViewBase.java
File: PullToRefreshAdapterViewBase.java
private boolean isLastItemVisible() { final Adapter adapter = mRefreshableView.getAdapter(); if (null == adapter || adapter.isEmpty()) { if (DEBUG) { Log.d(LOG_TAG, "isLastItemVisible. Empty View."); } return true; } else { final int lastItemPosition = mRefreshableView.getCount() - 1; final int lastVisiblePosition = mRefreshableView.getLastVisiblePosition(); if (DEBUG) { Log.d(LOG_TAG, "isLastItemVisible. Last Item Position: " + lastItemPosition + " Last Visible Pos: " + lastVisiblePosition); } /** * This check should really just be: lastVisiblePosition == * lastItemPosition, but PtRListView internally uses a FooterView * which messes the positions up. For me we'll just subtract one to * account for it and rely on the inner condition which checks * getBottom(). */ if (lastVisiblePosition >= lastItemPosition - 1) { final int childIndex = lastVisiblePosition - mRefreshableView.getFirstVisiblePosition(); final View lastVisibleChild = mRefreshableView.getChildAt(childIndex); if (lastVisibleChild != null) { return lastVisibleChild.getBottom() <= mRefreshableView.getBottom(); } } } return false; }
24. PullToRefreshAdapterViewBase#isFirstItemVisible()
Project: AcFun-Area63
File: PullToRefreshAdapterViewBase.java
File: PullToRefreshAdapterViewBase.java
private boolean isFirstItemVisible() { final Adapter adapter = mRefreshableView.getAdapter(); if (null == adapter || adapter.isEmpty()) { if (DEBUG) { Log.d(LOG_TAG, "isFirstItemVisible. Empty View."); } return true; } else { /** * This check should really just be: * mRefreshableView.getFirstVisiblePosition() == 0, but PtRListView * internally use a HeaderView which messes the positions up. For * now we'll just add one to account for it and rely on the inner * condition which checks getTop(). */ if (mRefreshableView.getFirstVisiblePosition() <= 1) { final View firstVisibleChild = mRefreshableView.getChildAt(0); if (firstVisibleChild != null) { return firstVisibleChild.getTop() >= mRefreshableView.getTop(); } } } return false; }
25. MicroBlogMoreItemClickListener#onItemClick()
Project: YiBo
File: MicroBlogMoreItemClickListener.java
File: MicroBlogMoreItemClickListener.java
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Adapter adapter = parent.getAdapter(); BaseAdapter baseAdapter = AdapterUtil.getAdapter(adapter); if (!(baseAdapter instanceof MicroBlogMoreListAdapter)) { return; } MicroBlogMoreListAdapter listAdapter = (MicroBlogMoreListAdapter) baseAdapter; chooseDialog.dismiss(); final Context context = view.getContext(); final Status status = listAdapter.getStatus(); int itemId = (int) listAdapter.getItemId(position); ClipboardManager clip = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); switch(itemId) { case MicroBlogMoreListAdapter.ITEM_DELETE: new AlertDialog.Builder(context).setTitle(R.string.title_dialog_alert).setMessage(R.string.msg_blog_delete).setNegativeButton(R.string.btn_cancel, new AlertDialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).setPositiveButton(R.string.btn_confirm, new AlertDialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { DestroyStatusTask task = new DestroyStatusTask(context, status); task.execute(); } }).show(); break; case MicroBlogMoreListAdapter.ITEM_COPY: String copyStatusText = StatusUtil.extraSimpleStatus(context, status); clip.setText(copyStatusText); Toast.makeText(context, R.string.msg_blog_copy, Toast.LENGTH_SHORT).show(); break; case MicroBlogMoreListAdapter.ITEM_SHARE_TO_ACCOUNTS: Intent intent = new Intent(Intent.ACTION_SEND); intent.setClass(context, EditMicroBlogActivity.class); if (EntityUtil.hasPicture(status)) { intent.setType("image/*"); CachedImageKey info = EntityUtil.getMaxLocalCachedImageInfo(status); String imagePath = ImageCache.getRealPath(info); if (StringUtil.isNotEmpty(imagePath)) { if (info.getCacheType() == CachedImageKey.IMAGE_THUMBNAIL) { Toast.makeText(context, context.getString(R.string.msg_blog_share_picture_thumbnail), Toast.LENGTH_LONG).show(); } Uri uri = Uri.fromFile(new File(imagePath)); intent.putExtra(Intent.EXTRA_STREAM, uri); } else { intent.setType("text/plain"); Toast.makeText(context, context.getString(R.string.msg_blog_share_picture), Toast.LENGTH_LONG).show(); } } else { intent.setType("text/plain"); } String statusText = StatusUtil.extraSimpleStatus(context, status); clip.setText(statusText); intent.putExtra(Intent.EXTRA_TEXT, statusText); intent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.msg_extra_subject)); context.startActivity(intent); break; } }
26. MicroBlogItemClickListener#onItemClick()
Project: YiBo
File: MicroBlogItemClickListener.java
File: MicroBlogItemClickListener.java
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Adapter adapter = parent.getAdapter(); Status status = (Status) adapter.getItem(position); if (status == null || (status instanceof LocalStatus && ((LocalStatus) status).isDivider())) { return; } Intent intent = new Intent(); Bundle bundle = new Bundle(); bundle.putSerializable("STATUS", status); CacheAdapter<?> cacheAdapter = AdapterUtil.getCacheAdapter(adapter); if (cacheAdapter instanceof MyHomeListAdapter) { bundle.putInt("SOURCE", Constants.REQUEST_CODE_MY_HOME); bundle.putInt("POSITION", position - 1); } intent.putExtras(bundle); intent.setClass(parent.getContext(), MicroBlogActivity.class); ((Activity) context).startActivityForResult(intent, Constants.REQUEST_CODE_MICRO_BLOG); CompatibilityUtil.overridePendingTransition((Activity) context, R.anim.slide_in_right, android.R.anim.fade_out); }
27. HomePageRefreshListener#onRefresh()
Project: YiBo
File: HomePageRefreshListener.java
File: HomePageRefreshListener.java
@Override public void onRefresh(PullToRefreshListView listView) { if (listView == null) { return; } Adapter adapter = listView.getAdapter(); if (adapter == null) { return; } if (adapter instanceof HeaderViewListAdapter) { adapter = ((HeaderViewListAdapter) adapter).getWrappedAdapter(); } CacheAdapter<?> cacheAdapter = (CacheAdapter<?>) adapter; if (cacheAdapter instanceof MyHomeListAdapter) { MyHomePageUpTask task = new MyHomePageUpTask((MyHomeListAdapter) cacheAdapter); task.setListView(listView); task.execute(); } else if (cacheAdapter instanceof GroupStatusesListAdapter) { GroupStatusesPageUpTask task = new GroupStatusesPageUpTask((GroupStatusesListAdapter) cacheAdapter); task.setListView(listView); task.execute(); } else if (cacheAdapter instanceof MentionsListAdapter) { MetionsPageUpTask task = new MetionsPageUpTask((MentionsListAdapter) cacheAdapter); task.setListView(listView); task.execute(); } else if (cacheAdapter instanceof CommentsListAdapter) { CommentsPageUpTask task = new CommentsPageUpTask((CommentsListAdapter) cacheAdapter); task.setListView(listView); task.execute(); } else if (cacheAdapter instanceof DirectMessagesListAdapter) { DirectMessagePageUpTask task = new DirectMessagePageUpTask((DirectMessagesListAdapter) cacheAdapter); task.setListView(listView); task.execute(); } }
28. GroupItemClickListener#onItemClick()
Project: YiBo
File: GroupItemClickListener.java
File: GroupItemClickListener.java
@SuppressWarnings("unchecked") @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Adapter adapter = parent.getAdapter(); final CacheAdapter<Group> cacheAdapter = (CacheAdapter<Group>) AdapterUtil.getCacheAdapter(adapter); if (position >= cacheAdapter.getCount()) { return; } //final LocalAccount account = cacheAdapter.getAccount(); Group group = (Group) cacheAdapter.getItem(position); if (position == 0) { final EditText editText = new EditText(context); new AlertDialog.Builder(context).setIcon(R.drawable.icon_group).setTitle(R.string.title_dialog_add_group).setView(editText).setPositiveButton(R.string.btn_confirm, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String groupName = editText.getEditableText().toString(); if (StringUtil.isNotEmpty(groupName)) { GroupAddTask task = new GroupAddTask((GroupListAdapter) cacheAdapter, groupName); task.execute(); } } }).setNegativeButton(R.string.btn_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { /* User clicked cancel so do some stuff */ } }).create().show(); } else { Intent intent = new Intent(); Bundle bundle = new Bundle(); bundle.putString("SELECT_MODE", SelectMode.Multiple.toString()); bundle.putSerializable("GROUP", group); intent.putExtras(bundle); intent.setClass(context, GroupMemberActivity.class); context.startActivity(intent); } }
29. CommentsOfStatusContextMenuListener#getCacheAdapter()
Project: YiBo
File: CommentsOfStatusContextMenuListener.java
File: CommentsOfStatusContextMenuListener.java
@SuppressWarnings("unchecked") private CacheAdapter<Comment> getCacheAdapter(Adapter adapter) { CacheAdapter<Comment> cacheAdapter = null; Adapter tempAdapter = adapter; if (tempAdapter instanceof HeaderViewListAdapter) { tempAdapter = ((HeaderViewListAdapter) adapter).getWrappedAdapter(); } cacheAdapter = (CacheAdapter<Comment>) tempAdapter; return cacheAdapter; }
30. AppGridItemClickListener#onItemClick()
Project: YiBo
File: AppGridItemClickListener.java
File: AppGridItemClickListener.java
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Adapter adapter = parent.getAdapter(); long appImageId = adapter.getItemId(position); Activity context = (Activity) parent.getContext(); Intent intent = new Intent(); if (appImageId == R.drawable.icon_app_search) { intent.setClass(context, SearchActivity.class); } else if (appImageId == R.drawable.icon_app_public_timeline) { intent.setClass(context, PublicTimelineActivity.class); } else if (appImageId == R.drawable.icon_app_hot_retweet) { intent.setClass(context, HotStatusesActivity.class); intent.putExtra("STATUS_CATALOG", StatusCatalog.Hot_Retweet.getCatalogNo()); } else if (appImageId == R.drawable.icon_app_hot_comment) { intent.setClass(context, HotStatusesActivity.class); intent.putExtra("STATUS_CATALOG", StatusCatalog.Hot_Comment.getCatalogNo()); } else if (appImageId == R.drawable.icon_app_hot_topic) { //intent.setClass(context, HotTopicsActivity.class); intent.setClass(context, StatusSubscribeActivity.class); intent.putExtra("STATUS_CATALOG", StatusCatalog.Picture_Mobile.getCatalogNo()); intent.putExtra("TITLE_ID", R.string.label_app_hot_topic); } else if (appImageId == R.drawable.icon_app_daily) { intent.setClass(context, StatusSubscribeActivity.class); intent.putExtra("STATUS_CATALOG", StatusCatalog.News.getCatalogNo()); intent.putExtra("TITLE_ID", R.string.label_app_daily); } else if (appImageId == R.drawable.icon_app_image) { intent.setClass(context, StatusSubscribeActivity.class); intent.putExtra("STATUS_CATALOG", StatusCatalog.Picture.getCatalogNo()); intent.putExtra("TITLE_ID", R.string.label_app_image); } else if (appImageId == R.drawable.icon_app_jokes) { intent.setClass(context, StatusSubscribeActivity.class); intent.putExtra("STATUS_CATALOG", StatusCatalog.Joke.getCatalogNo()); intent.putExtra("TITLE_ID", R.string.label_app_jokes); } else if (appImageId == R.drawable.icon_app_exchange) { ConfigSystemDao configDao = new ConfigSystemDao(context); String username = configDao.getString(Constants.PASSPORT_USERNAME); // } return; } else { Toast.makeText(context, "???????????..", Toast.LENGTH_LONG).show(); return; } context.startActivity(intent); }
31. MyHomeListAdapter#refresh()
Project: YiBo
File: MyHomeListAdapter.java
File: MyHomeListAdapter.java
public boolean refresh() { if (listNewBlogs == null || listNewBlogs.size() == 0) { return false; } addCacheToFirst(listNewBlogs); int offset = listNewBlogs.size(); listNewBlogs.clear(); ListView lvMicroBlog = (ListView) ((Activity) context).findViewById(R.id.lvMicroBlog); if (lvMicroBlog == null) { return true; } Adapter adapter = lvMicroBlog.getAdapter(); if (adapter instanceof HeaderViewListAdapter) { adapter = ((HeaderViewListAdapter) adapter).getWrappedAdapter(); } if (adapter == this) { int position = lvMicroBlog.getFirstVisiblePosition(); View view = lvMicroBlog.getChildAt(0); int y = 0; if (view != null && position >= 1) { y = view.getTop(); //System.out.println("y:" + y + " position:" + position); position += offset; lvMicroBlog.setSelectionFromTop(position, y); } } return true; }
32. MentionsListAdapter#refresh()
Project: YiBo
File: MentionsListAdapter.java
File: MentionsListAdapter.java
public boolean refresh() { if (listNewBlogs == null || listNewBlogs.size() == 0) { return false; } addCacheToFirst(listNewBlogs); int offset = listNewBlogs.size(); listNewBlogs.clear(); newCount = 0; ListView lvMicroBlog = (ListView) ((Activity) context).findViewById(R.id.lvMicroBlog); if (lvMicroBlog == null) { return true; } Adapter adapter = lvMicroBlog.getAdapter(); if (adapter instanceof HeaderViewListAdapter) { adapter = ((HeaderViewListAdapter) adapter).getWrappedAdapter(); } if (lvMicroBlog != null && adapter == this) { int position = lvMicroBlog.getFirstVisiblePosition(); View view = lvMicroBlog.getChildAt(0); int y = 0; if (view != null && position >= 1) { y = view.getTop(); position += offset; lvMicroBlog.setSelectionFromTop(position, y); } } return true; }
33. DirectMessagesListAdapter#refresh()
Project: YiBo
File: DirectMessagesListAdapter.java
File: DirectMessagesListAdapter.java
public boolean refresh() { if (ListUtil.isEmpty(newInboxList) && ListUtil.isEmpty(newOutboxList)) { return false; } addCacheToFirst(newInboxList); addCacheToFirst(newOutboxList); int offset = newInboxList.size() + newOutboxList.size(); newInboxList.clear(); newOutboxList.clear(); newCount = 0; ListView lvMicroBlog = (ListView) ((Activity) context).findViewById(R.id.lvMicroBlog); if (lvMicroBlog == null) { return true; } Adapter adapter = lvMicroBlog.getAdapter(); if (adapter instanceof HeaderViewListAdapter) { adapter = ((HeaderViewListAdapter) adapter).getWrappedAdapter(); } if (lvMicroBlog != null && adapter == this) { int position = lvMicroBlog.getFirstVisiblePosition(); View view = lvMicroBlog.getChildAt(0); int y = 0; if (view != null && position >= 1) { y = view.getTop(); position += offset; lvMicroBlog.setSelectionFromTop(position, y); } } return true; }
34. CommentsListAdapter#refresh()
Project: YiBo
File: CommentsListAdapter.java
File: CommentsListAdapter.java
public boolean refresh() { if (ListUtil.isEmpty(listNewComments)) { return false; } addCacheToFirst(listNewComments); int offset = listNewComments.size(); listNewComments.clear(); newCount = 0; ListView lvMicroBlog = (ListView) ((Activity) context).findViewById(R.id.lvMicroBlog); if (lvMicroBlog == null) { return true; } Adapter adapter = lvMicroBlog.getAdapter(); if (adapter instanceof HeaderViewListAdapter) { adapter = ((HeaderViewListAdapter) adapter).getWrappedAdapter(); } if (lvMicroBlog != null && adapter == this) { int position = lvMicroBlog.getFirstVisiblePosition(); View view = lvMicroBlog.getChildAt(0); int y = 0; if (view != null && position >= 1) { y = view.getTop(); position += offset; lvMicroBlog.setSelectionFromTop(position, y); } } return true; }
35. ShadowAdapterView#getItemIdAtPosition()
Project: robolectric
File: ShadowAdapterView.java
File: ShadowAdapterView.java
@Implementation public long getItemIdAtPosition(int position) { Adapter adapter = getAdapter(); return (adapter == null || position < 0) ? AdapterView.INVALID_ROW_ID : adapter.getItemId(position); }
36. ShadowAdapterView#getItemAtPosition()
Project: robolectric
File: ShadowAdapterView.java
File: ShadowAdapterView.java
@Implementation public Object getItemAtPosition(int position) { Adapter adapter = getAdapter(); return (adapter == null || position < 0) ? null : adapter.getItem(position); }
37. ArticlesFragment#onDestroyView()
Project: reader
File: ArticlesFragment.java
File: ArticlesFragment.java
@Override public void onDestroyView() { // Don't forget to stop listening to articles loading state to avoid crash and memory leaks Adapter adapter = aq.id(R.id.articleList).getListView().getAdapter(); SharedArticlesAdapterHelper.getInstance().removeAdapter(adapter, articlesHelperListener); super.onDestroyView(); }
38. PXAdapterInvocationHandler#newInstance()
Project: pixate-freestyle-android
File: PXAdapterInvocationHandler.java
File: PXAdapterInvocationHandler.java
/** * Creates a new proxied instance of the given adapter. * * @param obj An {@link AdapterView} instance. The proxy will be made for * its {@link Adapter}. * @param adapterInterfaces The interfaces that will be implemented on the * fly by the proxy * @return A new proxy for the {@link Adapter} */ public static Object newInstance(AdapterView<Adapter> adapterView, Class<?>[] adapterInterfaces) { Adapter adapter = adapterView.getAdapter(); return java.lang.reflect.Proxy.newProxyInstance(adapter.getClass().getClassLoader(), adapterInterfaces, new PXAdapterInvocationHandler(adapterView)); }
39. PixateFreestyle#getAdapter()
Project: pixate-freestyle-android
File: PixateFreestyle.java
File: PixateFreestyle.java
/** * Returns the {@link Adapter} that is nested in the given * {@link AdapterView}. In case the adapter is 'proxied', try to extract the * original {@link Adapter} from the proxy instance. * * @param view * @return The original {@link Adapter} that was set for the * {@link AdapterView} (can be null) */ public static Adapter getAdapter(AdapterView<?> view) { Adapter adapter = view.getAdapter(); if (adapter != null && Proxy.isProxyClass(adapter.getClass())) { InvocationHandler handler = Proxy.getInvocationHandler(adapter); if (handler instanceof PXAdapterInvocationHandler) { adapter = ((PXAdapterInvocationHandler) handler).getOriginal(); } } return adapter; }
40. PullToRefreshAdapterViewBase#isLastItemVisible()
Project: ONE-Unofficial
File: PullToRefreshAdapterViewBase.java
File: PullToRefreshAdapterViewBase.java
private boolean isLastItemVisible() { final Adapter adapter = mRefreshableView.getAdapter(); if (null == adapter || adapter.isEmpty()) { if (DEBUG) { Log.d(LOG_TAG, "isLastItemVisible. Empty View."); } return true; } else { final int lastItemPosition = mRefreshableView.getCount() - 1; final int lastVisiblePosition = mRefreshableView.getLastVisiblePosition(); if (DEBUG) { Log.d(LOG_TAG, "isLastItemVisible. Last Item Position: " + lastItemPosition + " Last Visible Pos: " + lastVisiblePosition); } /** * This check should really just be: lastVisiblePosition == * lastItemPosition, but PtRListView internally uses a FooterView * which messes the positions up. For me we'll just subtract one to * account for it and rely on the inner condition which checks * getBottom(). */ if (lastVisiblePosition >= lastItemPosition - 1) { final int childIndex = lastVisiblePosition - mRefreshableView.getFirstVisiblePosition(); final View lastVisibleChild = mRefreshableView.getChildAt(childIndex); if (lastVisibleChild != null) { return lastVisibleChild.getBottom() <= mRefreshableView.getBottom(); } } } return false; }
41. PullToRefreshAdapterViewBase#isFirstItemVisible()
Project: ONE-Unofficial
File: PullToRefreshAdapterViewBase.java
File: PullToRefreshAdapterViewBase.java
private boolean isFirstItemVisible() { final Adapter adapter = mRefreshableView.getAdapter(); if (null == adapter || adapter.isEmpty()) { if (DEBUG) { Log.d(LOG_TAG, "isFirstItemVisible. Empty View."); } return true; } else { /** * This check should really just be: * mRefreshableView.getFirstVisiblePosition() == 0, but PtRListView * internally use a HeaderView which messes the positions up. For * now we'll just add one to account for it and rely on the inner * condition which checks getTop(). */ if (mRefreshableView.getFirstVisiblePosition() <= 1) { final View firstVisibleChild = mRefreshableView.getChildAt(0); if (firstVisibleChild != null) { return firstVisibleChild.getTop() >= mRefreshableView.getTop(); } } } return false; }
42. PullToRefreshList#isLastItemVisible()
Project: KJFrameForAndroid
File: PullToRefreshList.java
File: PullToRefreshList.java
/** * ??????child???????? * * @return true?????????false */ private boolean isLastItemVisible() { final Adapter adapter = mfakeListView.getAdapter(); if (null == adapter || adapter.isEmpty()) { return true; } final int lastItemPosition = adapter.getCount() - 1; final int lastVisiblePosition = mfakeListView.getLastVisiblePosition(); /** * This check should really just be: lastVisiblePosition == * lastItemPosition, but ListView internally uses a FooterView which * messes the positions up. For me we'll just subtract one to account * for it and rely on the inner condition which checks getBottom(). */ if (lastVisiblePosition >= lastItemPosition - 1) { final int childIndex = lastVisiblePosition - mfakeListView.getFirstVisiblePosition(); final int childCount = mfakeListView.getChildCount(); final int index = Math.min(childIndex, childCount - 1); final View lastVisibleChild = mfakeListView.getChildAt(index); if (lastVisibleChild != null) { return lastVisibleChild.getBottom() <= mfakeListView.getBottom(); } } return false; }
43. PullToRefreshList#isLastItemVisible()
Project: KJBlog
File: PullToRefreshList.java
File: PullToRefreshList.java
/** * ??????child???????? * * @return true?????????false */ private boolean isLastItemVisible() { final Adapter adapter = mfakeListView.getAdapter(); if (null == adapter || adapter.isEmpty()) { return true; } final int lastItemPosition = adapter.getCount() - 1; final int lastVisiblePosition = mfakeListView.getLastVisiblePosition(); /** * This check should really just be: lastVisiblePosition == * lastItemPosition, but ListView internally uses a FooterView which * messes the positions up. For me we'll just subtract one to account * for it and rely on the inner condition which checks getBottom(). */ if (lastVisiblePosition >= lastItemPosition - 1) { final int childIndex = lastVisiblePosition - mfakeListView.getFirstVisiblePosition(); final int childCount = mfakeListView.getChildCount(); final int index = Math.min(childIndex, childCount - 1); final View lastVisibleChild = mfakeListView.getChildAt(index); if (lastVisibleChild != null) { return lastVisibleChild.getBottom() <= mfakeListView.getBottom(); } } return false; }
44. PullToRefreshAdapterViewBase#isLastItemVisible()
Project: k-9
File: PullToRefreshAdapterViewBase.java
File: PullToRefreshAdapterViewBase.java
private boolean isLastItemVisible() { final Adapter adapter = mRefreshableView.getAdapter(); if (null == adapter || adapter.isEmpty()) { if (DEBUG) { Log.d(LOG_TAG, "isLastItemVisible. Empty View."); } return true; } else { final int lastItemPosition = mRefreshableView.getCount() - 1; final int lastVisiblePosition = mRefreshableView.getLastVisiblePosition(); if (DEBUG) { Log.d(LOG_TAG, "isLastItemVisible. Last Item Position: " + lastItemPosition + " Last Visible Pos: " + lastVisiblePosition); } /** * This check should really just be: lastVisiblePosition == * lastItemPosition, but PtRListView internally uses a FooterView * which messes the positions up. For me we'll just subtract one to * account for it and rely on the inner condition which checks * getBottom(). */ if (lastVisiblePosition >= lastItemPosition - 1) { final int childIndex = lastVisiblePosition - mRefreshableView.getFirstVisiblePosition(); final View lastVisibleChild = mRefreshableView.getChildAt(childIndex); if (lastVisibleChild != null) { return lastVisibleChild.getBottom() <= mRefreshableView.getBottom(); } } } return false; }
45. PullToRefreshAdapterViewBase#isFirstItemVisible()
Project: k-9
File: PullToRefreshAdapterViewBase.java
File: PullToRefreshAdapterViewBase.java
private boolean isFirstItemVisible() { final Adapter adapter = mRefreshableView.getAdapter(); if (null == adapter || adapter.isEmpty()) { if (DEBUG) { Log.d(LOG_TAG, "isFirstItemVisible. Empty View."); } return true; } else { /** * This check should really just be: * mRefreshableView.getFirstVisiblePosition() == 0, but PtRListView * internally use a HeaderView which messes the positions up. For * now we'll just add one to account for it and rely on the inner * condition which checks getTop(). */ if (mRefreshableView.getFirstVisiblePosition() <= 1) { final View firstVisibleChild = mRefreshableView.getChildAt(0); if (firstVisibleChild != null) { return firstVisibleChild.getTop() >= mRefreshableView.getTop(); } } } return false; }
46. SeparatedListAdapter#getViewTypeCount()
Project: jamendo-android
File: SeparatedListAdapter.java
File: SeparatedListAdapter.java
public int getViewTypeCount() { // assume that headers count as one, then total all sections int total = 1; for (Adapter adapter : this.sections.values()) total += adapter.getViewTypeCount(); return total; }
47. SeparatedListAdapter#getCount()
Project: jamendo-android
File: SeparatedListAdapter.java
File: SeparatedListAdapter.java
public int getCount() { // total together all sections, plus one for each section header int total = 0; for (Adapter adapter : this.sections.values()) total += adapter.getCount() + 1; return total; }
48. SeparatedListAdapter#getViewTypeCount()
Project: frostwire-android
File: SeparatedListAdapter.java
File: SeparatedListAdapter.java
/** * {@inheritDoc} */ @Override public int getViewTypeCount() { // assume that mHeaders count as one, then total all mSections int total = 1; for (final Adapter adapter : mSections.values()) { total += adapter.getViewTypeCount(); } return total; }
49. SeparatedListAdapter#getCount()
Project: frostwire-android
File: SeparatedListAdapter.java
File: SeparatedListAdapter.java
/** * {@inheritDoc} */ @Override public int getCount() { // total together all mSections, plus one for each section header int total = 0; for (final Adapter adapter : mSections.values()) { total += adapter.getCount() + 1; } return total; }
50. DragNDropListView#startDrag()
Project: DragNDropList
File: DragNDropListView.java
File: DragNDropListView.java
/** * Prepare the drag view. * * @param childIndex * @param y */ private void startDrag(int childIndex, int y) { View item = getChildAt(childIndex); if (item == null) return; long id = getItemIdAtPosition(mStartPosition); if (mDragNDropListener != null) mDragNDropListener.onItemDrag(this, item, mStartPosition, id); Adapter adapter = getAdapter(); DragNDropAdapter dndAdapter; // if exists a footer/header we have our adapter wrapped if (adapter instanceof WrapperListAdapter) { dndAdapter = (DragNDropAdapter) ((WrapperListAdapter) adapter).getWrappedAdapter(); } else { dndAdapter = (DragNDropAdapter) adapter; } dndAdapter.onItemDrag(this, item, mStartPosition, id); item.setDrawingCacheEnabled(true); // Create a copy of the drawing cache so that it does not get recycled // by the framework when the list tries to clean up memory Bitmap bitmap = Bitmap.createBitmap(item.getDrawingCache()); WindowManager.LayoutParams mWindowParams = new WindowManager.LayoutParams(); mWindowParams.gravity = Gravity.TOP; mWindowParams.x = 0; mWindowParams.y = y - mDragPointOffset; mWindowParams.height = WindowManager.LayoutParams.WRAP_CONTENT; mWindowParams.width = WindowManager.LayoutParams.WRAP_CONTENT; mWindowParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS; mWindowParams.format = PixelFormat.TRANSLUCENT; mWindowParams.windowAnimations = 0; Context context = getContext(); ImageView v = new ImageView(context); v.setImageBitmap(bitmap); mWm.addView(v, mWindowParams); mDragView = v; item.setVisibility(View.INVISIBLE); // We have not changed anything else. item.invalidate(); }
51. FastScroller#getSections()
Project: Book-Catalogue
File: FastScroller.java
File: FastScroller.java
private void getSections() { Adapter adapter = mList.getAdapter(); mSectionIndexerV1 = null; mSectionIndexerV2 = null; if (adapter instanceof HeaderViewListAdapter) { mListOffset = ((HeaderViewListAdapter) adapter).getHeadersCount(); adapter = ((HeaderViewListAdapter) adapter).getWrappedAdapter(); } if (mList instanceof ExpandableListView) { ExpandableListAdapter expAdapter = ((ExpandableListView) mList).getExpandableListAdapter(); if (expAdapter instanceof SectionIndexer) { mSectionIndexerV1 = (SectionIndexer) expAdapter; mListAdapter = (BaseAdapter) adapter; mSections = mSectionIndexerV1.getSections(); } else if (expAdapter instanceof SectionIndexerV2) { mSectionIndexerV2 = (SectionIndexerV2) expAdapter; mListAdapter = (BaseAdapter) adapter; } } else { if (adapter instanceof SectionIndexer) { mListAdapter = (BaseAdapter) adapter; mSectionIndexerV1 = (SectionIndexer) adapter; mSections = mSectionIndexerV1.getSections(); } else if (adapter instanceof SectionIndexerV2) { mListAdapter = (BaseAdapter) adapter; mSectionIndexerV2 = (SectionIndexerV2) adapter; } else { mListAdapter = (BaseAdapter) adapter; mSections = new String[] { " " }; } } }
52. AbstractAdapterViewAssert#hasAdapter()
Project: assertj-android
File: AbstractAdapterViewAssert.java
File: AbstractAdapterViewAssert.java
public S hasAdapter(Adapter adapter) { isNotNull(); Adapter actualAdapter = actual.getAdapter(); // assertThat(actualAdapter).overridingErrorMessage("Expected adapter <%s> but was <%s>.", adapter, // actualAdapter).isSameAs(adapter); return myself; }
53. FastScrollView#getSections()
Project: android-xbmcremote
File: FastScrollView.java
File: FastScrollView.java
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(); } }
54. PullToRefreshAdapterViewBase#isLastItemVisible()
Project: Android-PullToRefresh
File: PullToRefreshAdapterViewBase.java
File: PullToRefreshAdapterViewBase.java
private boolean isLastItemVisible() { final Adapter adapter = mRefreshableView.getAdapter(); if (null == adapter || adapter.isEmpty()) { if (DEBUG) { Log.d(LOG_TAG, "isLastItemVisible. Empty View."); } return true; } else { final int lastItemPosition = mRefreshableView.getCount() - 1; final int lastVisiblePosition = mRefreshableView.getLastVisiblePosition(); if (DEBUG) { Log.d(LOG_TAG, "isLastItemVisible. Last Item Position: " + lastItemPosition + " Last Visible Pos: " + lastVisiblePosition); } /** * This check should really just be: lastVisiblePosition == * lastItemPosition, but PtRListView internally uses a FooterView * which messes the positions up. For me we'll just subtract one to * account for it and rely on the inner condition which checks * getBottom(). */ if (lastVisiblePosition >= lastItemPosition - 1) { final int childIndex = lastVisiblePosition - mRefreshableView.getFirstVisiblePosition(); final View lastVisibleChild = mRefreshableView.getChildAt(childIndex); if (lastVisibleChild != null) { return lastVisibleChild.getBottom() <= mRefreshableView.getBottom(); } } } return false; }