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:
committed by
Jannis Mattheis
parent
737ad194e9
commit
f8422f4ef1
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user