From 07f49b6fa9f52f1e77a0c7054390f7d8620f2603 Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Mon, 17 Jun 2019 16:23:23 -0400 Subject: Fix `runScore` being a property and several method / variable names --- SmartDeviceLink/SDLMenuManager.m | 57 ++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/SmartDeviceLink/SDLMenuManager.m b/SmartDeviceLink/SDLMenuManager.m index b782d49c6..4698c093b 100644 --- a/SmartDeviceLink/SDLMenuManager.m +++ b/SmartDeviceLink/SDLMenuManager.m @@ -58,7 +58,7 @@ NS_ASSUME_NONNULL_BEGIN @property (assign, nonatomic) UInt32 lastMenuId; @property (copy, nonatomic) NSArray *oldMenuCells; -@property (copy, nonatomic, nullable) SDLDynamicMenuUpdateRunScore *runScore; + @end UInt32 const ParentIdNotFound = UINT32_MAX; @@ -105,7 +105,6 @@ UInt32 const MenuCellIdMin = 1; _hasQueuedUpdate = NO; _waitingOnHMIUpdate = NO; _waitingUpdateMenuCells = @[]; - _runScore = nil; } #pragma mark - Setters @@ -166,11 +165,11 @@ UInt32 const MenuCellIdMin = 1; NSArray *deleteMenuStatus = tempScore.oldStatus; NSArray *addMenuStatus = tempScore.updatedStatus; - NSArray *cellsToDelete = [self sdl_filterDeleteMenuItemsWithOldMenuItems:deleteMenuStatus basedOnStatusList:oldKeptCells[startIndex].subCells]; - NSArray *cellsToAdd = [self sdl_filterAddMenuItemsWithNewMenuItems:addMenuStatus basedOnStatusList:newKeptCells[startIndex].subCells]; + NSArray *cellsToDelete = [self sdl_filterDeleteMenuItemsWithOldMenuItems:oldKeptCells[startIndex].subCells basedOnStatusList:deleteMenuStatus]; + NSArray *cellsToAdd = [self sdl_filterAddMenuItemsWithNewMenuItems:newKeptCells[startIndex].subCells basedOnStatusList:addMenuStatus]; - NSArray *oldKeeps = [self sdl_filterKeepMenuItemsWithOldMenuItems: deleteMenuStatus basedOnStatusList:oldKeptCells[startIndex].subCells]; - NSArray *newKeeps = [self sdl_filterKeepMenuItemsWithNewMenuItems: addMenuStatus basedOnStatusList:newKeptCells[startIndex].subCells]; + NSArray *oldKeeps = [self sdl_filterKeepMenuItemsWithOldMenuItems:oldKeptCells[startIndex].subCells basedOnStatusList:deleteMenuStatus]; + NSArray *newKeeps = [self sdl_filterKeepMenuItemsWithNewMenuItems:newKeptCells[startIndex].subCells basedOnStatusList:addMenuStatus]; [self sdl_updateIdsOnMenuCells:cellsToAdd parentId:newKeptCells[startIndex].cellId]; [self transferCellIDFromOldCells:oldKeeps toKeptCells:newKeeps]; @@ -188,46 +187,46 @@ UInt32 const MenuCellIdMin = 1; } } -- (NSArray *)sdl_filterDeleteMenuItemsWithOldMenuItems:(NSArray *)oldMenuItems basedOnStatusList:(NSArray *)oldList { +- (NSArray *)sdl_filterDeleteMenuItemsWithOldMenuItems:(NSArray *)oldMenuCells basedOnStatusList:(NSArray *)oldStatusList { NSMutableArray *deleteCells = [[NSMutableArray alloc] init]; // The index of the status should corrleate 1-1 with the number of items in the menu // [2,0,2,0] => [A,B,C,D] = [B,D] - for (NSUInteger index = 0; index < oldMenuItems.count; index++) { - if (oldMenuItems[index].integerValue == MenuCellStateDelete) { - [deleteCells addObject:oldList[index]]; + for (NSUInteger index = 0; index < oldStatusList.count; index++) { + if (oldStatusList[index].integerValue == MenuCellStateDelete) { + [deleteCells addObject:oldMenuCells[index]]; } } return [deleteCells copy]; } -- (NSArray *)sdl_filterAddMenuItemsWithNewMenuItems:(NSArray *)newMenuItems basedOnStatusList:(NSArray *)statusList { +- (NSArray *)sdl_filterAddMenuItemsWithNewMenuItems:(NSArray *)newMenuCells basedOnStatusList:(NSArray *)newStatusList { NSMutableArray *addCells = [[NSMutableArray alloc] init]; // The index of the status should corrleate 1-1 with the number of items in the menu // [2,1,2,1] => [A,B,C,D] = [B,D] - for (NSUInteger index = 0; index < newMenuItems.count; index++) { - if (newMenuItems[index].integerValue == MenuCellStateAdd) { - [addCells addObject:statusList[index]]; + for (NSUInteger index = 0; index < newStatusList.count; index++) { + if (newStatusList[index].integerValue == MenuCellStateAdd) { + [addCells addObject:newMenuCells[index]]; } } return [addCells copy]; } -- (NSArray *)sdl_filterKeepMenuItemsWithOldMenuItems:(NSArray *)oldMenuItems basedOnStatusList:(NSArray *)statusList { +- (NSArray *)sdl_filterKeepMenuItemsWithOldMenuItems:(NSArray *)oldMenuCells basedOnStatusList:(NSArray *)keepStatusList { NSMutableArray *keepMenuCells = [[NSMutableArray alloc] init]; - for (NSUInteger index = 0; index < oldMenuItems.count; index++) { - if (oldMenuItems[index].integerValue == MenuCellStateKeep) { - [keepMenuCells addObject:statusList[index]]; + for (NSUInteger index = 0; index < keepStatusList.count; index++) { + if (keepStatusList[index].integerValue == MenuCellStateKeep) { + [keepMenuCells addObject:oldMenuCells[index]]; } } return [keepMenuCells copy]; } -- (NSArray *)sdl_filterKeepMenuItemsWithNewMenuItems:(NSArray *)newMenuItems basedOnStatusList:(NSArray *)statusList { +- (NSArray *)sdl_filterKeepMenuItemsWithNewMenuItems:(NSArray *)newMenuCells basedOnStatusList:(NSArray *)keepStatusList { NSMutableArray *keepMenuCells = [[NSMutableArray alloc] init]; - for (NSUInteger index = 0; index < newMenuItems.count; index++) { - if (newMenuItems[index].integerValue == MenuCellStateKeep) { - [keepMenuCells addObject:statusList[index]]; + for (NSUInteger index = 0; index < keepStatusList.count; index++) { + if (keepStatusList[index].integerValue == MenuCellStateKeep) { + [keepMenuCells addObject:newMenuCells[index]]; } } return [keepMenuCells copy]; @@ -243,16 +242,16 @@ UInt32 const MenuCellIdMin = 1; #pragma mark - Updating System - (void)sdl_startDynamicMenuUpdate { - _runScore = [SDLDynamicMenuUpdateAlgorithm compareOldMenuCells:self.oldMenuCells updatedMenuCells:self.menuCells]; + SDLDynamicMenuUpdateRunScore *runScore = [SDLDynamicMenuUpdateAlgorithm compareOldMenuCells:self.oldMenuCells updatedMenuCells:self.menuCells]; - NSArray *deleteMenuStatus = self.runScore.oldStatus; - NSArray *addMenuStatus = self.runScore.updatedStatus; + NSArray *deleteMenuStatus = runScore.oldStatus; + NSArray *addMenuStatus = runScore.updatedStatus; - NSArray *cellsToDelete = [self sdl_filterDeleteMenuItemsWithOldMenuItems:deleteMenuStatus basedOnStatusList:self.oldMenuCells]; - NSArray *cellsToAdd = [self sdl_filterAddMenuItemsWithNewMenuItems:addMenuStatus basedOnStatusList:self.menuCells]; + NSArray *cellsToDelete = [self sdl_filterDeleteMenuItemsWithOldMenuItems:self.oldMenuCells basedOnStatusList:deleteMenuStatus]; + NSArray *cellsToAdd = [self sdl_filterAddMenuItemsWithNewMenuItems:self.menuCells basedOnStatusList:addMenuStatus]; // These arrays should ONLY contain KEEPS. These will be used for SubMenu compares - NSArray *oldKeeps = [self sdl_filterKeepMenuItemsWithOldMenuItems:deleteMenuStatus basedOnStatusList:self.oldMenuCells]; - NSArray *newKeeps = [self sdl_filterKeepMenuItemsWithNewMenuItems:addMenuStatus basedOnStatusList:self.menuCells]; + NSArray *oldKeeps = [self sdl_filterKeepMenuItemsWithOldMenuItems:self.oldMenuCells basedOnStatusList:deleteMenuStatus]; + NSArray *newKeeps = [self sdl_filterKeepMenuItemsWithNewMenuItems:self.menuCells basedOnStatusList:addMenuStatus]; // Cells that will be added need new ids [self sdl_updateIdsOnMenuCells:cellsToAdd parentId:ParentIdNotFound]; -- cgit v1.2.1