Skip to content

Update selected list in LeftDrawerMgr when switching pages #181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public class HomePagerActivity extends CalendulaActivity implements
private LeftDrawerMgr drawerMgr;
private Patient activePatient;
private int pendingRefresh = -2;
private int pagerPositionNow = 0;
private Queue<Object> pendingEvents = new LinkedList<>();
private Handler handler;

Expand Down Expand Up @@ -580,6 +581,7 @@ public void onPageScrolled(int position, float positionOffset, int positionOffse
public void onPageSelected(int position) {
updateTitle(position);
updateScrim(position);
pagerPositionNow = position;
fabMgr.onViewPagerItemChange(position);
if (position == HomePages.HOME.ordinal() && !((DailyAgendaFragment) getViewPagerFragment(HomePages.HOME)).isExpanded()) {
appBarLayout.setExpanded(true);
Expand All @@ -591,6 +593,7 @@ public void onPageSelected(int position) {
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) appBarLayout.getLayoutParams();
((DisableableAppBarLayoutBehavior) layoutParams.getBehavior()).setEnabled(false);
}
drawerMgr.changePageSelected(position);

invalidateOptionsMenu();
}
Expand Down Expand Up @@ -644,6 +647,12 @@ private void launchActivity(Intent i) {
this.overridePendingTransition(0, 0);
}

@Override
protected void onResumeFragments() {
super.onResumeFragments();
drawerMgr.changePageSelected(pagerPositionNow);
}

/*
public void askForWEEPermissionsIfNeeded() {
String p = Manifest.permission.WRITE_EXTERNAL_STORAGE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,23 @@ public void onPagerPositionChange(int pagerPosition) {
}
}

public void changePageSelected(int pagerPosition) {
switch (pagerPosition) {
case 0:
drawer.setSelection(HOME, false);
break;
case 1:
drawer.setSelection(MEDICINES, false);
break;
case 2:
drawer.setSelection(ROUTINES, false);
break;
case 3:
drawer.setSelection(SCHEDULES, false);
break;
}
}

@Override
public boolean onProfileChanged(View view, IProfile profile, boolean current) {

Expand Down