Skip to content
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

how to remove refreshing animation? #5

Closed
supermanxiacheng opened this issue Jun 27, 2018 · 11 comments
Closed

how to remove refreshing animation? #5

supermanxiacheng opened this issue Jun 27, 2018 · 11 comments

Comments

@supermanxiacheng
Copy link

我尝试修改了AnyHeader.java中的onFinsh中的return 500,变成了return 0.但是,没有效果。
我需要释放刷新后,就立即回弹,不要再有别的动画了。

@2534290808
Copy link
Member

请问你这是什么场景需要的?

@supermanxiacheng
Copy link
Author

额。说起来挺尴尬的。不是正常场景的需求。
有个页面里面scrollview里面有个tabView,tabView里面有4个flatList。
在安卓上,flatList如果嵌套在scrollView里面的话,flatList没法滑动。
为了解决这个问题,我们用了一种变通的方法,在使用flatList的情况下,就把外层的scrollVIew的scrollEnable设置为false,这时flatlist就可以滑动了,但是外层的scrollView就不能懂了。那么想要使用外层ScrollView的时候,就通过里面的flatList使用下拉刷新触发外层ScrollVIew的scrollTO方法,复位,并重新这是scrollEnable为true。

所以就产生一个需求,就是下拉刷新,释放刷新后不需要正在刷新的过渡。

因为那个页面非常复杂,来不及重写了,所以只能用这个变通方法。

@supermanxiacheng
Copy link
Author

supermanxiacheng commented Jun 28, 2018

我已经看了SmartRefreshLayout的issue,
知道可以使用refreshLayout.finishRefresh(0)立即结束刷新
写出了一种比较生硬的解决方法。。

在AnyHeader.java里

public void onStateChanged(RefreshLayout refreshLayout, RefreshState oldState, RefreshState newState) {
        Log.i("tag1","on State change "+newState.toString());
        switch (newState) {
            case RefreshReleased:
                refreshLayout.finishRefresh(0);
                break;
                default:
        }
    }

但是这样做,如果后期,这个RN项目需要自定义RefreshControl,用你这个库的话,那就会所有的loading,立即结束了。。。

@supermanxiacheng
Copy link
Author

最让我费解的是,如果用DefaultHeader的话

public void onStateChanged(RefreshLayout refreshLayout, RefreshState oldState, RefreshState newState) {
        switch (newState) {
            case None:
            case PullDownToRefresh:
                mHeaderText.setText("下拉开始刷新");
                mArrowView.setVisibility(VISIBLE);//显示下拉箭头
                mProgressView.setVisibility(GONE);//隐藏动画
                mArrowView.animate().rotation(0);//还原箭头方向
                break;
            case Refreshing:
                mHeaderText.setText("正在刷新");
                mProgressView.setVisibility(VISIBLE);//显示加载动画
                mArrowView.setVisibility(GONE);//隐藏箭头
                break;
            case ReleaseToRefresh:
                mHeaderText.setText("释放立即刷新");
                mArrowView.animate().rotation(180);//显示箭头改为朝上
                break;
        }
    }

只需要把

case Refreshing:
                mHeaderText.setText("正在刷新");
                mProgressView.setVisibility(VISIBLE);//显示加载动画
                mArrowView.setVisibility(GONE);//隐藏箭头
                break;

注释掉,释放立即刷新,过后就不会有任何过度,直接开始回弹了。

但是AnyHeader不知道,怎么做到。

@2534290808
Copy link
Member

外面的ScrollView可以不要吗?如果实在不行的话,可以设置
smartRefreshLayout.setReboundDuration(0);//回弹动画时长(毫秒)

@2534290808
Copy link
Member

在 SmartRefreshLayoutManager的
createViewInstance()方法里加上就行了

@supermanxiacheng
Copy link
Author

supermanxiacheng commented Jun 28, 2018

释放立即刷新,之后的 正在刷新 的动画时长应该是1000ms,而且并不是setReboundDuration设置的,我之前有试过这个函数。 应该是smartRefreshLayout的作者,在内部过程写了一个1000的最小默认值。

这个issue,有类似的需求
scwang90/SmartRefreshLayout#212

我觉得,如果你有空能加个RN能控制是否需要在RefreshReleased的情况下 refreshLayout.finishRefresh(0);的话能解决这个问题。

switch (newState) {
            case RefreshReleased:
                refreshLayout.finishRefresh(0);
                break;
                default:
        }

@supermanxiacheng
Copy link
Author

或者,RN的this._hw && this._hw.finishRefresh();
这种finishRefresh,应该是桥接的原生的
RefreshLayout finishRefresh(int delayed, boolean success);
但这个,finishRefresh(0,true),还是有过渡动画。

如果,能把这个finishRefresh再桥接一下原生的
RefreshLayout finishRefresh(int delayed);
这个类型的finishRefresh,可以直接关闭过渡动画。

@2534290808
Copy link
Member

finishRefresh传递的是json类型{delayed,success
},你试试

2534290808 added a commit that referenced this issue Jun 28, 2018
@2534290808
Copy link
Member

新版本0.5.3,执行this._hw && this.hw.finishRefresh({delayed:0})试试

@supermanxiacheng
Copy link
Author

谢谢,确实成功了。

PS:后来的兄弟,如果有类似的需求,别忘记,还要去AnyHeader.java中吧onfinish中的return 500改成return 0. 就是完美地立即上弹了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants