Source:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View view = inflater.inflate(R.layout.media_grid_fragment, container, false); mRecycler = view.findViewById(R.id.recycler); mRecycler.setHasFixedSize(true); int numColumns = MediaGridAdapter.getColumnCount(getActivity()); mGridManager = new GridLayoutManager(getActivity(), numColumns); mRecycler.setLayoutManager(mGridManager); mRecycler.setAdapter(getAdapter()); mRecycler.setEmptyView(view.findViewById(R.id.empty_view)); final int minDistance = WPMediaUtils.getFlingDistanceToDisableThumbLoading(getActivity()); mRecycler.setOnFlingListener(new RecyclerView.OnFlingListener() { @Override public boolean onFling(int velocityX, int velocityY) { if (Math.abs(velocityY) > minDistance) { getAdapter().setLoadThumbnails(false); } return false; } }); mRecycler.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); if (newState == RecyclerView.SCROLL_STATE_IDLE) { getAdapter().setLoadThumbnails(true); } } }); mEmptyView = (TextView) view.findViewById(R.id.empty_view); mSwipeToRefreshHelper = buildSwipeToRefreshHelper( (CustomSwipeRefreshLayout) view.findViewById(R.id.ptr_layout), new RefreshListener() { @Override public void onRefreshStarted() { if (!isAdded()) { return; } if (!NetworkUtils.checkConnection(getActivity())) { updateEmptyView(EmptyViewMessageType.NETWORK_ERROR); setRefreshing(false); return; } fetchMediaList(false); } } ); if (savedInstanceState != null) { restoreState(savedInstanceState); } setFilter(mFilter); return view; }

Target:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View view = inflater.inflate(R.layout.media_grid_fragment, container, false); mRecycler = view.findViewById(R.id.recycler); mRecycler.setHasFixedSize(true); int numColumns = MediaGridAdapter.getColumnCount(getActivity()); mGridManager = new GridLayoutManager(getActivity(), numColumns); mRecycler.setLayoutManager(mGridManager); mRecycler.setAdapter(getAdapter()); final int minDistance = WPMediaUtils.getFlingDistanceToDisableThumbLoading(getActivity()); mRecycler.setOnFlingListener(new RecyclerView.OnFlingListener() { @Override public boolean onFling(int velocityX, int velocityY) { if (Math.abs(velocityY) > minDistance) { getAdapter().setLoadThumbnails(false); } return false; } }); mRecycler.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); if (newState == RecyclerView.SCROLL_STATE_IDLE) { getAdapter().setLoadThumbnails(true); } } }); mEmptyView = (TextView) view.findViewById(R.id.empty_view); mRecycler.setEmptyView(mEmptyView); mSwipeToRefreshHelper = buildSwipeToRefreshHelper( (CustomSwipeRefreshLayout) view.findViewById(R.id.ptr_layout), new RefreshListener() { @Override public void onRefreshStarted() { if (!isAdded()) { return; } if (!NetworkUtils.checkConnection(getActivity())) { updateEmptyView(EmptyViewMessageType.NETWORK_ERROR); setRefreshing(false); return; } fetchMediaList(false); } } ); if (savedInstanceState != null) { restoreState(savedInstanceState); } setFilter(mFilter); return view; }