@@ -41,7 +41,7 @@ private int getLastVisibleItem(int[] lastVisibleItemPositions) {
4141
4242 @ Override
4343 public void onScrolled (RecyclerView recyclerView , int dx , int dy ) {
44- handler . sendEmptyMessageDelayed ( 1 , 150 );
44+ //setStackFromEnd( );
4545 if (mListener != null ) {
4646 int lastVisibleItemPosition = 0 ;
4747 int firstVisibleItemPosition = 0 ;
@@ -87,29 +87,31 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
8787 @ Override
8888 public void handleMessage (Message msg ) {
8989 if (msg .what == 1 ) {
90- setStackFromEnd ();
90+ try {
91+ ll .setStackFromEnd (false );
92+ } catch (Exception e ) {
93+ e .printStackTrace ();
94+ }
95+ } else if (msg .what == 2 ){
96+ try {
97+ ll .setStackFromEnd (true );
98+ } catch (Exception e ) {
99+ e .printStackTrace ();
100+ }
91101 }
92102 }
93103 };
94-
104+ LinearLayoutManager ll ;
95105 void setStackFromEnd () {
96106 if (mLayoutManager instanceof LinearLayoutManager ) {
97- LinearLayoutManager ll = (LinearLayoutManager ) mLayoutManager ;
107+ ll = (LinearLayoutManager ) mLayoutManager ;
98108 if (ll .getStackFromEnd ()) {
99109 if (ll .getChildCount () < mLayoutManager .getItemCount ()) {
100- try {
101- ll .setStackFromEnd (false );
102- } catch (Exception e ) {
103- e .printStackTrace ();
104- }
110+ handler .sendEmptyMessageDelayed (1 ,150 );
105111 }
106112 } else {
107113 if (ll .getChildCount () >= mLayoutManager .getItemCount ()) {
108- try {
109- ll .setStackFromEnd (true );
110- } catch (Exception e ) {
111- e .printStackTrace ();
112- }
114+ handler .sendEmptyMessageDelayed (2 ,150 );
113115 }
114116 }
115117 }
0 commit comments