I have implemented a recyclerView . How do I add footer progressBar at the bottom of my recyclerView with my existing code .I know that the same can be achieved in a listview using addFooterView(View v) method.How can I achieve the same in this existing code .I have looked at examples like - Android 5.0 - Add header/footer to a RecyclerView on the web,but did not understand them properly and the procedure to use it with my existing code.I am looking for a simpler explaination. I want to achieve this functionality in my existing code.Please edit it and tell me what changes are need to be made.
My Adapter
public class PostAdapter extends RecyclerView.Adapter<PostAdapter.PostHandler> {
private LayoutInflater inflater;
Context context;
public PostAdapter(Context con) {
context = con;
inflater = LayoutInflater.from(context);
}
@Override
public PostHandler onCreateViewHolder(ViewGroup parent, int viewType) {
View v = inflater.inflate(R.layout.post_row, parent, false);
PostHandler postHandler = new PostHandler(v);
return postHandler;
}
@Override
public void onBindViewHolder(final PostHandler holder, final int position) {
//The bind actions set text and others happen here...
}
@Override
public int getItemCount() {
return FreshPostContainer.getInstance().getPosts().size();
}
class PostHandler extends RecyclerView.ViewHolder {
SimpleDraweeView mprofilePic;
TextView mpostAuthor;
;
public PostHandler(View itemView) {
super(itemView);
mprofilePic = (SimpleDraweeView) itemView.findViewById(R.id.post_profilePic);
mpostAuthor = (TextView) itemView.findViewById(R.id.post_authorName);
}
}
}
MyEndless Scroller
public abstract class EndlessOnScrollRecycler extends RecyclerView.OnScrollListener {
boolean mloading;
private final int AUTO_LOAD_THRESHOLD = 5;
private LinearLayoutManager mlinearLayoutManager;
int firstVisibleItem, visibleItemCount, totalItemCount;
public EndlessOnScrollRecycler(LinearLayoutManager linearLayoutManager) {
this.mlinearLayoutManager = linearLayoutManager;
}
public void setLoading(boolean loading) {
this.mloading = loading;
}
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
visibleItemCount = recyclerView.getChildCount();
totalItemCount = mlinearLayoutManager.getItemCount();
firstVisibleItem = mlinearLayoutManager.findLastVisibleItemPosition();
if (!mloading) {
if (totalItemCount - AUTO_LOAD_THRESHOLD <= firstVisibleItem + visibleItemCount) {
loading();
setLoading(true);
}
}
}
protected abstract void loading();
}