Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add SlideSwitch #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2015
Merged

Add SlideSwitch #110

merged 1 commit into from
Mar 11, 2015

Conversation

Leaking
Copy link
Contributor

@Leaking Leaking commented Mar 11, 2015

No description provided.

Trinea added a commit that referenced this pull request Mar 11, 2015
@Trinea Trinea merged commit bfa4f2a into Trinea:master Mar 11, 2015
@jact-hz
Copy link

jact-hz commented Mar 12, 2015

您好,首先感谢您的开源组件android-auto-scroll-view-pager对我项目的帮助。
我在使用过程遇到一点问题。
我在https://github.com/chrisbanes/Android-PullToRefresh
的scrollview中嵌套了android-auto-scroll-view-pager
但是图片的上下滑动不能触发scrollview。是否有解决方法?
谢谢了。

在 2015-03-11 22:00:55,"Trinea" [email protected] 写道:

Merged #110.


Reply to this email directly or view it on GitHub.

@lsjwzh
Copy link
Contributor

lsjwzh commented Mar 12, 2015

继承 PullToRefreshListView 然后再dispatchTouchEvent处判断是否在ViewPager区域中。即可

@lsjwzh
Copy link
Contributor

lsjwzh commented Mar 12, 2015

/**

  • 用于截获dispatchTouchEvent事件

  • Created by Administrator on 13-9-30.
    */
    public class PullToRefreshListViewExtend extends PullToRefreshListView {

    public interface OnDispatchTouchEventListener {
    public boolean dispatchTouchEvent(MotionEvent event);
    }

    private OnDispatchTouchEventListener onDispatchTouchEventListener;

    public PullToRefreshListViewExtend(Context context) {
    super(context);
    }

    public PullToRefreshListViewExtend(Context context, AttributeSet attrs) {
    super(context, attrs);
    }

    public PullToRefreshListViewExtend(Context context, Mode mode) {
    super(context, mode);
    }

    public PullToRefreshListViewExtend(Context context, Mode mode, AnimationStyle style) {
    super(context, mode, style);
    }

    @OverRide
    public boolean dispatchTouchEvent(MotionEvent event) {
    try {
    if (getOnDispatchTouchEventListener() != null
    && getOnDispatchTouchEventListener().dispatchTouchEvent(event)) {
    return true;
    }
    return super.dispatchTouchEvent(event);
    } catch (IllegalArgumentException e) {
    //catch java.lang.IllegalArgumentException: pointerIndex out of range
    return true;
    }
    }

    public OnDispatchTouchEventListener getOnDispatchTouchEventListener() {
    return onDispatchTouchEventListener;
    }

    public void setOnDispatchTouchEventListener(OnDispatchTouchEventListener onDispatchTouchEventListener) {
    this.onDispatchTouchEventListener = onDispatchTouchEventListener;
    }

}

@lsjwzh
Copy link
Contributor

lsjwzh commented Mar 12, 2015

private class OnDispatchTouchEventListener implements
        PullToRefreshScrollViewExtend.OnDispatchTouchEventListener {
    boolean mActionDownOnBannerArea;

    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
        boolean inBannerArea = isInBannerArea(event);
        if ((event.getAction() == MotionEvent.ACTION_DOWN
                && inBannerArea) || mActionDownOnBannerArea) {
            //如果在banner区域按下,则开始触发bannerViewPager的ontouch事件
            mActionDownOnBannerArea = true;
            try {
                mBannerViews.bannerViewPager.onTouchEvent(event);
            } catch (IllegalStateException e) {

            }
        }
        if (event.getAction() == MotionEvent.ACTION_UP) {
            mActionDownOnBannerArea = false;
            mBannerViews.bannerViewPager.startAutoScroll();
        }
        return false;
    }
}

@lsjwzh
Copy link
Contributor

lsjwzh commented Mar 12, 2015

使用的时候:
mPTRScrollView.setOnDispatchTouchEventListener(new OnDispatchTouchEventListener());

@jact-hz
Copy link

jact-hz commented Mar 12, 2015

isInBannerArea(event)和mBannerViews.bannerViewPager 找不到?

@Trinea
Copy link
Owner

Trinea commented Mar 12, 2015

相关问题请大家到 https://github.com/android-cn/interview-questions 下面新建 Issue 讨论,谢谢,这里讨论会影响太多人。

Repository owner locked and limited conversation to collaborators Mar 12, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants