@@ -151,16 +151,18 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
151
151
public void onScrollStateChanged (RecyclerView recyclerView , int newState ) {
152
152
mListener .recyclerViewScrolled ();
153
153
final int near = 6 ;
154
- if (!paused && !loadingMessages && firstMessageId > 0 && lastMessageId > 0 ) {
155
- int lastVisiblePosition = linearLayoutManager .findLastVisibleItemPosition ();
156
- if (lastVisiblePosition > adapter .getItemCount (false ) - near ) { // At the bottom of the list
157
- Log .i ("scroll" , "Starting request below" );
158
- loadMoreMessages (LoadPosition .BELOW );
159
- }
160
- if (linearLayoutManager .findFirstCompletelyVisibleItemPosition () < near && !loadedToTop ) {
161
- // At the top of the list
162
- Log .i ("scroll" , "Starting request above" );
163
- loadMoreMessages (LoadPosition .ABOVE );
154
+ if (newState == RecyclerView .SCROLL_STATE_IDLE ) {
155
+ if (!paused && !loadingMessages && firstMessageId > 0 && lastMessageId > 0 ) {
156
+ int lastVisiblePosition = linearLayoutManager .findLastVisibleItemPosition ();
157
+ if (lastVisiblePosition > adapter .getItemCount (false ) - near ) { // At the bottom of the list
158
+ Log .i ("scroll" , "Starting request below" );
159
+ loadMoreMessages (LoadPosition .BELOW );
160
+ }
161
+ if (linearLayoutManager .findFirstCompletelyVisibleItemPosition () < near && !loadedToTop ) {
162
+ // At the top of the list
163
+ Log .i ("scroll" , "Starting request above" );
164
+ loadMoreMessages (LoadPosition .ABOVE );
165
+ }
164
166
}
165
167
}
166
168
}
@@ -360,7 +362,7 @@ public void onMessages(Message[] messages, LoadPosition pos,
360
362
}
361
363
362
364
if (pos == LoadPosition .NEW || pos == LoadPosition .BELOW ) {
363
- this .adapter .addMessage (message );
365
+ this .adapter .addNewMessage (message );
364
366
messageList .add (message );
365
367
} else if (pos == LoadPosition .ABOVE || pos == LoadPosition .INITIAL ) {
366
368
headerParents = (this .adapter .addMessage (message , addedCount + headerParents )) ? headerParents + 1 : headerParents ;
0 commit comments