mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-12-05 05:37:53 +08:00
remove math functions' calling from constexpr
This commit is contained in:
parent
ca44726d5e
commit
aaa61f11a7
@ -86,8 +86,8 @@ private:
|
|||||||
static constexpr float EPSILON = 0.001f;
|
static constexpr float EPSILON = 0.001f;
|
||||||
|
|
||||||
static constexpr double ANGLE = M_PI / 6.f;
|
static constexpr double ANGLE = M_PI / 6.f;
|
||||||
static constexpr float SIN = (float) std::sin(ANGLE);
|
static constexpr float SIN = 0.5f/*(float) std::sin(ANGLE)*/;
|
||||||
static constexpr float COS = (float) std::cos(ANGLE);
|
static constexpr float COS = 0.86602540378f/*(float) std::cos(ANGLE)*/;
|
||||||
static constexpr float RADIUS_FACTOR = 0.6f;
|
static constexpr float RADIUS_FACTOR = 0.6f;
|
||||||
float mGlowAlpha;
|
float mGlowAlpha;
|
||||||
float mGlowScaleY;
|
float mGlowScaleY;
|
||||||
|
@ -108,10 +108,10 @@ int GridView::lookForSelectablePosition(int position, bool lookDown) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GridView::fillGap(bool down) {
|
void GridView::fillGap(bool down) {
|
||||||
int numColumns = mNumColumns;
|
const int numColumns = mNumColumns;
|
||||||
int verticalSpacing = mVerticalSpacing;
|
const int verticalSpacing = mVerticalSpacing;
|
||||||
|
|
||||||
int count = getChildCount();
|
const int count = getChildCount();
|
||||||
|
|
||||||
if (down) {
|
if (down) {
|
||||||
int paddingTop = 0;
|
int paddingTop = 0;
|
||||||
@ -145,12 +145,12 @@ void GridView::fillGap(bool down) {
|
|||||||
View* GridView::fillDown(int pos, int nextTop) {
|
View* GridView::fillDown(int pos, int nextTop) {
|
||||||
View* selectedView = nullptr;
|
View* selectedView = nullptr;
|
||||||
|
|
||||||
int end = (mBottom - mTop);
|
int listEnd = (mBottom - mTop);
|
||||||
if ((mGroupFlags & CLIP_TO_PADDING_MASK) == CLIP_TO_PADDING_MASK) {
|
if ((mGroupFlags & CLIP_TO_PADDING_MASK) == CLIP_TO_PADDING_MASK) {
|
||||||
end -= mListPadding.height;
|
listEnd -= mListPadding.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (nextTop < end && pos < mItemCount) {
|
while (nextTop < listEnd && pos < mItemCount) {
|
||||||
View* temp = makeRow(pos, nextTop, true);
|
View* temp = makeRow(pos, nextTop, true);
|
||||||
if (temp != nullptr) {
|
if (temp != nullptr) {
|
||||||
selectedView = temp;
|
selectedView = temp;
|
||||||
|
@ -63,9 +63,9 @@ int ListView::getMaxScrollAmount()const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ListView::adjustViewsUpOrDown() {
|
void ListView::adjustViewsUpOrDown() {
|
||||||
int delta;
|
int delta = 0;
|
||||||
int childCount=getChildCount();
|
const int childCount = getChildCount();
|
||||||
if (childCount > 0) {
|
if (childCount == 0)return;
|
||||||
|
|
||||||
if (!mStackFromBottom) {
|
if (!mStackFromBottom) {
|
||||||
// Uh-oh -- we came up short. Slide all views up to make them
|
// Uh-oh -- we came up short. Slide all views up to make them
|
||||||
@ -97,7 +97,6 @@ void ListView::adjustViewsUpOrDown() {
|
|||||||
|
|
||||||
if (delta != 0) offsetChildrenTopAndBottom(-delta);
|
if (delta != 0) offsetChildrenTopAndBottom(-delta);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void ListView::addHeaderView(View* v,void* data, bool isSelectable) {
|
void ListView::addHeaderView(View* v,void* data, bool isSelectable) {
|
||||||
if (v->getParent() != nullptr && v->getParent() != this) {
|
if (v->getParent() != nullptr && v->getParent() != this) {
|
||||||
@ -296,10 +295,10 @@ bool ListView::requestChildRectangleOnScreen(View* child, Rect& rect, bool immed
|
|||||||
rect.offset(child->getLeft(), child->getTop());
|
rect.offset(child->getLeft(), child->getTop());
|
||||||
rect.offset(-child->getScrollX(), -child->getScrollY());
|
rect.offset(-child->getScrollX(), -child->getScrollY());
|
||||||
|
|
||||||
int height = getHeight();
|
const int height = getHeight();
|
||||||
int listUnfadedTop = getScrollY();
|
int listUnfadedTop = getScrollY();
|
||||||
int listUnfadedBottom = listUnfadedTop + height;
|
int listUnfadedBottom = listUnfadedTop + height;
|
||||||
int fadingEdge = getVerticalFadingEdgeLength();
|
const int fadingEdge = getVerticalFadingEdgeLength();
|
||||||
|
|
||||||
if (showingTopFadingEdge()) {
|
if (showingTopFadingEdge()) {
|
||||||
// leave room for top fading edge as long as rect isn't at very top
|
// leave room for top fading edge as long as rect isn't at very top
|
||||||
@ -351,12 +350,12 @@ bool ListView::requestChildRectangleOnScreen(View* child, Rect& rect, bool immed
|
|||||||
}
|
}
|
||||||
|
|
||||||
// make sure we aren't scrolling any further than the top our children
|
// make sure we aren't scrolling any further than the top our children
|
||||||
int top = getChildAt(0)->getTop();
|
const int top = getChildAt(0)->getTop();
|
||||||
int deltaToTop = top - listUnfadedTop;
|
const int deltaToTop = top - listUnfadedTop;
|
||||||
scrollYDelta = std::max(scrollYDelta, deltaToTop);
|
scrollYDelta = std::max(scrollYDelta, deltaToTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool scroll = scrollYDelta != 0;
|
const bool scroll = scrollYDelta != 0;
|
||||||
if (scroll) {
|
if (scroll) {
|
||||||
scrollListItemsBy(-scrollYDelta);
|
scrollListItemsBy(-scrollYDelta);
|
||||||
positionSelector(INVALID_POSITION, child);
|
positionSelector(INVALID_POSITION, child);
|
||||||
@ -373,7 +372,7 @@ void ListView::fillGap(bool down) {
|
|||||||
if ((mGroupFlags & CLIP_TO_PADDING_MASK) == CLIP_TO_PADDING_MASK) {
|
if ((mGroupFlags & CLIP_TO_PADDING_MASK) == CLIP_TO_PADDING_MASK) {
|
||||||
paddingTop = getListPaddingTop();
|
paddingTop = getListPaddingTop();
|
||||||
}
|
}
|
||||||
int startOffset = count > 0 ? getChildAt(count - 1)->getBottom() + mDividerHeight :paddingTop;
|
const int startOffset = count > 0 ? getChildAt(count - 1)->getBottom() + mDividerHeight :paddingTop;
|
||||||
fillDown(mFirstPosition + count, startOffset);
|
fillDown(mFirstPosition + count, startOffset);
|
||||||
correctTooHigh(getChildCount());
|
correctTooHigh(getChildCount());
|
||||||
} else {
|
} else {
|
||||||
@ -390,17 +389,19 @@ void ListView::fillGap(bool down) {
|
|||||||
View* ListView::fillDown(int pos, int nextTop) {
|
View* ListView::fillDown(int pos, int nextTop) {
|
||||||
View* selectedView = nullptr;
|
View* selectedView = nullptr;
|
||||||
|
|
||||||
int end = (mBottom - mTop);
|
int listEnd = getHeight();
|
||||||
if ((mGroupFlags & CLIP_TO_PADDING_MASK) == CLIP_TO_PADDING_MASK) {
|
if ((mGroupFlags & CLIP_TO_PADDING_MASK) == CLIP_TO_PADDING_MASK) {
|
||||||
end -= mListPadding.height;
|
listEnd -= mListPadding.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (nextTop < end && pos < mItemCount) {
|
while (nextTop < listEnd && pos < mItemCount) {
|
||||||
// is this the selected item?
|
// is this the selected item?
|
||||||
bool selected = pos == mSelectedPosition;
|
bool selected = pos == mSelectedPosition;
|
||||||
View* child = makeAndAddView(pos, nextTop, true, mListPadding.left, selected);
|
View* child = makeAndAddView(pos, nextTop, true, mListPadding.left, selected);
|
||||||
|
|
||||||
nextTop = child->getBottom() + mDividerHeight;
|
nextTop = child->getBottom() + mDividerHeight;
|
||||||
|
LOGV("[%d]%p:%d pos=(%d,%d) nextStart=%d end=%d size=%dx%d listsize=%dx%d",pos,child,child->getId(),
|
||||||
|
child->getLeft(),child->getBottom(),nextTop,listEnd,
|
||||||
|
child->getWidth(),child->getHeight(),getWidth(),getHeight());
|
||||||
if (selected) {
|
if (selected) {
|
||||||
selectedView = child;
|
selectedView = child;
|
||||||
}
|
}
|
||||||
@ -444,9 +445,9 @@ View* ListView::fillFromTop(int nextTop) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
View* ListView::fillFromMiddle(int childrenTop, int childrenBottom) {
|
View* ListView::fillFromMiddle(int childrenTop, int childrenBottom) {
|
||||||
int height = childrenBottom - childrenTop;
|
const int height = childrenBottom - childrenTop;
|
||||||
|
|
||||||
int position = reconcileSelectedPosition();
|
const int position = reconcileSelectedPosition();
|
||||||
|
|
||||||
View* sel = makeAndAddView(position, childrenTop, true,mListPadding.left, true);
|
View* sel = makeAndAddView(position, childrenTop, true,mListPadding.left, true);
|
||||||
mFirstPosition = position;
|
mFirstPosition = position;
|
||||||
@ -479,7 +480,7 @@ void ListView::fillAboveAndBelow(View* sel, int position) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
View* ListView::fillFromSelection(int selectedTop, int childrenTop, int childrenBottom) {
|
View* ListView::fillFromSelection(int selectedTop, int childrenTop, int childrenBottom) {
|
||||||
int fadingEdgeLength = getVerticalFadingEdgeLength();
|
const int fadingEdgeLength = getVerticalFadingEdgeLength();
|
||||||
int selectedPosition = mSelectedPosition;
|
int selectedPosition = mSelectedPosition;
|
||||||
|
|
||||||
int topSelectionPixel = getTopSelectionPixel(childrenTop, fadingEdgeLength,selectedPosition);
|
int topSelectionPixel = getTopSelectionPixel(childrenTop, fadingEdgeLength,selectedPosition);
|
||||||
@ -542,7 +543,7 @@ int ListView::getTopSelectionPixel(int childrenTop, int fadingEdgeLength, int se
|
|||||||
}
|
}
|
||||||
|
|
||||||
View* ListView::moveSelection(View* oldSel, View* newSel, int delta, int childrenTop, int childrenBottom){
|
View* ListView::moveSelection(View* oldSel, View* newSel, int delta, int childrenTop, int childrenBottom){
|
||||||
int fadingEdgeLength = getVerticalFadingEdgeLength();
|
const int fadingEdgeLength = getVerticalFadingEdgeLength();
|
||||||
int selectedPosition = mSelectedPosition;
|
int selectedPosition = mSelectedPosition;
|
||||||
|
|
||||||
View* sel;
|
View* sel;
|
||||||
@ -570,7 +571,6 @@ View* ListView::moveSelection(View* oldSel, View* newSel, int delta, int childre
|
|||||||
oldSel = makeAndAddView(selectedPosition - 1, oldSel->getTop(), true, mListPadding.left, false);
|
oldSel = makeAndAddView(selectedPosition - 1, oldSel->getTop(), true, mListPadding.left, false);
|
||||||
|
|
||||||
int dividerHeight = mDividerHeight;
|
int dividerHeight = mDividerHeight;
|
||||||
|
|
||||||
// Now put the new selection (B) below that
|
// Now put the new selection (B) below that
|
||||||
sel = makeAndAddView(selectedPosition, oldSel->getBottom() + dividerHeight, true, mListPadding.left, true);
|
sel = makeAndAddView(selectedPosition, oldSel->getBottom() + dividerHeight, true, mListPadding.left, true);
|
||||||
|
|
||||||
@ -799,11 +799,10 @@ void ListView::measureScrapChild(View* child, int position, int widthMeasureSpec
|
|||||||
p->viewType = mAdapter->getItemViewType(position);
|
p->viewType = mAdapter->getItemViewType(position);
|
||||||
p->isEnabled = mAdapter->isEnabled(position);
|
p->isEnabled = mAdapter->isEnabled(position);
|
||||||
p->forceAdd = true;
|
p->forceAdd = true;
|
||||||
|
int childWidthSpec,childHeightSpec;
|
||||||
int childWidthSpec = ViewGroup::getChildMeasureSpec(widthMeasureSpec,
|
childWidthSpec = getChildMeasureSpec(widthMeasureSpec,
|
||||||
mListPadding.left + mListPadding.width, p->width);
|
mListPadding.left + mListPadding.width, p->width);
|
||||||
int lpHeight = p->height;
|
const int lpHeight = p->height;
|
||||||
int childHeightSpec;
|
|
||||||
if (lpHeight > 0) {
|
if (lpHeight > 0) {
|
||||||
childHeightSpec = MeasureSpec::makeMeasureSpec(lpHeight, MeasureSpec::EXACTLY);
|
childHeightSpec = MeasureSpec::makeMeasureSpec(lpHeight, MeasureSpec::EXACTLY);
|
||||||
} else {
|
} else {
|
||||||
@ -938,23 +937,19 @@ View* ListView::fillSpecific(int position, int top) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ListView::correctTooHigh(int childCount) {
|
void ListView::correctTooHigh(int childCount) {
|
||||||
int lastPosition = mFirstPosition + childCount - 1;
|
const int lastPosition = mFirstPosition + childCount - 1;
|
||||||
if (lastPosition == mItemCount - 1 && childCount > 0) {
|
if (lastPosition == mItemCount - 1 && childCount > 0) {
|
||||||
|
|
||||||
// Get the last child ...
|
// Get the last child ...
|
||||||
const View* lastChild = getChildAt(childCount - 1);
|
const View* last = getChildAt(childCount - 1);
|
||||||
|
|
||||||
// ... and its bottom edge
|
// ... and its bottom edge
|
||||||
const int lastBottom = lastChild->getBottom();
|
const int lastBottom = last->getBottom();
|
||||||
|
|
||||||
// This is bottom of our drawable area
|
// This is bottom of our drawable area
|
||||||
const int end = getHeight()- mListPadding.height;//bottom;
|
const int listEnd = getHeight()- mListPadding.height;
|
||||||
|
|
||||||
// This is how far the bottom edge of the last view is from the bottom of the
|
// This is how far the bottom edge of the last view is from the bottom of the
|
||||||
// drawable area
|
// drawable area
|
||||||
int bottomOffset = end - lastBottom;
|
int bottomOffset = listEnd - lastBottom;
|
||||||
View* firstChild = getChildAt(0);
|
const View* first = getChildAt(0);
|
||||||
const int firstTop = firstChild->getTop();
|
const int firstTop = first->getTop();
|
||||||
|
|
||||||
// Make sure we are 1) Too high, and 2) Either there are more rows above the
|
// Make sure we are 1) Too high, and 2) Either there are more rows above the
|
||||||
// first row or the first row is scrolled off the top of the drawable area
|
// first row or the first row is scrolled off the top of the drawable area
|
||||||
@ -968,7 +963,7 @@ void ListView::correctTooHigh(int childCount) {
|
|||||||
if (mFirstPosition > 0) {
|
if (mFirstPosition > 0) {
|
||||||
// Fill the gap that was opened above mFirstPosition with more rows, if
|
// Fill the gap that was opened above mFirstPosition with more rows, if
|
||||||
// possible
|
// possible
|
||||||
fillUp(mFirstPosition - 1, firstChild->getTop() - mDividerHeight);
|
fillUp(mFirstPosition - 1, first->getTop() - mDividerHeight);
|
||||||
// Close up the remaining gap
|
// Close up the remaining gap
|
||||||
adjustViewsUpOrDown();
|
adjustViewsUpOrDown();
|
||||||
}
|
}
|
||||||
@ -978,41 +973,36 @@ void ListView::correctTooHigh(int childCount) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ListView::correctTooLow(int childCount) {
|
void ListView::correctTooLow(int childCount) {
|
||||||
if (mFirstPosition == 0 && childCount > 0) {
|
if (mFirstPosition != 0 || childCount == 0) return;
|
||||||
|
|
||||||
// Get the first child ...
|
// Get the first child ...
|
||||||
const View* firstChild = getChildAt(0);
|
const View* first = getChildAt(0);
|
||||||
|
|
||||||
// ... and its top edge
|
// ... and its top edge
|
||||||
const int firstTop = firstChild->getTop();
|
const int firstTop = first->getTop();
|
||||||
|
|
||||||
// This is top of our drawable area
|
// This is top of our drawable area
|
||||||
const int start = mListPadding.top;
|
const int listStart = mListPadding.top;
|
||||||
|
|
||||||
// This is bottom of our drawable area
|
// This is bottom of our drawable area
|
||||||
const int end = getHeight()- mListPadding.height;//bottom;
|
const int listEnd = getHeight()- mListPadding.height;
|
||||||
|
|
||||||
// This is how far the top edge of the first view is from the top of the
|
// This is how far the top edge of the first view is from the top of the
|
||||||
// drawable area
|
// drawable area
|
||||||
int topOffset = firstTop - start;
|
int topOffset = firstTop - listStart;
|
||||||
View* lastChild = getChildAt(childCount - 1);
|
const View* last = getChildAt(childCount - 1);
|
||||||
const int lastBottom = lastChild->getBottom();
|
const int lastBottom = last->getBottom();
|
||||||
int lastPosition = mFirstPosition + childCount - 1;
|
const int lastPosition = mFirstPosition + childCount - 1;
|
||||||
|
|
||||||
// Make sure we are 1) Too low, and 2) Either there are more rows below the
|
// 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
|
// last row or the last row is scrolled off the bottom of the drawable area
|
||||||
if (topOffset > 0) {
|
if (topOffset > 0) {
|
||||||
if (lastPosition < mItemCount - 1 || lastBottom > end) {
|
if (lastPosition < mItemCount - 1 || lastBottom > listEnd) {
|
||||||
if (lastPosition == mItemCount - 1) {
|
if (lastPosition == mItemCount - 1) {
|
||||||
// Don't pull the bottom too far up
|
// Don't pull the bottom too far up
|
||||||
topOffset = std::min(topOffset, lastBottom - end);
|
topOffset = std::min(topOffset, lastBottom - listEnd);
|
||||||
}
|
}
|
||||||
// Move everything up
|
// Move everything up
|
||||||
offsetChildrenTopAndBottom(-topOffset);
|
offsetChildrenTopAndBottom(-topOffset);
|
||||||
if (lastPosition < mItemCount - 1) {
|
if (lastPosition < mItemCount - 1) {
|
||||||
// Fill the gap that was opened below the last position with more rows, if
|
// Fill the gap that was opened below the last position with more rows, if
|
||||||
// possible
|
// possible
|
||||||
fillDown(lastPosition + 1, lastChild->getBottom() + mDividerHeight);
|
fillDown(lastPosition + 1, last->getBottom() + mDividerHeight);
|
||||||
// Close up the remaining gap
|
// Close up the remaining gap
|
||||||
adjustViewsUpOrDown();
|
adjustViewsUpOrDown();
|
||||||
}
|
}
|
||||||
@ -1021,7 +1011,6 @@ void ListView::correctTooLow(int childCount) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void ListView::layoutChildren() {
|
void ListView::layoutChildren() {
|
||||||
const bool blockLayoutRequests = mBlockLayoutRequests;
|
const bool blockLayoutRequests = mBlockLayoutRequests;
|
||||||
@ -1481,7 +1470,7 @@ void ListView::setupChild(View* child, int position, int y, bool flowDown, int c
|
|||||||
child->offsetLeftAndRight(childrenLeft - child->getLeft());
|
child->offsetLeftAndRight(childrenLeft - child->getLeft());
|
||||||
child->offsetTopAndBottom(childTop - child->getTop());
|
child->offsetTopAndBottom(childTop - child->getTop());
|
||||||
}
|
}
|
||||||
|
LOGD("%p:%d start=%d size=%dx%d ,pos=%d,%d needmeasure=%d flowDown=%d",child,child->getId(),childrenLeft,w,h, child->getLeft(),child->getTop(),needToMeasure,flowDown);
|
||||||
if (mCachingStarted && !child->isDrawingCacheEnabled())
|
if (mCachingStarted && !child->isDrawingCacheEnabled())
|
||||||
child->setDrawingCacheEnabled(true);
|
child->setDrawingCacheEnabled(true);
|
||||||
}
|
}
|
||||||
@ -1519,29 +1508,28 @@ static int constrain(int amount, int low, int high) {//get the
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ListView::lookForSelectablePositionAfter(int current, int position, bool lookDown) {
|
int ListView::lookForSelectablePositionAfter(int current, int position, bool lookDown) {
|
||||||
Adapter* adapter = mAdapter;
|
if (mAdapter == nullptr || isInTouchMode()) {
|
||||||
if (adapter == nullptr || isInTouchMode()) {
|
|
||||||
return INVALID_POSITION;
|
return INVALID_POSITION;
|
||||||
}
|
}
|
||||||
|
|
||||||
// First check after the starting position in the specified direction.
|
// First check after the starting position in the specified direction.
|
||||||
int after = lookForSelectablePosition(position, lookDown);
|
const int after = lookForSelectablePosition(position, lookDown);
|
||||||
if (after != INVALID_POSITION) {
|
if (after != INVALID_POSITION) {
|
||||||
return after;
|
return after;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then check between the starting position and the current position.
|
// Then check between the starting position and the current position.
|
||||||
int count = adapter->getCount();
|
const int count = mAdapter->getCount();
|
||||||
current = constrain(current, -1, count - 1);
|
current = constrain(current, -1, count - 1);
|
||||||
if (lookDown) {
|
if (lookDown) {
|
||||||
position = std::min(position - 1, count - 1);
|
position = std::min(position - 1, count - 1);
|
||||||
while ((position > current) && !adapter->isEnabled(position)) {
|
while ((position > current) && !mAdapter->isEnabled(position)) {
|
||||||
position--;
|
position--;
|
||||||
}
|
}
|
||||||
if (position <= current) return INVALID_POSITION;
|
if (position <= current) return INVALID_POSITION;
|
||||||
} else {
|
} else {
|
||||||
position = std::max(0, position + 1);
|
position = std::max(0, position + 1);
|
||||||
while ((position < current) && !adapter->isEnabled(position)) {
|
while ((position < current) && !mAdapter->isEnabled(position)) {
|
||||||
position++;
|
position++;
|
||||||
}
|
}
|
||||||
if (position >= current) return INVALID_POSITION;
|
if (position >= current) return INVALID_POSITION;
|
||||||
@ -1956,8 +1944,8 @@ void ListView::handleNewSelectionChange(View* selectedView, int direction, int n
|
|||||||
View* bottomView;
|
View* bottomView;
|
||||||
int topViewIndex, bottomViewIndex;
|
int topViewIndex, bottomViewIndex;
|
||||||
bool topSelected = false;
|
bool topSelected = false;
|
||||||
int selectedIndex = mSelectedPosition - mFirstPosition;
|
const int selectedIndex = mSelectedPosition - mFirstPosition;
|
||||||
int nextSelectedIndex = newSelectedPosition - mFirstPosition;
|
const int nextSelectedIndex = newSelectedPosition - mFirstPosition;
|
||||||
if (direction == View::FOCUS_UP) {
|
if (direction == View::FOCUS_UP) {
|
||||||
topViewIndex = nextSelectedIndex;
|
topViewIndex = nextSelectedIndex;
|
||||||
bottomViewIndex = selectedIndex;
|
bottomViewIndex = selectedIndex;
|
||||||
@ -1971,7 +1959,7 @@ void ListView::handleNewSelectionChange(View* selectedView, int direction, int n
|
|||||||
bottomView = getChildAt(bottomViewIndex);
|
bottomView = getChildAt(bottomViewIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
int numChildren = getChildCount();
|
const int numChildren = getChildCount();
|
||||||
|
|
||||||
// start with top view: is it changing size?
|
// start with top view: is it changing size?
|
||||||
if (topView != nullptr) {
|
if (topView != nullptr) {
|
||||||
@ -2019,13 +2007,11 @@ void ListView::measureItem(View* child) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ListView::relayoutMeasuredItem(View* child) {
|
void ListView::relayoutMeasuredItem(View* child) {
|
||||||
int w = child->getMeasuredWidth();
|
const int w = child->getMeasuredWidth();
|
||||||
int h = child->getMeasuredHeight();
|
const int h = child->getMeasuredHeight();
|
||||||
int childLeft = mListPadding.left;
|
const int childLeft = mListPadding.left;
|
||||||
int childRight = childLeft + w;
|
const int childTop = child->getTop();
|
||||||
int childTop = child->getTop();
|
child->layout(childLeft, childTop, w, h);
|
||||||
int childBottom = childTop + h;
|
|
||||||
child->layout(childLeft, childTop, childRight, childBottom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ListView::getArrowScrollPreviewLength() {
|
int ListView::getArrowScrollPreviewLength() {
|
||||||
@ -2378,12 +2364,12 @@ bool ListView::isOpaque()const {
|
|||||||
if (retValue) {
|
if (retValue) {
|
||||||
// only return true if the list items cover the entire area of the view
|
// only return true if the list items cover the entire area of the view
|
||||||
const int listTop = mListPadding.top;
|
const int listTop = mListPadding.top;
|
||||||
View* first = getChildAt(0);
|
const View* first = getChildAt(0);
|
||||||
if (first == nullptr || first->getTop() > listTop) {
|
if (first == nullptr || first->getTop() > listTop) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int listBottom = getHeight() - mListPadding.height;
|
int listBottom = getHeight() - mListPadding.height;
|
||||||
View* last = getChildAt(getChildCount() - 1);
|
const View* last = getChildAt(getChildCount() - 1);
|
||||||
if (last == nullptr || last->getBottom() < listBottom) {
|
if (last == nullptr || last->getBottom() < listBottom) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -2444,11 +2430,9 @@ void ListView::dispatchDraw(Canvas&canvas) {
|
|||||||
int dividerHeight = mDividerHeight;
|
int dividerHeight = mDividerHeight;
|
||||||
Drawable* overscrollHeader = mOverScrollHeader;
|
Drawable* overscrollHeader = mOverScrollHeader;
|
||||||
Drawable* overscrollFooter = mOverScrollFooter;
|
Drawable* overscrollFooter = mOverScrollFooter;
|
||||||
bool bdrawOverscrollHeader = overscrollHeader != nullptr;
|
|
||||||
bool bdrawOverscrollFooter = overscrollFooter != nullptr;
|
|
||||||
bool drawDividers = dividerHeight > 0 && mDivider != nullptr;
|
bool drawDividers = dividerHeight > 0 && mDivider != nullptr;
|
||||||
|
|
||||||
if (drawDividers || bdrawOverscrollHeader || bdrawOverscrollFooter) {
|
if (drawDividers || mOverScrollHeader || mOverScrollFooter) {
|
||||||
// Only modify the top and bottom in the loop, we set the left and right here
|
// Only modify the top and bottom in the loop, we set the left and right here
|
||||||
Rect bounds;
|
Rect bounds;
|
||||||
bounds.left = mPaddingLeft;
|
bounds.left = mPaddingLeft;
|
||||||
@ -2482,7 +2466,7 @@ void ListView::dispatchDraw(Canvas&canvas) {
|
|||||||
|
|
||||||
// Draw top divider or header for overscroll
|
// Draw top divider or header for overscroll
|
||||||
if (count > 0 && mScrollY < 0) {
|
if (count > 0 && mScrollY < 0) {
|
||||||
if (bdrawOverscrollHeader) {
|
if (mOverScrollHeader) {
|
||||||
bounds.top = 0;
|
bounds.top = 0;
|
||||||
bounds.height = mScrollY;
|
bounds.height = mScrollY;
|
||||||
drawOverscrollHeader(canvas, overscrollHeader, bounds);
|
drawOverscrollHeader(canvas, overscrollHeader, bounds);
|
||||||
@ -2503,7 +2487,7 @@ void ListView::dispatchDraw(Canvas&canvas) {
|
|||||||
bool isLastItem = (i == (count - 1));
|
bool isLastItem = (i == (count - 1));
|
||||||
|
|
||||||
if (drawDividers && (bottom < listBottom)
|
if (drawDividers && (bottom < listBottom)
|
||||||
&& !(bdrawOverscrollFooter && isLastItem)) {
|
&& !(mOverScrollFooter && isLastItem)) {
|
||||||
int nextIndex = (itemIndex + 1);
|
int nextIndex = (itemIndex + 1);
|
||||||
// Draw dividers between enabled items, headers
|
// Draw dividers between enabled items, headers
|
||||||
// and/or footers when enabled and requested, and
|
// and/or footers when enabled and requested, and
|
||||||
@ -2525,7 +2509,7 @@ void ListView::dispatchDraw(Canvas&canvas) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int overFooterBottom = getBottom() + mScrollY;
|
int overFooterBottom = getBottom() + mScrollY;
|
||||||
if (bdrawOverscrollFooter && first + count == itemCount &&
|
if (mOverScrollFooter && first + count == itemCount &&
|
||||||
overFooterBottom > bottom) {
|
overFooterBottom > bottom) {
|
||||||
bounds.top = bottom;
|
bounds.top = bottom;
|
||||||
bounds.height = overFooterBottom-bottom;
|
bounds.height = overFooterBottom-bottom;
|
||||||
@ -2534,13 +2518,13 @@ void ListView::dispatchDraw(Canvas&canvas) {
|
|||||||
} else {
|
} else {
|
||||||
int top;
|
int top;
|
||||||
|
|
||||||
if (count > 0 && bdrawOverscrollHeader) {
|
if (count > 0 && mOverScrollHeader) {
|
||||||
bounds.top = mScrollY;
|
bounds.top = mScrollY;
|
||||||
bounds.height = getChildAt(0)->getTop() - mScrollY;
|
bounds.height = getChildAt(0)->getTop() - mScrollY;
|
||||||
drawOverscrollHeader(canvas, overscrollHeader, bounds);
|
drawOverscrollHeader(canvas, overscrollHeader, bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
int start = bdrawOverscrollHeader ? 1 : 0;
|
int start = mOverScrollHeader ? 1 : 0;
|
||||||
for (int i = start; i < count; i++) {
|
for (int i = start; i < count; i++) {
|
||||||
int itemIndex = (first + i);
|
int itemIndex = (first + i);
|
||||||
bool isHeader = (itemIndex < headerCount);
|
bool isHeader = (itemIndex < headerCount);
|
||||||
@ -2577,7 +2561,7 @@ void ListView::dispatchDraw(Canvas&canvas) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (count > 0 && mScrollY > 0) {
|
if (count > 0 && mScrollY > 0) {
|
||||||
if (bdrawOverscrollFooter) {
|
if (mOverScrollFooter) {
|
||||||
int absListBottom = getBottom();
|
int absListBottom = getBottom();
|
||||||
bounds.top = absListBottom;
|
bounds.top = absListBottom;
|
||||||
bounds.height = mScrollY;
|
bounds.height = mScrollY;
|
||||||
@ -2771,43 +2755,37 @@ int ListView::getHeightForPosition(int position) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ListView::shouldAdjustHeightForDivider(int itemIndex) {
|
bool ListView::shouldAdjustHeightForDivider(int itemIndex) {
|
||||||
int dividerHeight = mDividerHeight;
|
const bool drawDividers = mDividerHeight > 0 && mDivider != nullptr;
|
||||||
Drawable* overscrollHeader = mOverScrollHeader;
|
|
||||||
Drawable* overscrollFooter = mOverScrollFooter;
|
|
||||||
bool drawOverscrollHeader = overscrollHeader != nullptr;
|
|
||||||
bool drawOverscrollFooter = overscrollFooter != nullptr;
|
|
||||||
bool drawDividers = dividerHeight > 0 && mDivider != nullptr;
|
|
||||||
|
|
||||||
if (drawDividers) {
|
if (drawDividers) {
|
||||||
bool fillForMissingDividers = isOpaque() && !AbsListView::isOpaque();
|
bool fillForMissingDividers = isOpaque() && !AbsListView::isOpaque();
|
||||||
int itemCount = mItemCount;
|
const int itemCount = mItemCount;
|
||||||
int headerCount = getHeaderViewsCount();
|
const int headerCount = getHeaderViewsCount();
|
||||||
int footerLimit = (itemCount - mFooterViewInfos.size());
|
const int footerLimit = (itemCount - mFooterViewInfos.size());
|
||||||
bool isHeader = (itemIndex < headerCount);
|
const bool isHeader = (itemIndex < headerCount);
|
||||||
bool isFooter = (itemIndex >= footerLimit);
|
const bool isFooter = (itemIndex >= footerLimit);
|
||||||
bool headerDividers = mHeaderDividersEnabled;
|
const bool headerDividers = mHeaderDividersEnabled;
|
||||||
bool footerDividers = mFooterDividersEnabled;
|
const bool footerDividers = mFooterDividersEnabled;
|
||||||
if ((headerDividers || !isHeader) && (footerDividers || !isFooter)) {
|
if ((headerDividers || !isHeader) && (footerDividers || !isFooter)) {
|
||||||
if (!mStackFromBottom) {
|
if (!mStackFromBottom) {
|
||||||
bool isLastItem = (itemIndex == (itemCount - 1));
|
bool isLastItem = (itemIndex == (itemCount - 1));
|
||||||
if (!drawOverscrollFooter || !isLastItem) {
|
if (!mOverScrollHeader || !isLastItem) {
|
||||||
int nextIndex = itemIndex + 1;
|
int nextIndex = itemIndex + 1;
|
||||||
/* Draw dividers between enabled items, headers and/or footers
|
/* Draw dividers between enabled items, headers and/or footers
|
||||||
*when enabled and requested, and after the last enabled item.*/
|
*when enabled and requested, and after the last enabled item.*/
|
||||||
if (mAdapter->isEnabled(itemIndex) && (headerDividers || !isHeader
|
if (mAdapter->isEnabled(itemIndex) && (headerDividers || !isHeader && (nextIndex >= headerCount))
|
||||||
&& (nextIndex >= headerCount)) && (isLastItem
|
&& (isLastItem || mAdapter->isEnabled(nextIndex)
|
||||||
|| mAdapter->isEnabled(nextIndex) && (footerDividers || !isFooter
|
&& (footerDividers || !isFooter && (nextIndex < footerLimit)))) {
|
||||||
&& (nextIndex < footerLimit)))) {
|
|
||||||
return true;
|
return true;
|
||||||
} else if (fillForMissingDividers) {
|
} else if (fillForMissingDividers) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int start = drawOverscrollHeader ? 1 : 0;
|
const int start = mOverScrollHeader ? 1 : 0;
|
||||||
bool isFirstItem = (itemIndex == start);
|
const bool isFirstItem = (itemIndex == start);
|
||||||
if (!isFirstItem) {
|
if (!isFirstItem) {
|
||||||
int previousIndex = (itemIndex - 1);
|
const int previousIndex = (itemIndex - 1);
|
||||||
// Draw dividers between enabled items, headers
|
// Draw dividers between enabled items, headers
|
||||||
// and/or footers when enabled and requested, and
|
// and/or footers when enabled and requested, and
|
||||||
// before the first enabled item.
|
// before the first enabled item.
|
||||||
|
@ -11,7 +11,7 @@ class SplineOverScroller{
|
|||||||
private://constexprs
|
private://constexprs
|
||||||
// Constant gravity value, used in the deceleration phase.
|
// Constant gravity value, used in the deceleration phase.
|
||||||
static constexpr float GRAVITY = 2000.0f;
|
static constexpr float GRAVITY = 2000.0f;
|
||||||
static constexpr float DECELERATION_RATE = (float) (log(0.78) / log(0.9));
|
static constexpr float DECELERATION_RATE = 2.35967668204509f/*(float) (log(0.78) / log(0.9))*/;
|
||||||
static constexpr float INFLEXION = 0.35f; // Tension lines cross at (INFLEXION, 1)
|
static constexpr float INFLEXION = 0.35f; // Tension lines cross at (INFLEXION, 1)
|
||||||
static constexpr float START_TENSION = 0.5f;
|
static constexpr float START_TENSION = 0.5f;
|
||||||
static constexpr float END_TENSION = 1.0f;
|
static constexpr float END_TENSION = 1.0f;
|
||||||
|
@ -39,7 +39,7 @@ private:
|
|||||||
static constexpr int SCROLL_MODE = 0;
|
static constexpr int SCROLL_MODE = 0;
|
||||||
static constexpr int FLING_MODE = 1;
|
static constexpr int FLING_MODE = 1;
|
||||||
|
|
||||||
static constexpr float DECELERATION_RATE = (float) (log(0.78) / log(0.9));
|
static constexpr float DECELERATION_RATE = 2.35967668204509f/*(float) (log(0.78) / log(0.9))*/;
|
||||||
static constexpr float INFLEXION = 0.35f; // Tension lines cross at (INFLEXION, 1)
|
static constexpr float INFLEXION = 0.35f; // Tension lines cross at (INFLEXION, 1)
|
||||||
static constexpr float START_TENSION = 0.5f;
|
static constexpr float START_TENSION = 0.5f;
|
||||||
static constexpr float END_TENSION = 1.0f;
|
static constexpr float END_TENSION = 1.0f;
|
||||||
|
Loading…
Reference in New Issue
Block a user