java – How to get the key value of the firebase node from the recyclerview position?

I use OnScrollListener for recyclerview to get the position of the current visible element on the screen

Protected void onCreate (Bundle savedInstanceState)
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_main);

postList = (RecyclerView) findViewById (;
final LinearLayoutManager linearLayoutManager = new LinearLayoutManager (this);
postList.setLayoutManager (linearLayoutManager);

postList.addOnScrollListener (new RecyclerView.OnScrollListener () {
public void onScrollStateChanged (@NoNull RecyclerView recycleView, int newState) {
super.onScrollStateChanged (recyclerView, newState);

switch (newState) {
case RecyclerView.SCROLL_STATE_IDLE:
System.out.println ("The RecyclerView does not scroll");
LinearLayoutManager layoutManager = (((LinearLayoutManager) postList.getLayoutManager ());

firstVisiblePosition = layoutManager.findFirstVisibleItemPosition ();

Toast.makeText (MainActivity.this, String.valueOf (firstVisiblePosition), Toast.LENGTH_SHORT) .show (); ** // Here is the position // **
System.out.println ("Scrolling now");
System.out.println ("Scroll Settling");

public void onScrolled (@NoNull RecyclerView recycleView, int dx, int dy) {
super.onScrolled (recyclerView, dx, dy);

Query sortPost = PostRef
FirebaseRecyclerOptions options = new FirebaseRecyclerOptions.Builder() .setQuery (sortPost, Post.class) .build ();
FirebaseRecyclerAdapter firebaseRecyclerAdapter = new FirebaseRecyclerAdapter(Options)
onBindViewHolder protected void (@ PostsViewHolder final @NonNull holder, final final position, final post template @NonNull)

final String PostKey = getRef (position) .getKey ();

in the onBindViewHolder method, I get the postkey of the getRef () method.

But now, I also want to recover the recyclerview post-key.
Means whenever SCROLL_STATE_IDLE I want to retrieve the post-key from the visible position of recyclerview (firstVisiblePosition).