Skip to content

IHeaderView_cn

Zone edited this page Apr 4, 2017 · 2 revisions

接口

public interface IHeaderView {


    /**
     * 获取头部布局
     *
     * @param zRefreshLayout
     * @return
     */
    View getView(ZRefreshLayout zRefreshLayout);

    /**
     * 下拉准备刷新动作
     *
     * @param fraction   当前下拉高度与头部高度的比  超过头部动画基本保持不变
     * @param headHeight
     */
    void onPullingDown(float fraction, float headHeight);

    /**
     * 可刷新与不可刷新 状态切换监听
     *
     * @param refreshAble
     */
    void refreshAble(boolean refreshAble);

    /**
     * 回弹动画 监听
     *
     * @param animateBack  回弹类型
     * @param fraction
     * @param headHeight
     * @param isPinContent
     */
    void animateBack(AnimateBack animateBack, float fraction, float headHeight, boolean isPinContent);

    /**
     * 拦截滚动
     * 想让其滚动可使用AUtils.smoothScrollTo_NotIntercept(iScroll,0);
     * 参考:demo里的 CircleRefresh
     *
     * @param animateBack
     * @param iScroll
     * @return
     */
    boolean interceptAnimateBack(AnimateBack animateBack, ZRefreshLayout.IScroll iScroll);

    /**
     * 刷新进行时
     *
     * @param headHeight
     * @param isAutoRefresh
     */
    void onRefreshing(float headHeight, boolean isAutoRefresh);

    /**
     * 头部Rest前一刻调用此 用来重置状态
     */
    void onComplete();

    /**
     * 全局更换头的配置
     * 主要是为了复制头部对象,复制想要复制的属性
     * 注意:返回null时候,默认就是新浪头了
     */
    IHeaderView clone_();

}

设置触发刷新的位置

我觉得出发刷新的位置应该与头部关联更为紧密所以,方法放到AUtils类中setHeaderHeightToRefresh方法,为了不让ZRefreshLayout中方法暴露出去

For exmaple:

    @Override
    public View getView(ZRefreshLayout zRefreshLayout) {
        rootView = View.inflate(zRefreshLayout.getContext(), R.layout.header_meterial, null);
        AUtils.setHeaderHeightToRefresh(zRefreshLayout,(int) (screenPixs[1] * 0.2*0.8));
        ...
        return rootView;
    }

滚动延迟与拦截

interceptAnimateBack方法如果返回true,滚动就会被拦截不执行。

通过AUtils.smoothScrollTo_NotIntercept(iScroll,0);方法让其滚动到特定位置.Tips:此方法不会被拦截!

    mHeaderWaveCircle.setOnViewAniDone(new AnimationView.OnViewAniDone() {
            @Override
            public void viewAniDone() {
                AUtils.smoothScrollTo_NotIntercept(iScroll,0);
            }
        });

   public boolean interceptAnimateBack(AnimateBack animateBack, ZRefreshLayout.IScroll iScroll) {
        this.iScroll = iScroll;
        boolean result = false;
        if (mAnimateBack != animateBack && animateBack == AnimateBack.Complete_Back) {
            //完成时候的滚动返回被拦截
            mHeaderWaveCircle.setRefreshing(false);
            result = true;
        }
        mAnimateBack = animateBack;
        return result;
    }

clone_()

请看config 全局介绍里的原理

文档

[Home/总览概要] en/cn

[AutoRefresh]en/cn

[AnimateBack]en/cn

[GlobalConfiguration]en/cn

[IFooterView]en/cn

[IHeaderView]en/cn

[IResistance]en/cn

[Update Logs]en/cn

Clone this wiki locally