diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/ConversationMessageAdapter.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/ConversationMessageAdapter.java index d05fc6c..ea11eb9 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/ConversationMessageAdapter.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/ConversationMessageAdapter.java @@ -185,8 +185,8 @@ public class ConversationMessageAdapter extends RecyclerView.Adapter { if(pos < 2) setUserInfoVisibility(true); else - if(mList.get(pos).getUser_id() == mList.get(pos-1).getUser_id()) - setUserInfoVisibility(false); + setUserInfoVisibility( + !(mList.get(pos).getUser_id() == mList.get(pos-1).getUser_id())); } } } diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/ConversationFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/ConversationFragment.java index b214cce..b3a6f35 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/ConversationFragment.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/ConversationFragment.java @@ -112,6 +112,11 @@ public class ConversationFragment extends Fragment */ private RecyclerView convMessRecyclerView; + /** + * Conversation messages layout manager + */ + private LinearLayoutManager mLinearLayoutManager; + /** * Conversation messages helper */ @@ -231,8 +236,11 @@ public class ConversationFragment extends Fragment messagesList, userID); //Apply adapter - convMessRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); + mLinearLayoutManager = new LinearLayoutManager(getActivity()); + convMessRecyclerView.setLayoutManager(mLinearLayoutManager); convMessRecyclerView.setAdapter(convMessAdapter); + mLinearLayoutManager.setStackFromEnd(true); + //Get new messages input fields 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 - //convMessRecyclerView.setOnScrollChangeDetectListener(this); + //TODO : add reach top listener } @Override @@ -357,6 +365,9 @@ public class ConversationFragment extends Fragment //Make sure we have got information about all the members of the conversation refreshUserInfo(); + + //Scroll to bottom + convMessRecyclerView.scrollToPosition(messagesList.size() - 1); } @Override diff --git a/app/src/main/res/layout/fragment_conversation.xml b/app/src/main/res/layout/fragment_conversation.xml index 7ac3ae0..cd4bb01 100644 --- a/app/src/main/res/layout/fragment_conversation.xml +++ b/app/src/main/res/layout/fragment_conversation.xml @@ -35,6 +35,7 @@ android:divider="@null" android:stackFromBottom="true" android:transcriptMode="alwaysScroll" + android:layout_marginBottom="5dp" />