Skip to content

Commit

Permalink
Fix Issue #859:Enabled menu item on selection
Browse files Browse the repository at this point in the history
  • Loading branch information
AkshGautam authored and therajanmaurya committed Aug 15, 2018
1 parent 78fb231 commit a994468
Showing 1 changed file with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class DashboardActivity extends MifosBaseActivity
SwitchCompat userStatusToggle;
private Menu menu;
private boolean doubleBackToExitPressedOnce = false;
private boolean itemClient = true, itemCenter = true, itemGroup = true;

@Override
public void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -93,19 +94,26 @@ public void onBackStackChanged() {
Fragment fragment = fragmentManager.findFragmentById(R.id.container);
if (fragment instanceof CreateNewClientFragment) {
setActionBarTitle(R.string.create_client);
setMenuCreateClient(false);
setMenuCreateCentre(true);
setMenuCreateGroup(true);
itemClient = false;
itemGroup = true;
itemCenter = true;
invalidateOptionsMenu();
} else if (fragment instanceof CreateNewGroupFragment) {
setActionBarTitle(R.string.create_group);
setMenuCreateClient(true);
setMenuCreateCentre(true);
setMenuCreateGroup(false);
itemClient = true;
itemGroup = false;
itemCenter = true;
invalidateOptionsMenu();
} else if (fragment instanceof CreateNewCenterFragment) {
setActionBarTitle(R.string.create_center);
setMenuCreateClient(true);
setMenuCreateCentre(false);
setMenuCreateGroup(true);
itemClient = true;
itemGroup = true;
itemCenter = false;
invalidateOptionsMenu();
} else {
itemClient = true;
itemGroup = true;
itemCenter = true;
}
}
});
Expand Down Expand Up @@ -319,6 +327,9 @@ public boolean onCreateOptionsMenu(Menu menu) {
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
hideKeyboard(mDrawerLayout);
menu.getItem(0).setEnabled(itemClient);
menu.getItem(1).setEnabled(itemCenter);
menu.getItem(2).setEnabled(itemGroup);
return super.onPrepareOptionsMenu(menu);
}

Expand Down

0 comments on commit a994468

Please sign in to comment.