android - How programmatically know that recyclerview is scrolled position is bottom of recyclerview to execute following function -


which statement should put in "recyclerview_position_is_bottem" satisfy condition recyclerview position bottem execute function

recyclerview.addonscrolllistener(new recyclerview.onscrolllistener() {                 @override                 public void onscrolled(recyclerview recyclerview, int dx, int dy) {                      super.onscrolled(recyclerview, dx, dy);                     if (recyclerview_position_is_bottem){                         isscrolled=0;                         skip = skip + 5;                                 remove = 1;                                 feeditems.add(null);                                 eventsrecyclerview.notifyiteminserted(feeditems.size());                                 handler.postdelayed(new runnable() {                                     @override                                     public void run() {                                         loadmore(eventsrecyclerview,1);                                      }                                 }, 500);                           }                  }               }); 

first / last visible child depends on layoutmanager. if using linearlayoutmanager or gridlayoutmanager, can use

int findfirstvisibleitemposition(); int findfirstcompletelyvisibleitemposition(); int findlastvisibleitemposition(); int findlastcompletelyvisibleitemposition(); 

for example:

gridlayoutmanager layoutmanager = ((gridlayoutmanager)mrecyclerview.getlayoutmanager()); int firstvisibleposition = layoutmanager.findlastcompletelyvisibleitemposition(); 

for linearlayoutmanager, first/last depends on adapter ordering. don't query children recyclerview; layoutmanager may prefered layout more items visible caching.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -