Revert improperly removed code for Message Request footer.

This commit is contained in:
Cody Henthorne 2020-06-17 15:50:29 -04:00 committed by Alan Evans
parent a6384d1b73
commit 0fbc6ac151

View File

@ -212,6 +212,8 @@ public class ConversationFragment extends Fragment {
this::handleReplyMessage this::handleReplyMessage
).attachToRecyclerView(list); ).attachToRecyclerView(list);
setupListLayoutListeners();
this.conversationViewModel = ViewModelProviders.of(requireActivity(), new ConversationViewModel.Factory()).get(ConversationViewModel.class); this.conversationViewModel = ViewModelProviders.of(requireActivity(), new ConversationViewModel.Factory()).get(ConversationViewModel.class);
conversationViewModel.getMessages().observe(this, list -> { conversationViewModel.getMessages().observe(this, list -> {
if (getListAdapter() != null && !list.getDataSource().isInvalid()) { if (getListAdapter() != null && !list.getDataSource().isInvalid()) {
@ -226,6 +228,22 @@ public class ConversationFragment extends Fragment {
return view; 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() { private void setListVerticalTranslation() {
if (list.canScrollVertically(1) || list.canScrollVertically(-1) || list.getChildCount() == 0) { if (list.canScrollVertically(1) || list.canScrollVertically(-1) || list.getChildCount() == 0) {
list.setTranslationY(0); list.setTranslationY(0);