Skip to content

Instantly share code, notes, and snippets.

@jessejohnson
Created November 27, 2015 07:59
Show Gist options
  • Save jessejohnson/89078844d02ee6a64578 to your computer and use it in GitHub Desktop.
Save jessejohnson/89078844d02ee6a64578 to your computer and use it in GitHub Desktop.
A trivial Endless Scrolling RecyclerView
/**
* Created by odette on 10/28/15.
*/
public class ContentFragment extends Fragment {
public static ContentFragment newInstance(){
return fragment;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_content, container, false);
recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
recyclerView.setHasFixedSize(true);
final LinearLayoutManager llm = new LinearLayoutManager(getActivity());
llm.setOrientation(LinearLayoutManager.VERTICAL);
recyclerView.setLayoutManager(llm);
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if(llm.findLastCompletelyVisibleItemPosition() == dataArray.length() -1){
Log.d(TAG, "At bottom of list!");
//TODO load data here
}
}
});
return view;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment