mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-23 13:59:29 +00:00
Automatically scroll to bottom
This commit is contained in:
parent
a0feee9516
commit
e579891f73
@ -185,8 +185,8 @@ public class ConversationMessageAdapter extends RecyclerView.Adapter {
|
|||||||
if(pos < 2)
|
if(pos < 2)
|
||||||
setUserInfoVisibility(true);
|
setUserInfoVisibility(true);
|
||||||
else
|
else
|
||||||
if(mList.get(pos).getUser_id() == mList.get(pos-1).getUser_id())
|
setUserInfoVisibility(
|
||||||
setUserInfoVisibility(false);
|
!(mList.get(pos).getUser_id() == mList.get(pos-1).getUser_id()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,6 +112,11 @@ public class ConversationFragment extends Fragment
|
|||||||
*/
|
*/
|
||||||
private RecyclerView convMessRecyclerView;
|
private RecyclerView convMessRecyclerView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Conversation messages layout manager
|
||||||
|
*/
|
||||||
|
private LinearLayoutManager mLinearLayoutManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Conversation messages helper
|
* Conversation messages helper
|
||||||
*/
|
*/
|
||||||
@ -231,8 +236,11 @@ public class ConversationFragment extends Fragment
|
|||||||
messagesList, userID);
|
messagesList, userID);
|
||||||
|
|
||||||
//Apply adapter
|
//Apply adapter
|
||||||
convMessRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
|
mLinearLayoutManager = new LinearLayoutManager(getActivity());
|
||||||
|
convMessRecyclerView.setLayoutManager(mLinearLayoutManager);
|
||||||
convMessRecyclerView.setAdapter(convMessAdapter);
|
convMessRecyclerView.setAdapter(convMessAdapter);
|
||||||
|
mLinearLayoutManager.setStackFromEnd(true);
|
||||||
|
|
||||||
|
|
||||||
//Get new messages input fields
|
//Get new messages input fields
|
||||||
new_message_content = view.findViewById(R.id.fragment_conversation_newmessage_content);
|
new_message_content = view.findViewById(R.id.fragment_conversation_newmessage_content);
|
||||||
@ -283,7 +291,7 @@ public class ConversationFragment extends Fragment
|
|||||||
|
|
||||||
|
|
||||||
//Set a listener to detect when the user reaches the top of the conversation
|
//Set a listener to detect when the user reaches the top of the conversation
|
||||||
//convMessRecyclerView.setOnScrollChangeDetectListener(this);
|
//TODO : add reach top listener
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -357,6 +365,9 @@ public class ConversationFragment extends Fragment
|
|||||||
|
|
||||||
//Make sure we have got information about all the members of the conversation
|
//Make sure we have got information about all the members of the conversation
|
||||||
refreshUserInfo();
|
refreshUserInfo();
|
||||||
|
|
||||||
|
//Scroll to bottom
|
||||||
|
convMessRecyclerView.scrollToPosition(messagesList.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
android:divider="@null"
|
android:divider="@null"
|
||||||
android:stackFromBottom="true"
|
android:stackFromBottom="true"
|
||||||
android:transcriptMode="alwaysScroll"
|
android:transcriptMode="alwaysScroll"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- Send messages form -->
|
<!-- Send messages form -->
|
||||||
|
Loading…
Reference in New Issue
Block a user