In a normal recyclerview, the newest items are all at the top and if you add an item into the recyclerview, it pushes the existing items down and the new item takes the top posi
I didn't really want to use a SwipeToRefreshLayout at the end as it doens't look good when you have a comment feed.
So what I did was modify the onLoadMoreListener method so that it detects when the actiivity is first started up. If it is first starting up, we do not want the progress bar to be displayed:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
initial = true;
}
}
Then we will use the initial boolean variable to determine whether the activity has just started up and disable the progress bar.
@Override
public void onLoadMore(int current_page) {
//add progress item
if (initial) {
//we do not add the progress bar when the activity opens initially so
//we do nothing. We just change the variable to false so going forward, you will add a progress bar each time you refresh
initial = false;
} else {
comments.add(createProgressBar());
mCommentAdapter.notifyItemInserted(comments.size()-1);
}