Fix SwipeRefreshLayout and ListView interaction.

Scrolling interaction works out of the box only if ListView is the only
child of SwipeRefreshLayout.
See https://stackoverflow.com/a/26296897
This commit is contained in:
leopoldsedev
2020-02-10 16:07:42 +01:00
committed by Jannis Mattheis
parent 737ad194e9
commit f8422f4ef1

View File

@@ -154,6 +154,20 @@ public class MessagesActivity extends AppCompatActivity
} }
} }
}); });
swipeRefreshLayout.setEnabled(false);
messagesView
.getViewTreeObserver()
.addOnScrollChangedListener(
() -> {
View topChild = messagesView.getChildAt(0);
if (topChild != null) {
swipeRefreshLayout.setEnabled(topChild.getTop() == 0);
} else {
swipeRefreshLayout.setEnabled(true);
}
});
new SelectApplicationAndUpdateMessages(true).execute(appId); new SelectApplicationAndUpdateMessages(true).execute(appId);
} }