diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2021-09-08 13:41:17 -0400 |
---|---|---|
committer | Joel Fischer <joeljfischer@gmail.com> | 2021-09-08 13:41:17 -0400 |
commit | 7aacb05eb27a0624ed1506812a455be2db95bb40 (patch) | |
tree | d394031c876e393fed6c07050edd10df7fb73245 | |
parent | 61a48afdd4c586af5fef97638d3e250402167a21 (diff) | |
download | sdl_ios-7aacb05eb27a0624ed1506812a455be2db95bb40.tar.gz |
Update from review
-rw-r--r-- | SmartDeviceLink/private/SDLMenuReplaceOperation.m | 26 | ||||
-rw-r--r-- | SmartDeviceLink/public/SDLMenuCell.m | 4 | ||||
-rw-r--r-- | SmartDeviceLink/public/SDLScreenManager.m | 4 |
3 files changed, 10 insertions, 24 deletions
diff --git a/SmartDeviceLink/private/SDLMenuReplaceOperation.m b/SmartDeviceLink/private/SDLMenuReplaceOperation.m index bc50c8284..8f656c8a5 100644 --- a/SmartDeviceLink/private/SDLMenuReplaceOperation.m +++ b/SmartDeviceLink/private/SDLMenuReplaceOperation.m @@ -107,8 +107,8 @@ NS_ASSUME_NONNULL_BEGIN NSArray<SDLMenuCell *> *cellsToDelete = [self sdl_filterDeleteMenuItemsWithOldMenuItems:self.currentMenu basedOnStatusList:runScore.oldStatus]; NSArray<SDLMenuCell *> *cellsToAdd = [self sdl_filterAddMenuItemsWithNewMenuItems:self.updatedMenu basedOnStatusList:runScore.updatedStatus]; // These arrays should ONLY contain KEEPS. These will be used for SubMenu compares - NSArray<SDLMenuCell *> *oldKeeps = [self sdl_filterKeepMenuItemsWithOldMenuItems:self.currentMenu basedOnStatusList:runScore.oldStatus]; - NSArray<SDLMenuCell *> *newKeeps = [self sdl_filterKeepMenuItemsWithNewMenuItems:self.updatedMenu basedOnStatusList:runScore.updatedStatus]; + NSArray<SDLMenuCell *> *oldKeeps = [self sdl_filterKeepMenuItems:self.currentMenu basedOnStatusList:runScore.oldStatus]; + NSArray<SDLMenuCell *> *newKeeps = [self sdl_filterKeepMenuItems:self.updatedMenu basedOnStatusList:runScore.updatedStatus]; // Old kept cells ids need to be moved to the new kept cells so that submenu changes have correct parent ids [SDLMenuReplaceUtilities transferCellIDsFromCells:oldKeeps toCells:newKeeps]; @@ -186,8 +186,8 @@ NS_ASSUME_NONNULL_BEGIN NSArray<SDLMenuCell *> *cellsToAdd = [self sdl_filterAddMenuItemsWithNewMenuItems:newKeptCells[index].subCells basedOnStatusList:addMenuStatus]; // Transfer ids from subcell keeps to old subcells, which are stored in the current menu - NSArray<SDLMenuCell *> *oldSubcellKeeps = [self sdl_filterKeepMenuItemsWithOldMenuItems:oldKeptCells[index].subCells basedOnStatusList:deleteMenuStatus]; - NSArray<SDLMenuCell *> *newSubcellKeeps = [self sdl_filterKeepMenuItemsWithNewMenuItems:newKeptCells[index].subCells basedOnStatusList:addMenuStatus]; + NSArray<SDLMenuCell *> *oldSubcellKeeps = [self sdl_filterKeepMenuItems:oldKeptCells[index].subCells basedOnStatusList:deleteMenuStatus]; + NSArray<SDLMenuCell *> *newSubcellKeeps = [self sdl_filterKeepMenuItems:newKeptCells[index].subCells basedOnStatusList:addMenuStatus]; [SDLMenuReplaceUtilities transferCellHandlersFromCells:newSubcellKeeps toCells:oldSubcellKeeps]; __weak typeof(self) weakself = self; @@ -322,22 +322,12 @@ NS_ASSUME_NONNULL_BEGIN return [addCells copy]; } -- (NSArray<SDLMenuCell *> *)sdl_filterKeepMenuItemsWithOldMenuItems:(NSArray<SDLMenuCell *> *)oldMenuCells basedOnStatusList:(NSArray<NSNumber *> *)keepStatusList { +- (NSArray<SDLMenuCell *> *)sdl_filterKeepMenuItems:(NSArray<SDLMenuCell *> *)menuCells basedOnStatusList:(NSArray<NSNumber *> *)keepStatusList { NSMutableArray<SDLMenuCell *> *keepMenuCells = [[NSMutableArray alloc] init]; - for (NSUInteger index = 0; index < keepStatusList.count; index++) { - if (keepStatusList[index].unsignedIntegerValue == SDLMenuCellUpdateStateKeep) { - [keepMenuCells addObject:oldMenuCells[index]]; - } - } - return [keepMenuCells copy]; -} - -- (NSArray<SDLMenuCell *> *)sdl_filterKeepMenuItemsWithNewMenuItems:(NSArray<SDLMenuCell *> *)newMenuCells basedOnStatusList:(NSArray<NSNumber *> *)keepStatusList { - NSMutableArray<SDLMenuCell *> *keepMenuCells = [[NSMutableArray alloc] init]; - for (NSUInteger index = 0; index < keepStatusList.count; index++) { - if (keepStatusList[index].unsignedIntegerValue == SDLMenuCellUpdateStateKeep) { - [keepMenuCells addObject:newMenuCells[index]]; + for (NSUInteger i = 0; i < keepStatusList.count; i++) { + if (keepStatusList[i].unsignedIntegerValue == SDLMenuCellUpdateStateKeep) { + [keepMenuCells addObject:menuCells[i]]; } } return [keepMenuCells copy]; diff --git a/SmartDeviceLink/public/SDLMenuCell.m b/SmartDeviceLink/public/SDLMenuCell.m index a66812032..fb07ef49f 100644 --- a/SmartDeviceLink/public/SDLMenuCell.m +++ b/SmartDeviceLink/public/SDLMenuCell.m @@ -112,16 +112,12 @@ NS_ASSUME_NONNULL_BEGIN } - (BOOL)isEqualToCell:(SDLMenuCell *)cell { - if (cell == nil) { return NO; } - return (self.hash == cell.hash); } #pragma mark With Unique Title - (BOOL)isEqualToCellWithUniqueTitle:(SDLMenuCell *)cell { - if (cell == nil) { return NO; } - return ([self sdl_hashWithUniqueTitle] == [cell sdl_hashWithUniqueTitle]); } diff --git a/SmartDeviceLink/public/SDLScreenManager.m b/SmartDeviceLink/public/SDLScreenManager.m index 72ea10d53..d413cdee6 100644 --- a/SmartDeviceLink/public/SDLScreenManager.m +++ b/SmartDeviceLink/public/SDLScreenManager.m @@ -332,11 +332,11 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - Menu - (BOOL)openMenu { - return [self.menuManager openMenu:nil]; + return [self.menuManager openMenu:nil]; } - (BOOL)openSubmenu:(SDLMenuCell *)cell { - return [self.menuManager openMenu:cell]; + return [self.menuManager openMenu:cell]; } #pragma mark - Alert |