diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/swiperefresh/ReactSwipeRefreshLayout.java b/ReactAndroid/src/main/java/com/facebook/react/views/swiperefresh/ReactSwipeRefreshLayout.java index f458c0ab06b914..728def66f7940b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/swiperefresh/ReactSwipeRefreshLayout.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/swiperefresh/ReactSwipeRefreshLayout.java @@ -20,10 +20,27 @@ */ public class ReactSwipeRefreshLayout extends SwipeRefreshLayout { + private boolean mRefreshing = false; + public ReactSwipeRefreshLayout(ReactContext reactContext) { super(reactContext); } + @Override + public void setRefreshing(boolean refreshing) { + if (mRefreshing != refreshing) { + mRefreshing = refreshing; + // Use `post` otherwise the control won't start refreshing if refreshing is true when + // the component gets mounted. + post(new Runnable() { + @Override + public void run() { + ReactSwipeRefreshLayout.super.setRefreshing(mRefreshing); + } + }); + } + } + @Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (super.onInterceptTouchEvent(ev)) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/swiperefresh/SwipeRefreshLayoutManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/swiperefresh/SwipeRefreshLayoutManager.java index 5db04a1a77f39c..e66132ff735d90 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/swiperefresh/SwipeRefreshLayoutManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/swiperefresh/SwipeRefreshLayoutManager.java @@ -74,15 +74,8 @@ public void setSize(ReactSwipeRefreshLayout view, int size) { } @ReactProp(name = "refreshing") - public void setRefreshing(final ReactSwipeRefreshLayout view, final boolean refreshing) { - // Use `post` otherwise the control won't start refreshing if refreshing is true when - // the component gets mounted. - view.post(new Runnable() { - @Override - public void run() { - view.setRefreshing(refreshing); - } - }); + public void setRefreshing(ReactSwipeRefreshLayout view, boolean refreshing) { + view.setRefreshing(refreshing); } @ReactProp(name = "progressViewOffset", defaultFloat = 0)