Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. public void setTradeMarketAdapter(TabletTradeMarketListAdapter marketTradeAdapter) {
  2.         marketTradeAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
  3.             @Override
  4.             public void onChanged() {
  5.                 marketTradeRecyclerView.smoothScrollToPosition(0);
  6.                 LinearLayoutManager layoutManager = (LinearLayoutManager) marketTradeRecyclerView
  7.                         .getLayoutManager();
  8.                 layoutManager.scrollToPositionWithOffset(0, 0);
  9.             }
  10.  
  11.             @Override
  12.             public void onItemRangeInserted(int positionStart, int itemCount) {
  13.                 super.onItemRangeInserted(positionStart, itemCount);
  14.                 marketTradeRecyclerView.scrollToPosition(0);
  15.             }
  16.         });
  17.         this.marketTradeRecyclerView.setAdapter(marketTradeAdapter);
  18.         marketTradeAdapter.notifyDataSetChanged();        
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement