Skip to content

Commit

Permalink
Merge branch 'fix/garden-select' into develop
Browse files Browse the repository at this point in the history
* fix/garden-select:
  Prevent double item selection when adding new garden
  • Loading branch information
7LPdWcaW committed Jan 23, 2019
2 parents dc0c875 + fb266c6 commit 26e4d69
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/src/main/java/me/anon/grow/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ else if (item.getItemId() == R.id.add)
GardenManager.getInstance().getGardens().set(index, garden);
}

MenuItem item = navigation.getMenu().findItem(selectedItem);

if (item != null)
{
item.setChecked(false);
}

selectedItem = 100 + index;

setNavigationView();
Expand Down Expand Up @@ -250,7 +257,14 @@ else if (item.getItemId() >= 100 && item.getItemId() < Integer.MAX_VALUE)
{
navigation.getMenu().findItem(R.id.garden_menu).getSubMenu().findItem(R.id.all).setChecked(false);

MenuItem selected = navigation.getMenu().findItem(selectedItem);
if (selected != null)
{
selected.setChecked(false);
}

selectedItem = item.getItemId();
item.setChecked(true);
int gardenIndex = item.getItemId() - 100;
getFragmentManager().beginTransaction().replace(R.id.fragment_holder, PlantListFragment.newInstance(GardenManager.getInstance().getGardens().get(gardenIndex)), TAG_FRAGMENT).commit();
}
Expand Down

0 comments on commit 26e4d69

Please sign in to comment.