ScrollListView can detect when the user reach the bottom on the list.

This commit is contained in:
Pierre HUBERT
2018-07-04 09:06:27 +02:00
parent 767a3b47f5
commit 128b05e3df
6 changed files with 23 additions and 63 deletions

View File

@ -354,9 +354,7 @@ public class ConversationFragment extends Fragment
display_not_msg_notice(false);
//Add the messages to the the main list of messages
for(ConversationMessage message : newMessages){
messagesList.add(message);
}
messagesList.addAll(newMessages);
convMessAdapter.notifyDataSetChanged();
last_message_id = lastID;
@ -654,6 +652,11 @@ public class ConversationFragment extends Fragment
}
@Override
public void onReachBottom() {
}
/**
* Actions to do once we downloaded older messages from the server
*

View File

@ -16,4 +16,9 @@ public interface OnScrollChangeDetectListener {
*/
void onReachTop();
/**
* This method is triggered when the user reach the bottom (last item) of the list view
*/
void onReachBottom();
}

View File

@ -79,9 +79,16 @@ public class ScrollListView extends android.widget.ListView {
visibleItemCount, totalItemCount);
//Check if the user reached the top of the view
if(onScrollChangeDetectListener != null && firstVisibleItem == 0
&& visibleItemCount > 0)
onScrollChangeDetectListener.onReachTop();
//Check if the user reached the bottom of the view
if(onScrollChangeDetectListener != null && totalItemCount > 0 &&
firstVisibleItem + visibleItemCount == totalItemCount)
onScrollChangeDetectListener.onReachBottom();
}
});