Revert improperly removed code for Message Request footer.

master
Cody Henthorne 2020-06-17 15:50:29 -04:00 committed by Alan Evans
parent a6384d1b73
commit 0fbc6ac151
1 changed files with 18 additions and 0 deletions

View File

@ -212,6 +212,8 @@ public class ConversationFragment extends Fragment {
this::handleReplyMessage
).attachToRecyclerView(list);
setupListLayoutListeners();
this.conversationViewModel = ViewModelProviders.of(requireActivity(), new ConversationViewModel.Factory()).get(ConversationViewModel.class);
conversationViewModel.getMessages().observe(this, list -> {
if (getListAdapter() != null && !list.getDataSource().isInvalid()) {
@ -226,6 +228,22 @@ public class ConversationFragment extends Fragment {
return view;
}
private void setupListLayoutListeners() {
list.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> setListVerticalTranslation());
list.addOnChildAttachStateChangeListener(new RecyclerView.OnChildAttachStateChangeListener() {
@Override
public void onChildViewAttachedToWindow(@NonNull View view) {
setListVerticalTranslation();
}
@Override
public void onChildViewDetachedFromWindow(@NonNull View view) {
setListVerticalTranslation();
}
});
}
private void setListVerticalTranslation() {
if (list.canScrollVertically(1) || list.canScrollVertically(-1) || list.getChildCount() == 0) {
list.setTranslationY(0);