GithubHelp home page GithubHelp logo

dispatchTouchEvent about swipetoloadlayout HOT 1 CLOSED

aspsine avatar aspsine commented on August 28, 2024
dispatchTouchEvent

from swipetoloadlayout.

Comments (1)

Aspsine avatar Aspsine commented on August 28, 2024

这是我当时为了解决一个bug写的一段chenglish,见笑了。

当前状态是SWIPING_TO_REFRESH的时候,抬起手指,然后落下手指。如果这时候状态依然是SWIPEING_TO_REFRESH(当速度特别快的时候,header没有收缩到原位,所以这种情况是可能的。)

当时onInterceptTouchEvent ACTION_DOWN中是这样的:

if (!(STATUS.isRefreshComplete(mStatus) || STATUS.isLoadMoreComplete(mStatus))
                        && !(STATUS.isRefreshing(mStatus) || STATUS.isLoadingMore(mStatus))) {
  mAutoScroller.abortIfRunning();
}

这时候明显if条件是成立的,所以

mAutoScroller.abortIfRunning();

会执行,让scroller停止。

这时候手指如果移动,在ACTION_MOVE中的triggerCondition为false。

boolean triggerCondition = (yInitDiff > 0 && moved && onCheckCanRefresh())
                        || (yInitDiff < 0 && moved && onCheckCanLoadMore());
if (triggerCondition) {
    // the trigger condition refresh or load more is true
    // intercept the move action event and pass it to SwipeToLoadLayout#onTouchEvent()
    return true;
}

这次事件就不能拦截在SwipeToLoadLayout中,而是会传向swipe_tagert这id的子view的onTouchEevent。所以随后的ACTION_UP和ACTION_CANCEL都不会传向onInterceptTouchEventonTouchEvent

而我在SwipeToLoadLayout的onTouchEvent的ACTION_UPACTION_CANCEL中调用了onActivePointerUp()`来让scroller运行,让header弹回去。

case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
    if (mActivePointerId == INVALID_POINTER) {
        return false;
    }
    onActivePointerUp();
    mActivePointerId = INVALID_POINTER;
    break;

所以,就导致了当时header会卡住的bug。

然后当时的处理方式是,把onActivePointerUp()放在dispatchTouchEvent中去执行。bug就fix了。

当时处理这个问题用的时间比较长,然后就做了一下简单的记录。

从现在的代码里面应该是找不到轨迹了,应该删掉的,对你造成了误导,不好意思啊。

看这里:

public boolean onInterceptTouchEvent(MotionEvent event) {

from swipetoloadlayout.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.