mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-12-04 05:10:06 +08:00
fix recyclerview edgeeffect's springback
This commit is contained in:
parent
e3e1d15a60
commit
970436e625
@ -518,12 +518,12 @@ void Window::dispatchInvalidateRectOnAnimation(View*view,const Rect&rect){
|
||||
|
||||
void Window::dispatchInvalidateDelayed(View*view, long delayMilliseconds){
|
||||
LOGW_IF(delayMilliseconds,"Delay is NOT IMPLEMENTED");
|
||||
if(0==delayMilliseconds) dispatchInvalidateOnAnimation(view);
|
||||
if(0==delayMilliseconds) dispatchInvalidateOnAnimation(view);
|
||||
}
|
||||
|
||||
void Window::dispatchInvalidateRectDelayed(const AttachInfo::InvalidateInfo*info,long delayMilliseconds){
|
||||
LOGW_IF(delayMilliseconds,"Delay is NOT IMPLEMENTED");
|
||||
if(0==delayMilliseconds) dispatchInvalidateRectOnAnimation(info->target,info->rect);
|
||||
if(0==delayMilliseconds) dispatchInvalidateRectOnAnimation(info->target,info->rect);
|
||||
}
|
||||
|
||||
void Window::cancelInvalidate(View* view){
|
||||
@ -562,7 +562,7 @@ void Window::InvalidateOnAnimationRunnable::addView(View* view){
|
||||
}
|
||||
|
||||
void Window::InvalidateOnAnimationRunnable::addViewRect(View* view,const Rect&rect){
|
||||
auto it=find(view);
|
||||
auto it = find(view);
|
||||
if(it == mInvalidateViews.end()){
|
||||
AttachInfo::InvalidateInfo* info = AttachInfo::InvalidateInfo::obtain();
|
||||
info->target =view;
|
||||
@ -577,7 +577,7 @@ void Window::InvalidateOnAnimationRunnable::addViewRect(View* view,const Rect&re
|
||||
}
|
||||
|
||||
void Window::InvalidateOnAnimationRunnable::removeView(View* view){
|
||||
auto it=find(view);
|
||||
auto it = find(view);
|
||||
if(it != mInvalidateViews.end()){
|
||||
mInvalidateViews.erase(it);
|
||||
}
|
||||
@ -588,21 +588,20 @@ void Window::InvalidateOnAnimationRunnable::removeView(View* view){
|
||||
|
||||
void Window::InvalidateOnAnimationRunnable::run(){
|
||||
mPosted = false;
|
||||
std::vector<View::AttachInfo::InvalidateInfo*>&temp = mInvalidateViews;
|
||||
mInvalidateViews.clear();
|
||||
std::vector<View::AttachInfo::InvalidateInfo*>& temp = mInvalidateViews;
|
||||
for (auto i:temp){
|
||||
Rect&r = i->rect;
|
||||
View*v = i->target;
|
||||
if(r.width<=0||r.height<=0) v->invalidate();
|
||||
else v->invalidate(r.left,r.top,r.width,r.height);
|
||||
}
|
||||
mInvalidateViews.clear();
|
||||
}
|
||||
|
||||
void Window::InvalidateOnAnimationRunnable::postIfNeededLocked() {
|
||||
if (!mPosted) {
|
||||
//Choreographer::getInstance().postCallback(Choreographer::CALLBACK_ANIMATION,nullptr,this);
|
||||
Runnable run;
|
||||
run=std::bind(&InvalidateOnAnimationRunnable::run,this);
|
||||
Runnable run(std::bind(&InvalidateOnAnimationRunnable::run,this));
|
||||
mOwner->postDelayed(run,AnimationHandler::getFrameDelay());
|
||||
mPosted = true;
|
||||
}
|
||||
|
@ -1153,28 +1153,28 @@ int RecyclerView::getMaxFlingVelocity() const{
|
||||
}
|
||||
|
||||
void RecyclerView::pullGlows(float x, float overscrollX, float y, float overscrollY) {
|
||||
bool invalidate = false;
|
||||
bool bInvalidate = false;
|
||||
if (overscrollX < 0) {
|
||||
ensureLeftGlow();
|
||||
mLeftGlow->onPull(-overscrollX / getWidth(), 1.f - y / getHeight());
|
||||
invalidate = true;
|
||||
bInvalidate = true;
|
||||
} else if (overscrollX > 0) {
|
||||
ensureRightGlow();
|
||||
mRightGlow->onPull(overscrollX / getWidth(), y / getHeight());
|
||||
invalidate = true;
|
||||
bInvalidate = true;
|
||||
}
|
||||
|
||||
if (overscrollY < 0) {
|
||||
ensureTopGlow();
|
||||
mTopGlow->onPull(-overscrollY / getHeight(), x / getWidth());
|
||||
invalidate = true;
|
||||
bInvalidate = true;
|
||||
} else if (overscrollY > 0) {
|
||||
ensureBottomGlow();
|
||||
mBottomGlow->onPull(overscrollY / getHeight(), 1.f - x / getWidth());
|
||||
invalidate = true;
|
||||
bInvalidate = true;
|
||||
}
|
||||
|
||||
if (invalidate || overscrollX != 0 || overscrollY != 0) {
|
||||
if (bInvalidate || (overscrollX != 0) || (overscrollY != 0)) {
|
||||
postInvalidateOnAnimation();
|
||||
}
|
||||
}
|
||||
@ -1196,8 +1196,8 @@ void RecyclerView::releaseGlows() {
|
||||
if (mBottomGlow != nullptr) {
|
||||
mBottomGlow->onRelease();
|
||||
needsInvalidate |= mBottomGlow->isFinished();
|
||||
}LOGE(".........%p needsInvalidate=%d",this,needsInvalidate);
|
||||
if (needsInvalidate||1) {
|
||||
}
|
||||
if (needsInvalidate) {
|
||||
postInvalidateOnAnimation();
|
||||
}
|
||||
}
|
||||
@ -1242,7 +1242,7 @@ void RecyclerView::absorbGlows(int velocityX, int velocityY) {
|
||||
mBottomGlow->onAbsorb(velocityY);
|
||||
}
|
||||
|
||||
if (velocityX != 0 || velocityY != 0) {
|
||||
if ((velocityX != 0) || (velocityY != 0)) {
|
||||
postInvalidateOnAnimation();
|
||||
}
|
||||
}
|
||||
@ -1771,8 +1771,8 @@ bool RecyclerView::onTouchEvent(MotionEvent& e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool canScrollHorizontally = mLayout->canScrollHorizontally();
|
||||
const bool canScrollVertically = mLayout->canScrollVertically();
|
||||
const bool bCanScrollHorizontally = mLayout->canScrollHorizontally();
|
||||
const bool bCanScrollVertically = mLayout->canScrollVertically();
|
||||
|
||||
if (mVelocityTracker == nullptr) {
|
||||
mVelocityTracker = VelocityTracker::obtain();
|
||||
@ -1795,10 +1795,10 @@ bool RecyclerView::onTouchEvent(MotionEvent& e) {
|
||||
mInitialTouchY = mLastTouchY = (int) (e.getY() + 0.5f);
|
||||
|
||||
int nestedScrollAxis = View::SCROLL_AXIS_NONE;
|
||||
if (canScrollHorizontally) {
|
||||
if (bCanScrollHorizontally) {
|
||||
nestedScrollAxis |= View::SCROLL_AXIS_HORIZONTAL;
|
||||
}
|
||||
if (canScrollVertically) {
|
||||
if (bCanScrollVertically) {
|
||||
nestedScrollAxis |= View::SCROLL_AXIS_VERTICAL;
|
||||
}
|
||||
startNestedScroll(nestedScrollAxis, TYPE_TOUCH);
|
||||
@ -1834,7 +1834,7 @@ bool RecyclerView::onTouchEvent(MotionEvent& e) {
|
||||
|
||||
if (mScrollState != SCROLL_STATE_DRAGGING) {
|
||||
bool startScroll = false;
|
||||
if (canScrollHorizontally && std::abs(dx) > mTouchSlop) {
|
||||
if (bCanScrollHorizontally && std::abs(dx) > mTouchSlop) {
|
||||
if (dx > 0) {
|
||||
dx -= mTouchSlop;
|
||||
} else {
|
||||
@ -1842,7 +1842,7 @@ bool RecyclerView::onTouchEvent(MotionEvent& e) {
|
||||
}
|
||||
startScroll = true;
|
||||
}
|
||||
if (canScrollVertically && std::abs(dy) > mTouchSlop) {
|
||||
if (bCanScrollVertically && std::abs(dy) > mTouchSlop) {
|
||||
if (dy > 0) {
|
||||
dy -= mTouchSlop;
|
||||
} else {
|
||||
@ -1860,8 +1860,8 @@ bool RecyclerView::onTouchEvent(MotionEvent& e) {
|
||||
mLastTouchY = y - mScrollOffset[1];
|
||||
|
||||
if (scrollByInternal(
|
||||
canScrollHorizontally ? dx : 0,
|
||||
canScrollVertically ? dy : 0,
|
||||
bCanScrollHorizontally ? dx : 0,
|
||||
bCanScrollVertically ? dy : 0,
|
||||
vtev)) {
|
||||
getParent()->requestDisallowInterceptTouchEvent(true);
|
||||
}
|
||||
@ -1879,11 +1879,9 @@ bool RecyclerView::onTouchEvent(MotionEvent& e) {
|
||||
mVelocityTracker->addMovement(*vtev);
|
||||
eventAddedToVelocityTracker = true;
|
||||
mVelocityTracker->computeCurrentVelocity(1000, mMaxFlingVelocity);
|
||||
const float xvel = canScrollHorizontally
|
||||
? -mVelocityTracker->getXVelocity(mScrollPointerId) : 0;
|
||||
const float yvel = canScrollVertically
|
||||
? -mVelocityTracker->getYVelocity(mScrollPointerId) : 0;
|
||||
if (!((xvel != 0 || yvel != 0) && fling((int) xvel, (int) yvel))) {
|
||||
const float xvel = bCanScrollHorizontally ? -mVelocityTracker->getXVelocity(mScrollPointerId) : 0;
|
||||
const float yvel = bCanScrollVertically ? -mVelocityTracker->getYVelocity(mScrollPointerId) : 0;
|
||||
if (!(((xvel != 0) || (yvel != 0)) && fling((int) xvel, (int) yvel))) {
|
||||
setScrollState(SCROLL_STATE_IDLE);
|
||||
}
|
||||
resetTouch();
|
||||
@ -2782,7 +2780,6 @@ void RecyclerView::draw(Canvas& c) {
|
||||
&& mItemAnimator->isRunning()) {
|
||||
needsInvalidate = true;
|
||||
}
|
||||
LOGD("%p draw needdrawedge=%d",this,needsInvalidate);
|
||||
if (needsInvalidate) {
|
||||
postInvalidateOnAnimation();
|
||||
}
|
||||
@ -3395,7 +3392,6 @@ void RecyclerView::ViewFlinger::fling(int velocityX, int velocityY) {
|
||||
mLastFlingX = mLastFlingY = 0;
|
||||
mScroller->fling(0, 0, velocityX, velocityY, INT_MIN, INT_MAX, INT_MIN, INT_MAX);
|
||||
postOnAnimation();
|
||||
LOGD("velocityxy=%d,%d",velocityX,velocityY);
|
||||
}
|
||||
|
||||
void RecyclerView::ViewFlinger::smoothScrollBy(int dx, int dy) {
|
||||
|
Loading…
Reference in New Issue
Block a user