How to add pull to refresh in Coordinator layout

You can disable swipe refresh layout when AppBar isn't fully expanded and enable it if it is fully expanded.

vAppBar.addOnOffsetChangedListener(AppBarLayout.OnOffsetChangedListener { _, verticalOffset ->
   vSwipeRefresh.isEnabled = verticalOffset == 0
}) 

I add swipetorefresh top level like answer above. And I fix my scroll up issue with code below. Thanks to mohammadReza :)

recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener(){
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            int topRowVerticalPosition =
                    (recyclerView == null || recyclerView.getChildCount() == 0) ? 0 : recyclerView.getChildAt(0).getTop();
            swipeRefreshLayout.setEnabled(topRowVerticalPosition >= 0);

        }

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
        }
    });