diff options
author | BrettyWhite <geekman3454@protonmail.com> | 2019-05-23 14:08:38 -0400 |
---|---|---|
committer | BrettyWhite <geekman3454@protonmail.com> | 2019-05-23 14:08:38 -0400 |
commit | e1ebfb371cbe27bc7f0e49595297ec932f58b92a (patch) | |
tree | 66e3b4232bb0547fc5e7442c0cb63024881b8b41 | |
parent | 364c3d3faa90ddd88bf105af127cc3e761fde4f9 (diff) | |
download | sdl_android-e1ebfb371cbe27bc7f0e49595297ec932f58b92a.tar.gz |
fix ID setting for added cells in existing sub menu
-rw-r--r-- | base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseMenuManager.java | 12 | ||||
-rw-r--r-- | base/src/main/java/com/smartdevicelink/managers/screen/menu/SubCellCommandLists.java | 12 |
2 files changed, 19 insertions, 5 deletions
diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseMenuManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseMenuManager.java index fd2a7b307..0d5a89693 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseMenuManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseMenuManager.java @@ -375,7 +375,7 @@ abstract class BaseMenuManager extends BaseSubManager { if (subScore != null){ DebugTool.logInfo("Sub menu Run Score: "+ oldKeptCell.getTitle()+ " Score: "+ subScore.getScore()); - SubCellCommandLists commandList = new SubCellCommandLists(oldKeptCell.getTitle(), subScore, oldKeptCell.getSubCells(), keptCell.getSubCells()); + SubCellCommandLists commandList = new SubCellCommandLists(oldKeptCell.getTitle(), oldKeptCell.getCellId(), subScore, oldKeptCell.getSubCells(), keptCell.getSubCells()); commandLists.add(commandList); } } @@ -441,7 +441,7 @@ abstract class BaseMenuManager extends BaseSubManager { subCellKeepsNew.add(newCells.get(x)); } } - final List<MenuCell> addsWithNewIds = updateIdsOnDynamicSubCells(oldCells, adds); + final List<MenuCell> addsWithNewIds = updateIdsOnDynamicSubCells(oldCells, adds, commandList.getParentId()); // this is needed for the onCommands to still work transferIdsToKeptSubCells(oldCells, subCellKeepsNew); @@ -608,7 +608,7 @@ abstract class BaseMenuManager extends BaseSubManager { return null; } - private List<MenuCell> updateIdsOnDynamicSubCells(List<MenuCell> oldList, List<MenuCell> dynamicCells){ + private List<MenuCell> updateIdsOnDynamicSubCells(List<MenuCell> oldList, List<MenuCell> dynamicCells, Integer parentId){ if (oldList != null && oldList.size() > 0 && dynamicCells != null && dynamicCells.size() > 0) { for (int z = 0; z < oldList.size(); z++) { MenuCell mainCell = oldList.get(z); @@ -616,8 +616,12 @@ abstract class BaseMenuManager extends BaseSubManager { MenuCell dynamicCell = dynamicCells.get(i); if (mainCell.equals(dynamicCell)) { int newId = ++lastMenuId; - dynamicCells.get(i).setParentCellId(oldList.get(z).getParentCellId()); oldList.get(z).setCellId(newId); + dynamicCells.get(i).setParentCellId(parentId); + dynamicCells.get(i).setCellId(newId); + }else{ + int newId = ++lastMenuId; + dynamicCells.get(i).setParentCellId(parentId); dynamicCells.get(i).setCellId(newId); } } diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/menu/SubCellCommandLists.java b/base/src/main/java/com/smartdevicelink/managers/screen/menu/SubCellCommandLists.java index d2c478780..d77fc60ef 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/menu/SubCellCommandLists.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/menu/SubCellCommandLists.java @@ -38,15 +38,25 @@ class SubCellCommandLists { private RunScore listsScore; private String menuTitle; + private Integer parentId; private List<MenuCell> oldList, newList; - SubCellCommandLists(String menuTitle, RunScore listsScore, List<MenuCell> oldList, List<MenuCell> newList){ + SubCellCommandLists(String menuTitle, Integer parentId, RunScore listsScore, List<MenuCell> oldList, List<MenuCell> newList){ setMenuTitle(menuTitle); + setParentId(parentId); setListsScore(listsScore); setOldList(oldList); setNewList(newList); } + private void setParentId(Integer parentId) { + this.parentId = parentId; + } + + Integer getParentId() { + return parentId; + } + private void setMenuTitle(String menuTitle) { this.menuTitle = menuTitle; } |