I have a simple code with a RecyclerView, CardView, and an adapter. And I retrieve the data from the Firestore.
Problem:
I have a publishing feed, for example. And in this feed I have a button that takes another screen.
In this second screen I use as a return method: Finish.
But the problem is that the feed is large and coming back from the second screen to the first screen, RecyclerView goes to the beginning.
Is there any way I can not start the RecyclerView on top when I return to the activity that contains the feed?
Sample Image:
1 - First screen where it is clicked to see users who enjoyed a post. (This screen is a fragment.)
2 - List screen of users who liked the post.
3 - The first screen, but after you return. This screen always returns to the top.
Thanks!!
EDIT:
Code adapter + recyclerview in Fragment:
/* Recycler */
mCardFeedList = (RecyclerView) view.findViewById(id.cardFeedUser_list);
mCardFeedList.setHasFixedSize(true);
mCardFeedList.setItemViewCacheSize(20);
mCardFeedList.setDrawingCacheEnabled(true);
mAdapter = new PostsAdapter(mQueryNew, this){
@Override
protected void onDataChanged() {
if (getItemCount() == 0) {
mCardFeedList.setVisibility(View.GONE);
//mTxtVazio.setVisibility(View.VISIBLE);
} else {
mCardFeedList.setVisibility(View.VISIBLE);
//mTxtVazio.setVisibility(View.GONE);
}
}
};
mCardFeedList.setLayoutManager(new LinearLayoutManager(getActivity().getApplication()));
mCardFeedList.setAdapter(mAdapter);