List of usage examples for android.view View getRight
@ViewDebug.CapturedViewProperty public final int getRight()
From source file:com.lovely3x.eavlibrary.EasyAdapterView.java
/** * ???leftright/*from w ww .ja va 2 s .c o m*/ * * @param offset ?????? */ public void offsetChildrenLeftAndRight(int offset) { if (DEBUG) Log.i(TAG, "OffsetChildrenLeftAndRight => " + offset); final int count = getChildCount(); for (int i = 0; i < count; i++) { final View v = getChildAt(i); v.setLeft(v.getLeft() + offset); v.setRight(v.getRight() + offset); } invalidate(); }
From source file:com.lovely3x.eavlibrary.EasyAdapterView.java
protected void drawDivider(Canvas canvas) { if (mDivider == null || mDividerHeight == 0) return;// w ww . j a va2 s . c om final int N = getChildCount(); final Rect bounds = mTempRect; switch (mLayoutDirectly) { case LAYOUT_DIRECTLY_HORIZONTAL: { if (N > 1) { bounds.top = 0; bounds.bottom = getBottom() - getTop(); for (int i = 0; i < N; i++) { final View child = getChildAt(i); int right = child.getRight(); final boolean isLastItem = (i == (N - 1)); final int listRight = getRight(); if ((right < listRight) && !isLastItem) { bounds.left = right; bounds.right = right + mDividerHeight; drawDivider(canvas, bounds); } } } } break; case LAYOUT_DIRECTLY_VERTICAL: { if (N > 1) { bounds.left = 0; bounds.right = getRight() - getLeft(); for (int i = 0; i < N; i++) { final View child = getChildAt(i); int bottom = child.getBottom(); final boolean isLastItem = (i == (N - 1)); final int listBottom = getBottom(); if ((bottom < listBottom) && !isLastItem) { bounds.top = bottom; bounds.bottom = bottom + mDividerHeight; drawDivider(canvas, bounds); } } } } break; } }
From source file:com.lovely3x.eavlibrary.EasyAdapterView.java
/** * ??????/*from w w w. j av a 2 s. c o m*/ * * @param pos * @param xOffset */ protected void fillRightSpecView(int pos, int xOffset) { View temp = makeAndAddView(pos, 0, xOffset, StuffMode.flowRight); mFirstPosition = pos; fillRightView(pos + 1, temp.getRight() + mDividerHeight, 0); }
From source file:com.lovely3x.eavlibrary.EasyAdapterView.java
/** * ListView?/* www .j a va 2 s. c o m*/ * * @param childCount */ protected void correctTooLeftForListView(int childCount) { //,???? //??? //?? //??? if (mFirstPosition == 0 && childCount > 0) { // ? final View firstChild = getChildAt(0); //? final int firstLeft = firstChild.getLeft(); //? final int start = getLeft(); //? final int end = (getRight() - getLeft()); //? int startOffset = firstLeft - start; View lastChild = getChildAt(childCount - 1); final int lastRight = lastChild.getRight(); int lastPosition = mFirstPosition + childCount - 1; // Make sure we are 1) Too low, and 2) Either there are more rows below the // last row or the last row is scrolled off the bottom of the drawable area if (startOffset > 0) { if (lastPosition < mItemCount - 1 || lastRight > end) { if (lastPosition == mItemCount - 1) { // Don't pull the bottom too far up startOffset = Math.min(startOffset, lastRight - end); } //??? offsetChildrenLeftAndRight(-startOffset); // startScrollIfNeed(-startOffset, 0); if (lastPosition < mItemCount - 1) { // Fill the gap that was opened below the last position with more rows, if // possible fillRightView(lastPosition + 1, lastChild.getRight() + mDividerHeight, 0); // Close up the remaining gap adjustViewsUpOrDown(); } } else if (lastPosition == mItemCount - 1) { adjustViewsUpOrDown(); } } } }
From source file:com.lovely3x.eavlibrary.EasyAdapterView.java
/** * WheelView?/*w w w. j a v a 2 s. co m*/ * * @param childCount */ protected void correctTooLeftForWheelView(int childCount) { //,???? //??? //?? //??? if (mFirstPosition == 0 && childCount > 0) { // ? final View firstChild = getChildAt(0); //? final int firstLeft = firstChild.getLeft(); //? final int start = getLeft() + getXSel(); //? final int end = (getRight() - getLeft()); //? int startOffset = firstLeft - start; View lastChild = getChildAt(childCount - 1); final int lastRight = lastChild.getRight(); int lastPosition = mFirstPosition + childCount - 1; // Make sure we are 1) Too low, and 2) Either there are more rows below the // last row or the last row is scrolled off the bottom of the drawable area if (startOffset > 0) { if (lastPosition < mItemCount - 1 || lastRight > end) { if (lastPosition == mItemCount - 1) { // Don't pull the bottom too far up startOffset = Math.min(startOffset, lastRight - end); } offsetChildrenLeftAndRight(-startOffset); //?? // startScrollIfNeed(-startOffset, 0); if (lastPosition < mItemCount - 1) { // Fill the gap that was opened below the last position with more rows, if // possible fillRightView(lastPosition + 1, lastChild.getRight() + mDividerHeight, 0); // Close up the remaining gap adjustViewsUpOrDown(); } } else if (lastPosition == mItemCount - 1) { adjustViewsUpOrDown(); } } } }
From source file:com.lovely3x.eavlibrary.EasyAdapterView.java
/** * ??/* www. j ava2 s.co m*/ * * @param offsetScreenNum * @param pos * @param nextLeft ? */ protected void fillRightView(int pos, int nextLeft, int offsetScreenNum) { switch (mViewMode) { case LIST_VIEW: case WHEEL_VIEW: {//? while (nextLeft < (getRight() - getLeft() + mDividerHeight) && pos < mItemCount) { View topView = makeAndAddView(pos, 0, nextLeft, StuffMode.flowRight); nextLeft = topView.getRight() + mDividerHeight; pos++; } mFirstPosition += offsetScreenNum; } break; case END_LESS_LIST_VIEW: case ENDLESS_WHEEL_VIEW: {//? //?,??? if (pos >= mItemCount) { pos = pos % mItemCount; } while (nextLeft < (getRight() - getLeft() + mDividerHeight) && mItemCount > 0 /*&& pos < mItemCount*/) { if (DEBUG) Log.d(TAG, "Fill right => " + pos); View topView = makeAndAddView(pos, 0, nextLeft, StuffMode.flowRight); nextLeft = topView.getRight() + mDividerHeight; pos++; if (pos >= mItemCount) { if (DEBUG) Log.d(TAG, String.format(Locale.US, "Fill right pos[%d] >= ItemCount[%d] re-pos = [%d]", pos, mItemCount, pos - mItemCount)); pos = pos - mItemCount; } } mFirstPosition += offsetScreenNum; mFirstPosition %= mItemCount; } break; } }
From source file:com.appunite.list.HorizontalListView.java
/** * Make sure views are touching the top or bottom edge, as appropriate for * our gravity/*from w w w. j a v a 2 s . c om*/ */ private void adjustViewsLeftOrRight() { final int childCount = getChildCount(); int delta; if (childCount > 0) { View child; if (!mStackFromRight) { // Uh-oh -- we came up short. Slide all views up to make them // align with the top child = getChildAt(0); delta = child.getLeft() - mListPadding.left; if (mFirstPosition != 0) { // It's OK to have some space above the first item if it is // part of the vertical spacing delta -= mDividerWidth; } if (delta < 0) { // We only are looking to see if we are too low, not too high delta = 0; } } else { // we are too high, slide all views down to align with bottom child = getChildAt(childCount - 1); delta = child.getRight() - (getWidth() - mListPadding.right); if (mFirstPosition + childCount < mItemCount) { // It's OK to have some space below the last item if it is // part of the vertical spacing delta += mDividerWidth; } if (delta > 0) { delta = 0; } } if (delta != 0) { offsetChildrenLeftAndRightUnhide(-delta); } } }
From source file:com.awrtechnologies.carbudgetsales.hlistview.widget.HListView.java
/** * Make sure views are touching the top or bottom edge, as appropriate for our gravity *///from w ww . jav a 2 s.c o m private void adjustViewsLeftOrRight() { final int childCount = getChildCount(); int delta; if (childCount > 0) { View child; if (!mStackFromRight) { // Uh-oh -- we came up short. Slide all views up to make them // align with the top child = getChildAt(0); delta = child.getLeft() - mListPadding.left; if (mFirstPosition != 0) { // It's OK to have some space above the first item if it is // part of the vertical spacing delta -= mDividerWidth; } if (delta < 0) { // We only are looking to see if we are too low, not too high delta = 0; } } else { // we are too high, slide all views down to align with bottom child = getChildAt(childCount - 1); delta = child.getRight() - (getWidth() - mListPadding.right); if (mFirstPosition + childCount < mItemCount) { // It's OK to have some space below the last item if it is // part of the vertical spacing delta += mDividerWidth; } if (delta > 0) { delta = 0; } } if (delta != 0) { offsetChildrenLeftAndRight(-delta); } } }
From source file:com.lovely3x.eavlibrary.EasyAdapterView.java
public int getSelectedViewPosition() { switch (mViewMode) { case END_LESS_LIST_VIEW: case LIST_VIEW: {//ListView ? return 0; }//from ww w . ja v a2s .c o m case ENDLESS_WHEEL_VIEW: case WHEEL_VIEW: {//? switch (mLayoutDirectly) { case LAYOUT_DIRECTLY_HORIZONTAL: {//? final int N = getChildCount(); final int xSel = getXSel(); for (int i = 0; i < N; i++) { View child = getChildAt(i); //// TODO: 16/8/6 May have bugs. if (child.getLeft() <= xSel && child.getRight() >= xSel) { if (DEBUG) Log.i(TAG, "Current Selected position, on divider => " + i); return i; } else if (child.getTop() <= xSel && child.getRight() + mDividerHeight >= xSel) { if (DEBUG) Log.i(TAG, "Current Selected position, on divider => " + i); return i; } // TODO: 16/8/18 } } break; case LAYOUT_DIRECTLY_VERTICAL: {//? final int N = getChildCount(); final int ySel = getYSel(); for (int i = 0; i < N; i++) { View child = getChildAt(i); //// TODO: 16/8/6 May have bugs. if (child.getTop() <= ySel && child.getBottom() >= ySel) { if (DEBUG) Log.i(TAG, "Current Selected position => " + i); return i; } else if (child.getTop() <= ySel && child.getBottom() + mDividerHeight >= ySel) { if (DEBUG) Log.i(TAG, "Current Selected position, on divider => " + i); return i; } } } break; } } break; } return INVALID_POSITION; }
From source file:com.lovely3x.eavlibrary.EasyAdapterView.java
/** * ListView??//from w w w . ja v a2s. co m * * @param childCount */ protected void correctTooRightForListView(int childCount) { //???? //???,?? int lastPosition = mFirstPosition + childCount - 1; //??,? if (lastPosition == mItemCount - 1 && childCount > 0) { //??? final View lastChild = getChildAt(childCount - 1); //???? final int lastRight = lastChild.getRight(); //? final int end = getRight() - getLeft(); //??? int rightOffset = end - lastRight; //?? View firstChild = getChildAt(0); //?? final int firstLeft = firstChild.getLeft(); //1) ? "" //2) ?? //? if (rightOffset > 0 && (mFirstPosition > 0 || firstLeft < getLeft())) { if (mFirstPosition == 0) { //?? rightOffset = Math.min(rightOffset, getLeft() - firstLeft); } // ??? offsetChildrenLeftAndRight(rightOffset); // startScrollIfNeed(rightOffset, 0); if (mFirstPosition > 0) { //? fillRightView(lastPosition + 1, lastChild.getRight() + mDividerHeight, 0); if (firstChild.getLeft() > getLeft()) {//Need fill left views. fillLeftView(mFirstPosition - 1, firstChild.getLeft() + mDividerHeight); } //mFirstPosition - 1, firstChild.getLeft() - mDividerHeight // adjustViewsUpOrDown(); } } } }