Skip to content

Commit

Permalink
Check whether spell filter status is null before getting list count.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carifio24 committed Feb 15, 2024
1 parent 7ad1386 commit 322aaf8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions app/src/main/java/dnd/jon/spellbook/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -919,19 +919,22 @@ private void setSideMenuTextWithCount(int menuItemId, int textId, int count) {
}

private void updateMenuFavoriteCounts() {
final int count = viewModel.getSpellFilterStatus().favoriteSpellIDs().size();
final SpellFilterStatus status = viewModel.getSpellFilterStatus();
final int count = status != null ? status.favoriteSpellIDs().size() : 0;
setSideMenuTextWithCount(id.nav_favorites, string.favorites, count);
setBottomNavTextWithCount(id.action_select_favorites, string.favorites, count);
}

private void updateMenuPreparedCounts() {
final int count = viewModel.getSpellFilterStatus().preparedSpellIDs().size();
final SpellFilterStatus status = viewModel.getSpellFilterStatus();
final int count = status != null ? status.preparedSpellIDs().size() : 0;
setSideMenuTextWithCount(id.nav_prepared, string.prepared, count);
setBottomNavTextWithCount(id.action_select_prepared, string.prepared, count);
}

private void updateMenuKnownCounts() {
final int count = viewModel.getSpellFilterStatus().knownSpellIDs().size();
final SpellFilterStatus status = viewModel.getSpellFilterStatus();
final int count = status != null ? status.knownSpellIDs().size() : 0;
setSideMenuTextWithCount(id.nav_known, string.known, count);
setBottomNavTextWithCount(id.action_select_known, string.known, count);
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@
<string name="update_03_05_00_title">Atualização da versão 3.5.0</string>
<string name="update_03_05_00_description">O livro de feitiços foi atualizado para incluir feitiços de <b>Cenário de Campanha Tal\'Dorei: Renascido</b> e <b>Sigil e as Terras Distantes</b>. Além disso, esta atualização corrige alguns pequenos bugs de interface do usuário e erros de texto.</string>
<string name="update_03_06_00_title">Atualização da versão 3.6.0</string>
<string name="update_03_06_00_description">O livro de feitiços foi atualizado com os seguintes novos recursos:\n\n\u2022A capacidade de filtrar feitiços por royalties foi adicionada\n\n\u2022A contagem de cada lista de feitiços agora pode ser mostrada ao lado do nome da lista em ambos os lados menu e a barra de navegação inferior. Isso pode ser ativado ou desativado na tela de configurações.\n\nAlém disso, esta atualização corrige alguns erros de digitação e erros no texto de algumas ortografias.</string>
<string name="update_03_06_00_description">O livro de feitiços foi atualizado com os seguintes novos recursos:\n\n\u2022A capacidade de filtrar feitiços por royalties foi adicionada.\n\n\u2022A contagem de cada lista de feitiços agora pode ser mostrada ao lado do nome da lista em ambos os lados menu e a barra de navegação inferior. Isso pode ser ativado ou desativado na tela de configurações.\n\nAlém disso, esta atualização corrige alguns erros de digitação e erros no texto de algumas ortografias.</string>

<!-- Character profile actions -->
<string name="rename">Renomear</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@
<string name="update_03_05_00_title">Version 3.5.0</string>
<string name="update_03_05_00_description">The spellbook has been updated to include spells from <b>Tal\'Dorei Campaign Setting Reborn</b> and <b>Sigil and the Outlands</b>. Additionally, this update corrects some minor UI bugs and text mistakes.</string>
<string name="update_03_06_00_title">Version 3.6.0</string>
<string name="update_03_06_00_description">The spellbook has been updated with the following new features:\n\n\u2022The ability to filter spells by royalty has been added\n\n\u2022The count for each spell list can now be shown next to the list name in both the side menu and the bottom navigation bar. This can be enabled or disabled from the settings screen.\n\nAdditionally, this update fixes some typos and mistakes in the text for a few spells.</string>
<string name="update_03_06_00_description">The spellbook has been updated with the following new features:\n\n\u2022The ability to filter spells by royalty has been added.\n\n\u2022The count for each spell list can now be shown next to the list name in both the side menu and the bottom navigation bar. This can be enabled or disabled from the settings screen.\n\nAdditionally, this update fixes some typos and mistakes in the text for a few spells.</string>

<!-- Character profile actions -->
<string name="rename">Rename</string>
Expand Down

0 comments on commit 322aaf8

Please sign in to comment.