-
Notifications
You must be signed in to change notification settings - Fork 7
/
RCTPullToRefreshScrollView.java
685 lines (561 loc) · 23.5 KB
/
RCTPullToRefreshScrollView.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
package com.rntaobao.pullToRefresh.view;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.views.scroll.ReactScrollView;
import com.facebook.react.views.view.ReactViewGroup;
import android.support.v4.view.ViewCompat;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.widget.LinearLayout;
/**
* 带下拉刷新功能的scrollView
*/
public class RCTPullToRefreshScrollView extends LinearLayout {
private ThemedReactContext mContext;
// ===========================================================
// Constants
// ===========================================================
/**
* DEBUG模式下会输出log
*/
static final boolean DEBUG = true;
/**
* log tag
*/
static final String LOG_TAG = "PullToRefresh";
/**
* {@link #smoothScrollTo(int)}方法使用的默认滚动时间
*/
public static final int SMOOTH_SCROLL_DURATION_MS = 200;
/**
* 下拉拉出{@link RCTPullToRefreshLoadingLayout}时,滑动的距离时拉出距离的{@value #FRICTION}倍
*/
public static final float FRICTION = 2.0f;
/**
* 从{@link State#RESET}开始拉动到即将进入{@link State#RELEASE_TO_REFRESH}时,
* 本控件被拉动的距离, 即被拉动多少后放手才有可能进入刷新
* <strong>是本控件被拉动的距离,不是手势经过的距离,两者有{@value FRICTION}倍的比例</strong>
* 单位是像素
*/
public static int MIN_DRAGGED_DISTANCE_TO_REFRESH_PX = 0;
/**
* 系统需要手势移动多少像素,才认为时开始scroll
* {@link ViewConfiguration#getScaledTouchSlop()}
*/
private int mTouchSlop;
private float mLastMotionX, mLastMotionY;
private float mInitialMotionX, mInitialMotionY;
private boolean mIsBeingDragged = false;
/**
* 本控件在状态机中的状态,见{@link State}
*/
private State mState = State.RESET;
/**
* 在{@link State#REFRESHING}{@link State#MANUAL_REFRESHING}时
* {@link RCTPullToRefreshLoadingLayout}是完全缩回去还是保留底端的状态文字部分
* 见{@link #onRefreshing(boolean)}
*/
private boolean mShowPartOfTheLoadingLayoutWhileRefreshing = true;
/**
* 更新时是否允许滑动
*/
private boolean mAllowScrollingWhileRefreshingEnabled = false;
/**
* 判断是否进入drag过程时,是否考虑横向和纵向上滑动距离的对比
*/
private boolean mFilterTouchEventsByDirectionDiffComparison = true;
private OnLoadingLayoutScrollPositionChangeListener mOnLoadingLayoutScrollPositionChangeListener;
private OnPullToRefreshStateChangeListener mOnPullToRefreshStateChangeListener;
private OnRefreshListener mOnRefreshListener;
private Interpolator mScrollAnimationInterpolator;
private RCTPullToRefreshLoadingLayout mLoadingLayout;
private ReactScrollView mScrollView;
private SmoothScrollRunnable mCurrentSmoothScrollRunnable;
public RCTPullToRefreshScrollView(ThemedReactContext context) {
super(context);
init(context);
}
private void init(ThemedReactContext context) {
mContext = context;
ViewConfiguration config = ViewConfiguration.get(context);
mTouchSlop = config.getScaledTouchSlop();
}
/**
* 提取js中定义的{@link RCTPullToRefreshLoadingLayout}和{@link ReactScrollView},以便在java中操作
*/
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
if (child instanceof ReactViewGroup) {
ReactViewGroup vg = (ReactViewGroup) child;
for (int i = 0; i < vg.getChildCount(); i++) {
View v = vg.getChildAt(i);
if (v instanceof RCTPullToRefreshLoadingLayout) {
mLoadingLayout = (RCTPullToRefreshLoadingLayout) v;
} else if (v instanceof ReactScrollView) {
mScrollView = (ReactScrollView) v;
}
}
}
super.addView(child, index, params);
}
/**
* 本控件的实际大小确定以后,按{@link RCTPullToRefreshLoadingLayout}的高度设置负的padding以便隐藏它
*/
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
int pLeft = getPaddingLeft();
int pTop = getPaddingTop();
int pRight = getPaddingRight();
int pBottom = getPaddingBottom();
pTop = -mLoadingLayout.getHeight();
setPadding(pLeft, pTop, pRight, pBottom);
}
public final boolean isRefreshing() {
return mState == State.REFRESHING || mState == State.MANUAL_REFRESHING;
}
protected boolean isReadyForPull() {
return mScrollView.getScrollY() == 0;
}
@Override
public final boolean onInterceptTouchEvent(MotionEvent event) {
final int action = event.getAction();
if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) {
mIsBeingDragged = false;
return false;
}
if (action != MotionEvent.ACTION_DOWN && mIsBeingDragged) {
return true;
}
switch (action) {
case MotionEvent.ACTION_MOVE: {
// If we're refreshing, and the flag is set. Eat all MOVE events
if (!mAllowScrollingWhileRefreshingEnabled && isRefreshing()) {
return true;
}
if (isReadyForPull()) {
final float y = event.getY(), x = event.getX();
final float effectiveDirectionDiff, ineffectiveDirectionDiff, absEffectiveDirectionDiff;
effectiveDirectionDiff = y - mLastMotionY;
ineffectiveDirectionDiff = x - mLastMotionX;
absEffectiveDirectionDiff = Math.abs(effectiveDirectionDiff);
if (absEffectiveDirectionDiff > mTouchSlop && (!mFilterTouchEventsByDirectionDiffComparison || absEffectiveDirectionDiff > Math.abs(ineffectiveDirectionDiff))) {
if (effectiveDirectionDiff >= 1f && isReadyForPull()) {
mLastMotionY = y;
mLastMotionX = x;
mIsBeingDragged = true;
}
}
}
break;
}
case MotionEvent.ACTION_DOWN: {
if (isReadyForPull()) {
mLastMotionY = mInitialMotionY = event.getY();
mLastMotionX = mInitialMotionX = event.getX();
mIsBeingDragged = false;
}
break;
}
}
return mIsBeingDragged;
}
@Override
public final boolean onTouchEvent(MotionEvent event) {
// 如果正在正在更新中,且更新时不允许滑动,则抛弃该手势
if (!mAllowScrollingWhileRefreshingEnabled && isRefreshing()) {
return true;
}
if (event.getAction() == MotionEvent.ACTION_DOWN && event.getEdgeFlags() != 0) {
return false;
}
switch (event.getAction()) {
case MotionEvent.ACTION_MOVE: {
if (mIsBeingDragged) {
mLastMotionY = event.getY();
mLastMotionX = event.getX();
scrollTheWholeView();
return true;
}
break;
}
case MotionEvent.ACTION_DOWN: {
if (isReadyForPull()) {
mLastMotionY = mInitialMotionY = event.getY();
mLastMotionX = mInitialMotionX = event.getX();
return true;
}
break;
}
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP: {
if (mIsBeingDragged) {
mIsBeingDragged = false;
/**
* 需要{@link mOnRefreshListener}存在才能进入{@link State#REFRESHING}状态
* 否则直接退回{@link State#RESET}状态
* 原因见{@link OnRefreshListener}
* */
if (mState == State.RELEASE_TO_REFRESH && mOnRefreshListener != null) {
setState(State.REFRESHING, true);
return true;
}
// If we're already refreshing, just scroll back to the top
if (isRefreshing()) {
smoothScrollTo(0);
return true;
}
// If we haven't returned by here, then we're not in a mState
// to pull, so just reset
setState(State.RESET);
return true;
}
break;
}
}
return false;
}
/**
* {@value MIN_DRAGGED_DISTANCE_TO_REFRESH_PX}
*/
private int getMinDraggedDistanceToRefreshPx() {
return MIN_DRAGGED_DISTANCE_TO_REFRESH_PX;
}
/**
* {@link com.rntaobao.pullToRefresh.viewManager.RCTPullToRefreshScrollViewManager#setMinDraggedDistanceToRefresh(RCTPullToRefreshScrollView, int)}
*/
public void setMinDraggedDistanceToRefreshDp(int distanceDp) {
float density = getResources().getDisplayMetrics().density;
MIN_DRAGGED_DISTANCE_TO_REFRESH_PX = (int) (distanceDp * density);
}
/**
* 平滑滚动到指定位置,滚动时间为{@value #SMOOTH_SCROLL_DURATION_MS} ms.
*/
protected final void smoothScrollTo(int scrollValue) {
smoothScrollTo(scrollValue, SMOOTH_SCROLL_DURATION_MS);
}
protected final void smoothScrollTo(int scrollValue, OnSmoothScrollFinishedListener listener) {
smoothScrollTo(scrollValue, SMOOTH_SCROLL_DURATION_MS, 0, listener);
}
private final void smoothScrollTo(int scrollValue, long duration) {
smoothScrollTo(scrollValue, duration, 0, null);
}
private final void smoothScrollTo(int newScrollValue, long duration, long delayMillis,
OnSmoothScrollFinishedListener listener) {
if (null != mCurrentSmoothScrollRunnable) {
mCurrentSmoothScrollRunnable.stop();
}
final int oldScrollValue = getScrollY();
if (oldScrollValue != newScrollValue) {
if (null == mScrollAnimationInterpolator) {
// Default interpolator is a Decelerate Interpolator
mScrollAnimationInterpolator = new DecelerateInterpolator();
}
mCurrentSmoothScrollRunnable = new SmoothScrollRunnable(oldScrollValue, newScrollValue, duration, listener);
if (delayMillis > 0) {
postDelayed(mCurrentSmoothScrollRunnable, delayMillis);
} else {
post(mCurrentSmoothScrollRunnable);
}
}
}
/**
* 进入{@link State#RESET}状态时触发
*/
private void onReset() {
mIsBeingDragged = false;
smoothScrollTo(0);
}
/**
* 进入{@link State#PULL_TO_REFRESH}状态时触发
*/
private void onPullToRefresh() {
// NO-OP
}
/**
* 进入{@link State#RELEASE_TO_REFRESH}状态时触发
*/
private void onReleaseToRefresh() {
// NO-OP
}
/**
* 外界刷新完成后,调用本方法通知{@link RCTPullToRefreshLoadingLayout}区域滚动至屏幕外从而隐藏
*/
public void notifyRefreshComplete() {
if (isRefreshing()) {
setState(State.RESET);
}
}
/**
* 进入{@link State#REFRESHING}和{@link State#MANUAL_REFRESHING}时触发
*
* @param doScroll 此时{@link RCTPullToRefreshLoadingLayout}是否要缩回去全部或者一部分
*/
private void onRefreshing(final boolean doScroll) {
if (doScroll) {
/**
* {@link RCTPullToRefreshLoadingLayout}缩回去一部分,缩回的是底端的状态文字部分
* */
if (mShowPartOfTheLoadingLayoutWhileRefreshing) {
// Call Refresh Listener when the Scroll has finished
OnSmoothScrollFinishedListener listener = new OnSmoothScrollFinishedListener() {
@Override
public void onSmoothScrollFinished() {
callRefreshListener();
}
};
smoothScrollTo(-getMinDraggedDistanceToRefreshPx(), listener);
}
/**
* {@link RCTPullToRefreshLoadingLayout}全部缩回去
* */
else {
smoothScrollTo(0);
}
}
/**
* {@link RCTPullToRefreshLoadingLayout}维持完全显示状态,等{@link OnRefreshListener}回调中调到{@link #notifyRefreshComplete()}再缩回去
* */
else {
callRefreshListener();
}
}
private void callRefreshListener() {
if (null != mOnRefreshListener) {
mOnRefreshListener.onRefresh(this);
}
}
/**
* 不是由手势触发的直接将{@link State}转移到{@link State#MANUAL_REFRESHING}的情况
* 目前<strong>暂无</strong>使用场景
*/
public void moveToRefreshingStateNotByGesture() {
moveToRefreshingStateNotByGesture(true);
}
private void moveToRefreshingStateNotByGesture(boolean doScroll) {
if (!isRefreshing()) {
setState(State.MANUAL_REFRESHING, doScroll);
}
}
private void setState(State state, final boolean... params) {
mState = state;
if (null != mOnPullToRefreshStateChangeListener) {
mOnPullToRefreshStateChangeListener.onPullToRefreshStateChange(this, mState);
}
if (DEBUG) {
Log.d(LOG_TAG, "State: " + mState.name());
}
switch (mState) {
case RESET:
onReset();
break;
case PULL_TO_REFRESH:
onPullToRefresh();
break;
case RELEASE_TO_REFRESH:
onReleaseToRefresh();
break;
case REFRESHING:
case MANUAL_REFRESHING:
onRefreshing(params[0]);
break;
case OVERSCROLLING:
// NO-OP
break;
}
}
/**
* {@link #scrollTheWholeViewImpl(int)}中能滚动到的最大位置
*/
private int getMaximumPullScroll() {
return Math.round(getHeight() / FRICTION);
}
/**
* 根据新的手势,将本控件滚动到合适的位置,制造{@link RCTPullToRefreshLoadingLayout}的显示和隐藏效果
* <strong>内部根据手势计算新的滚动值,并转换了{@link State}, 最终调用{@link #scrollTheWholeViewImpl(int)}</strong>
*/
private void scrollTheWholeView() {
final int newScrollValue;
final int minDraggedDistanceToRefreshPx;
final float initialMotionValue, lastMotionValue;
initialMotionValue = mInitialMotionY;
lastMotionValue = mLastMotionY;
newScrollValue = Math.round(Math.min(initialMotionValue - lastMotionValue, 0) / FRICTION);
minDraggedDistanceToRefreshPx = getMinDraggedDistanceToRefreshPx();
scrollTheWholeViewImpl(newScrollValue);
if (newScrollValue != 0 && !isRefreshing()) {
if (mState != State.PULL_TO_REFRESH && minDraggedDistanceToRefreshPx >= Math.abs(newScrollValue)) {
setState(State.PULL_TO_REFRESH);
} else if (mState == State.PULL_TO_REFRESH && minDraggedDistanceToRefreshPx < Math.abs(newScrollValue)) {
setState(State.RELEASE_TO_REFRESH);
}
}
}
/**
* 根据新的滚动值,将本控件滚动到合适的位置,制造{@link RCTPullToRefreshLoadingLayout}的显示和隐藏效果
*/
private final void scrollTheWholeViewImpl(int newScrollValue) {
if (DEBUG) {
Log.d(LOG_TAG, "scrollTheWholeViewImpl: " + newScrollValue);
}
// 滑动位置要在[0, maximumPullScroll]之间
final int maximumPullScroll = getMaximumPullScroll();
newScrollValue = Math.min(0, Math.max(-maximumPullScroll, newScrollValue));
scrollTo(0, newScrollValue);
float loadingLayoutScrollPositionRatio = Math.abs(newScrollValue) / (float) getMinDraggedDistanceToRefreshPx();
// 通知外界本控件被拖动的距离
if (mOnLoadingLayoutScrollPositionChangeListener != null) {
mOnLoadingLayoutScrollPositionChangeListener.onLoadingLayoutScrollPositionChange(this, loadingLayoutScrollPositionRatio);
}
}
/**
* 用户拖动控件,拖动到不同位置时,控件会进入状态机的不同状态,以便决定{@link RCTPullToRefreshLoadingLayout}区域的显示内容
*/
public enum State {
/**
* 状态机的初始状态:{@link RCTPullToRefreshLoadingLayout}隐藏,用户没有开始下拉开始刷新
*/
RESET(0x0),
/**
* 用户下拉刷新,但拖动距离<strong>不够</strong>松手后可以判定为需要刷新的程度
*/
PULL_TO_REFRESH(0x1),
/**
* 用户下拉刷新,而且拖动距离<strong>已经够</strong>松手后可以判定为需要刷新的程度
*/
RELEASE_TO_REFRESH(0x2),
/**
* 用户在{@link State#RELEASE_TO_REFRESH}状态下松手,开始刷新
*/
REFRESHING(0x8),
/**
* 不是通过用户手势,而是通过{@link #moveToRefreshingStateNotByGesture()}直接启动刷新的情况下,进入该状态
* <strong>暂无</strong>该场景
*/
MANUAL_REFRESHING(0x9),
/**
* 在{@link android.os.Build.VERSION_CODES#GINGERBREAD}版本的系统上,
* {@link android.widget.ScrollView#overScrollBy(int, int, int, int, int, int, int, int, boolean)}方法中,
* 模拟overscroll效果时会进入该状态
* <strong>暂无</strong>该场景
*/
OVERSCROLLING(0x10);
/**
* 根据{@link State}的名字获得对应枚举值
*/
static State mapIntToValue(final int stateInt) {
for (State value : State.values()) {
if (stateInt == value.getIntValue()) {
return value;
}
}
// 默认返回
return RESET;
}
private int mIntValue;
State(int intValue) {
mIntValue = intValue;
}
int getIntValue() {
return mIntValue;
}
}
/**
* {@link #smoothScrollTo(int)}时用的实际执行动画
*/
private class SmoothScrollRunnable implements Runnable {
private final Interpolator mInterpolator;
private final int mScrollToY;
private final int mScrollFromY;
private final long mDuration;
private OnSmoothScrollFinishedListener mListener;
private boolean mContinueRunning = true;
private long mStartTime = -1;
private int mCurrentY = -1;
public SmoothScrollRunnable(int fromY, int toY, long duration, OnSmoothScrollFinishedListener listener) {
mScrollFromY = fromY;
mScrollToY = toY;
mInterpolator = mScrollAnimationInterpolator;
mDuration = duration;
mListener = listener;
}
@Override
public void run() {
/**
* Only set mStartTime if this is the first time we're starting,
* else actually calculate the Y delta
*/
if (mStartTime == -1) {
mStartTime = System.currentTimeMillis();
} else {
/**
* We do do all calculations in long to reduce software float
* calculations. We use 1000 as it gives us good accuracy and
* small rounding errors
*/
long normalizedTime = (1000 * (System.currentTimeMillis() - mStartTime)) / mDuration;
normalizedTime = Math.max(Math.min(normalizedTime, 1000), 0);
final int deltaY = Math.round((mScrollFromY - mScrollToY)
* mInterpolator.getInterpolation(normalizedTime / 1000f));
mCurrentY = mScrollFromY - deltaY;
scrollTheWholeViewImpl(mCurrentY);
}
// If we're not at the target Y, keep going...
if (mContinueRunning && mScrollToY != mCurrentY) {
ViewCompat.postOnAnimation(RCTPullToRefreshScrollView.this, this);
} else {
if (null != mListener) {
mListener.onSmoothScrollFinished();
}
}
}
public void stop() {
mContinueRunning = false;
removeCallbacks(this);
}
}
interface OnSmoothScrollFinishedListener {
void onSmoothScrollFinished();
}
public void setOnLoadingLayoutScrollPositionChangeListener(OnLoadingLayoutScrollPositionChangeListener l) {
mOnLoadingLayoutScrollPositionChangeListener = l;
}
public void setOnPullToRefreshStateChangeListener(OnPullToRefreshStateChangeListener l) {
mOnPullToRefreshStateChangeListener = l;
}
public void setOnRefreshListener(OnRefreshListener l) {
mOnRefreshListener = l;
}
/**
* {@link RCTPullToRefreshLoadingLayout}的滑动位置改变时,通过该回调通知外界
*/
public interface OnLoadingLayoutScrollPositionChangeListener {
/**
* @param loadingLayoutScrollPositionRatio 等于{@link RCTPullToRefreshLoadingLayout}的滑动的距离与{@value MIN_DRAGGED_DISTANCE_TO_REFRESH_PX}的比值
* 表示本控件滑动程度相对于要松手后刷新的要求,达到的百分比
* <strong>可以大于1</strong>
* <strong>滑动的距离,可以是由于拖动导致,也可以是由自动滚动导致</strong>
* <strong>{@link RCTPullToRefreshLoadingLayout}隐藏时{@link #mScrollView}的滑动不会触发该回调,因为不属于下拉刷新状态</strong>
*/
void onLoadingLayoutScrollPositionChange(final RCTPullToRefreshScrollView v, float loadingLayoutScrollPositionRatio);
}
/**
* 当用户拖动控件,使得其状态改变时,通过该回调通知外界
* 状态详见{@link State}
*/
public interface OnPullToRefreshStateChangeListener {
void onPullToRefreshStateChange(final RCTPullToRefreshScrollView v, State state);
}
/**
* 本控件通过这个回调告诉外界应该开始刷新了
* 外界刷新完成后调用本控件的{@link #notifyRefreshComplete}方法通知本控件数据刷新完毕,可以回滚隐藏{@link RCTPullToRefreshLoadingLayout}区域了
* 如果外界不设置该回调,则外界无法通知本控件刷新完毕,则本控件不进入{@link State#REFRESHING}状态(否则<strong>无法</strong>,而是直接回到{@link State#RESET}状态
*/
public interface OnRefreshListener {
void onRefresh(final RCTPullToRefreshScrollView v);
}
}