mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2025-06-19 00:25:18 +00:00
ScrollListView can detect when the user reach the bottom on the list.
This commit is contained in:
@ -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
|
||||
*
|
||||
|
@ -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();
|
||||
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user