mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
[Contributions-Tab] Scroll to top on NavBar Button Pressed (#4668)
* [Contributions-Tab] Scroll to top on NavBar Button Pressed On NavBar Contributions Button pressed, if already on the Contributions tab, scroll to the top of the recyclerView in ContributionsListFragment. * [UnitTest][Contributions-Tab] Scroll to Top on NavBar Button Pressed
This commit is contained in:
parent
88b21a678e
commit
55c0b07ebf
6 changed files with 47 additions and 1 deletions
|
|
@ -204,6 +204,12 @@ public class ContributionsFragment
|
|||
throwable -> Timber.e(throwable, "Error occurred while loading notifications")));
|
||||
}
|
||||
|
||||
public void scrollToTop( ){
|
||||
if (contributionsListFragment != null) {
|
||||
contributionsListFragment.scrollToTop();
|
||||
}
|
||||
}
|
||||
|
||||
private void initNotificationViews(List<Notification> notificationList) {
|
||||
Timber.d("Number of notifications is %d", notificationList.size());
|
||||
if (notificationList.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -312,6 +312,10 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl
|
|||
animateFAB(isFabOpen);
|
||||
}
|
||||
|
||||
public void scrollToTop() {
|
||||
rvContributionsList.smoothScrollToPosition(0);
|
||||
}
|
||||
|
||||
private void animateFAB(final boolean isFabOpen) {
|
||||
this.isFabOpen = !isFabOpen;
|
||||
if (fabPlus.isShown()) {
|
||||
|
|
|
|||
|
|
@ -163,7 +163,9 @@ public class MainActivity extends BaseActivity
|
|||
//showBottom so that we do not show the bottom tray again when constructing
|
||||
//from the saved instance state.
|
||||
if (fragment instanceof ContributionsFragment) {
|
||||
if (activeFragment == ActiveFragment.CONTRIBUTIONS) { // Do nothing if same tab
|
||||
if (activeFragment == ActiveFragment.CONTRIBUTIONS) {
|
||||
// scroll to top if already on the Contributions tab
|
||||
contributionsFragment.scrollToTop();
|
||||
return true;
|
||||
}
|
||||
contributionsFragment = (ContributionsFragment) fragment;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue