Java Code Examples for android.widget.AbsListView#getChildAt()
The following examples show how to use
android.widget.AbsListView#getChildAt() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListScrollDistanceCalculator.java From KUAS-AP-Material with MIT License | 6 votes |
@Override public void onScrollStateChanged(AbsListView view, int scrollState) { if (view.getCount() == 0) { return; } switch (scrollState) { case SCROLL_STATE_IDLE: { mListScrollStarted = false; break; } case SCROLL_STATE_TOUCH_SCROLL: { final View firstChild = view.getChildAt(0); mFirstVisibleItem = view.getFirstVisiblePosition(); mFirstVisibleTop = firstChild.getTop(); mFirstVisibleBottom = firstChild.getBottom(); mFirstVisibleHeight = firstChild.getHeight(); mListScrollStarted = true; mTotalScrollDistance = 0; break; } } }
Example 2
Source File: MainActivity.java From RefreashTabView with Apache License 2.0 | 6 votes |
/** * 主要算这玩意,PullToRefreshListView插入了一个刷新头部,因此要根据不同的情况计算当前的偏移量</br> * <p/> * 当刷新时: 刷新头部显示,因此偏移量要加上刷新头的数值 未刷新时: 偏移量不计算头部。 * <p/> * firstVisiblePosition >1时,listview中的项开始显示,姑且认为每一项等高来计算偏移量(其实只要显示一个项,向上偏移 * 量已经大于头部的最大偏移量,因此不准确也没有关系) * * @param view * @return */ public int getScrollY(AbsListView view) { View c = view.getChildAt(0); if (c == null) { return 0; } int top = c.getTop(); int firstVisiblePosition = view.getFirstVisiblePosition(); if (firstVisiblePosition == 0) { return -top + headerScrollSize; } else if (firstVisiblePosition == 1) { return -top; } else { return -top + (firstVisiblePosition - 2) * c.getHeight() + headerHeight; } }
Example 3
Source File: ContextualUndoAdapter.java From UltimateAndroid with Apache License 2.0 | 6 votes |
private ContextualUndoView getContextualUndoView(final long dismissViewItemId) { ContextualUndoView contextualUndoView = null; AbsListView listView = getAbsListView(); int childCount = listView.getChildCount(); for (int i = 0; i < childCount; i++) { View child = listView.getChildAt(i); if (child instanceof ContextualUndoView) { ContextualUndoView listItem = (ContextualUndoView) child; if (listItem.getItemId() == dismissViewItemId) { contextualUndoView = listItem; } } } return contextualUndoView; }
Example 4
Source File: DirectionScrollListener.java From BigApp_Discuz_Android with Apache License 2.0 | 6 votes |
@Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { final View topChild = view.getChildAt(0); int firstViewTop = 0; if (topChild != null) { firstViewTop = topChild.getTop(); } boolean goingDown; boolean changed = true; if (mPrevPosition == firstVisibleItem) { final int topDelta = mPrevTop - firstViewTop; goingDown = firstViewTop < mPrevTop; changed = Math.abs(topDelta) > DIRECTION_CHANGE_THRESHOLD; } else { goingDown = firstVisibleItem > mPrevPosition; } if (changed && mUpdated) { if (mFloatingView != null) mFloatingView.hide(goingDown); } mPrevPosition = firstVisibleItem; mPrevTop = firstViewTop; mUpdated = true; }
Example 5
Source File: CustomListFragment.java From SmileEssence with MIT License | 5 votes |
@Override public void onScrollStateChanged(AbsListView absListView, int scrollState) { Bundle args = getArguments(); fragmentIndex = args.getInt(ADAPTER_INDEX); CustomListAdapter<?> adapter = getListAdapter(fragmentIndex); adapter.setNotifiable(false); if (absListView.getFirstVisiblePosition() == 0 && absListView.getChildAt(0) != null && absListView.getChildAt(0).getTop() == 0) { if (scrollState == SCROLL_STATE_IDLE) { updateListViewWithNotice(absListView, adapter, true); } } }
Example 6
Source File: DayPickerView.java From MaterialDateRangePicker with Apache License 2.0 | 5 votes |
/** * Updates the title and selected month if the view has moved to a new * month. */ @Override public void onScroll( AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { MonthView child = (MonthView) view.getChildAt(0); if (child == null) { return; } // Figure out where we are long currScroll = view.getFirstVisiblePosition() * child.getHeight() - child.getBottom(); mPreviousScrollPosition = currScroll; mPreviousScrollState = mCurrentScrollState; }
Example 7
Source File: DayPickerView.java From UltimateAndroid with Apache License 2.0 | 5 votes |
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { SimpleMonthView child = (SimpleMonthView) view.getChildAt(0); if (child == null) { return; } long currScroll = view.getFirstVisiblePosition() * child.getHeight() - child.getBottom(); mPreviousScrollPosition = currScroll; mPreviousScrollState = mCurrentScrollState; }
Example 8
Source File: ContextualUndoAdapter.java From android-open-project-demo with Apache License 2.0 | 5 votes |
/** * Animate the item at given position away and show the undo {@link View}. * @param position the position. */ public void swipeViewAtPosition(final int position) { mCurrentRemovedId = getItemId(position); for (int i = 0; i < getAbsListView().getChildCount(); i++) { AbsListView absListView = getAbsListView(); View childView = absListView.getChildAt(i); int positionForView = AdapterViewUtil.getPositionForView(absListView, childView); if (positionForView == position) { swipeView(childView, positionForView); } } }
Example 9
Source File: AbsListViewDelegate.java From Bitocle with Apache License 2.0 | 5 votes |
@Override public boolean isReadyForPull(View view, final float x, final float y) { boolean ready = false; // First we check whether we're scrolled to the top AbsListView absListView = (AbsListView) view; if (absListView.getCount() == 0) { ready = true; } else if (absListView.getFirstVisiblePosition() == 0) { final View firstVisibleChild = absListView.getChildAt(0); ready = firstVisibleChild != null && firstVisibleChild.getTop() >= absListView.getPaddingTop(); } // Then we have to check whether the fas scroller is enabled, and check we're not starting // the gesture from the scroller if (ready && absListView.isFastScrollEnabled() && isFastScrollAlwaysVisible(absListView)) { switch (getVerticalScrollbarPosition(absListView)) { case View.SCROLLBAR_POSITION_RIGHT: ready = x < absListView.getRight() - absListView.getVerticalScrollbarWidth(); break; case View.SCROLLBAR_POSITION_LEFT: ready = x > absListView.getVerticalScrollbarWidth(); break; } } return ready; }
Example 10
Source File: DatePicker.java From material with Apache License 2.0 | 5 votes |
@Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { MonthView child = (MonthView) view.getChildAt(0); if (child == null) return; // Figure out where we are mPreviousScrollPosition = getFirstVisiblePosition() * child.getHeight() - child.getBottom(); mPreviousScrollState = mCurrentScrollState; }
Example 11
Source File: AAbsListView.java From robotium-sandwich with Apache License 2.0 | 5 votes |
@Override public IAView getItemAt(int line) { View view = getAndWaitForView(); AbsListView listView = (AbsListView)view; if (listView.getCount()>line){ View child= listView.getChildAt(line); AView childAView = new AView(); childAView.initialize(child, mScreen,MessageFormat.format("{0}.{1}{2}", mName,"Item",line)); return childAView; } return null; }
Example 12
Source File: DayPickerView.java From Conquer with Apache License 2.0 | 5 votes |
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { SimpleMonthView child = (SimpleMonthView) view.getChildAt(0); if (child == null) { return; } // Figure out where we are long currScroll = view.getFirstVisiblePosition() * child.getHeight() - child.getBottom(); mPreviousScrollPosition = currScroll; mPreviousScrollState = mCurrentScrollState; }
Example 13
Source File: ListScrollDistanceCalculator.java From KUAS-AP-Material with MIT License | 5 votes |
@Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (totalItemCount == 0 || !mListScrollStarted) { return; } final View firstChild = view.getChildAt(0); final int firstVisibleTop = firstChild.getTop(), firstVisibleBottom = firstChild.getBottom(); final int firstVisibleHeight = firstChild.getHeight(); final int delta; if (firstVisibleItem > mFirstVisibleItem) { mFirstVisibleTop += mFirstVisibleHeight; delta = firstVisibleTop - mFirstVisibleTop; } else if (firstVisibleItem < mFirstVisibleItem) { mFirstVisibleBottom -= mFirstVisibleHeight; delta = firstVisibleBottom - mFirstVisibleBottom; } else { delta = firstVisibleBottom - mFirstVisibleBottom; } mTotalScrollDistance += delta; if (mScrollDistanceListener != null) { mScrollDistanceListener.onScrollDistanceChanged(delta, mTotalScrollDistance); } mFirstVisibleTop = firstVisibleTop; mFirstVisibleBottom = firstVisibleBottom; mFirstVisibleHeight = firstVisibleHeight; mFirstVisibleItem = firstVisibleItem; }
Example 14
Source File: StatusScrollListener.java From YiBo with Apache License 2.0 | 5 votes |
private void displayImage(AbsListView listView) { int firstPos = listView.getFirstVisiblePosition(); int lastPos = listView.getLastVisiblePosition(); int totalCount = lastPos - firstPos + 1; Log.v(TAG, "滚动停止加载图片.."); for (int i = 0; i < totalCount; i++) { View view = listView.getChildAt(i); Object tag = view.getTag(); if (!(tag instanceof StatusHolder)) { continue; } StatusHolder holder = (StatusHolder)view.getTag(); ImageLoad4ThumbnailTask thumbnailTask = holder.thumbnailTask; if (thumbnailTask != null && thumbnailTask.isCancelled() == false && thumbnailTask.getStatus() == Status.PENDING) { thumbnailTask.execute(); } QueryResponseCountTask responseCountTask = holder.responseCountTask; if (responseCountTask != null && responseCountTask.isCancelled() == false && responseCountTask.getStatus() == Status.PENDING) { responseCountTask.execute(); } } }
Example 15
Source File: DayPickerView.java From narrate-android with Apache License 2.0 | 5 votes |
/** * Updates the title and selected month if the view has moved to a new * month. */ @Override public void onScroll( AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { MonthView child = (MonthView) view.getChildAt(0); if (child == null) { return; } // Figure out where we are long currScroll = view.getFirstVisiblePosition() * child.getHeight() - child.getBottom(); mPreviousScrollPosition = currScroll; mPreviousScrollState = mCurrentScrollState; }
Example 16
Source File: ConversationFragment.java From Pix-Art-Messenger with GNU General Public License v3.0 | 5 votes |
private static boolean scrolledToBottom(AbsListView listView) { final int count = listView.getCount(); if (count == 0) { return true; } else if (listView.getLastVisiblePosition() == count - 1) { final View lastChild = listView.getChildAt(listView.getChildCount() - 1); return lastChild != null && lastChild.getBottom() <= listView.getHeight(); } else { return false; } }
Example 17
Source File: FadingActionBarHelperBase.java From ALLGO with Apache License 2.0 | 5 votes |
@Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { View topChild = view.getChildAt(0); if (topChild == null) { onNewScroll(0); } else if (topChild != mMarginView) { onNewScroll(mHeaderContainer.getHeight()); } else { onNewScroll(-topChild.getTop()); } }
Example 18
Source File: DialogRootView.java From AndroidMaterialDialog with Apache License 2.0 | 5 votes |
/** * Returns, whether a specific list view is scrolled to the top, or not. * * @param listView The list view as an instance of the class {@link AbsListView}. The list view may not * be null * @return True, if the given list view is scrolled to the top, false otherwise */ private boolean isListViewScrolledToTop(@NonNull final AbsListView listView) { if (listView.getFirstVisiblePosition() == 0) { if (listView.getChildCount() == 0) { return true; } else { View child = listView.getChildAt(0); return child == null || child.getTop() == 0; } } return false; }
Example 19
Source File: QuickReturnUtils.java From QuickReturn with Apache License 2.0 | 5 votes |
public static int getScrollY(AbsListView lv) { View c = lv.getChildAt(0); if (c == null) { return 0; } int firstVisiblePosition = lv.getFirstVisiblePosition(); int scrollY = -(c.getTop()); // int scrollY = 0; sListViewItemHeights.put(lv.getFirstVisiblePosition(), c.getHeight()); // if(scrollY>0) // Log.d("QuickReturnUtils", "getScrollY() : -(c.getTop()) - "+ -(c.getTop())); // else // Log.i("QuickReturnUtils", "getScrollY() : -(c.getTop()) - "+ -(c.getTop())); if (scrollY < 0) scrollY = 0; for (int i = 0; i < firstVisiblePosition; ++i) { // Log.d("QuickReturnUtils", "getScrollY() : i - "+i); // Log.d("QuickReturnUtils", "getScrollY() : sListViewItemHeights.get(i) - "+sListViewItemHeights.get(i)); if (sListViewItemHeights.get(i) != null) // (this is a sanity check) scrollY += sListViewItemHeights.get(i); //add all heights of the views that are gone } // Log.d("QuickReturnUtils", "getScrollY() : scrollY - "+scrollY); return scrollY; }
Example 20
Source File: DayPickerView.java From PersianDateRangePicker with Apache License 2.0 | 5 votes |
/** * Updates the title and selected month if the view has moved to a new * month. */ @Override public void onScroll( AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { MonthView child = (MonthView) view.getChildAt(0); if (child == null) { return; } // Figure out where we are long currScroll = view.getFirstVisiblePosition() * child.getHeight() - child.getBottom(); mPreviousScrollPosition = currScroll; mPreviousScrollState = mCurrentScrollState; }