diff --git a/PepperDashEssentials/UIDrivers/VC/EssentialsVideoCodecUiDriver.cs b/PepperDashEssentials/UIDrivers/VC/EssentialsVideoCodecUiDriver.cs index f2bbcead..612f7eeb 100644 --- a/PepperDashEssentials/UIDrivers/VC/EssentialsVideoCodecUiDriver.cs +++ b/PepperDashEssentials/UIDrivers/VC/EssentialsVideoCodecUiDriver.cs @@ -1041,22 +1041,21 @@ namespace PepperDash.Essentials.UIDrivers.VC void SetupDirectoryList() { var codec = Codec as IHasDirectory; - if (codec != null) - { - DirectoryList = new SmartObjectDynamicList(TriList.SmartObjects[UISmartObjectJoin.VCDirectoryList], - true, 1300); - codec.DirectoryResultReturned += new EventHandler(dir_DirectoryResultReturned); + if (codec == null) + { + return; + } - if (codec.PhonebookSyncState.InitialSyncComplete) - SetCurrentDirectoryToRoot(); - else - { - codec.PhonebookSyncState.InitialSyncCompleted += new EventHandler(PhonebookSyncState_InitialSyncCompleted); - } + DirectoryList = new SmartObjectDynamicList(TriList.SmartObjects[UISmartObjectJoin.VCDirectoryList], + true, 1300); + codec.DirectoryResultReturned += dir_DirectoryResultReturned; - RefreshDirectory(); - - } + if (codec.PhonebookSyncState.InitialSyncComplete) + SetCurrentDirectoryToRoot(); + else + { + codec.PhonebookSyncState.InitialSyncCompleted += PhonebookSyncState_InitialSyncCompleted; + } } /// @@ -1064,11 +1063,15 @@ namespace PepperDash.Essentials.UIDrivers.VC /// void SetCurrentDirectoryToRoot() { - (Codec as IHasDirectory).SetCurrentDirectoryToRoot(); + var hasDirectory = Codec as IHasDirectory; + if (hasDirectory == null) + { + return; + } + + hasDirectory.SetCurrentDirectoryToRoot(); SearchKeypadClear(); - - RefreshDirectory(); } /// @@ -1080,12 +1083,17 @@ namespace PepperDash.Essentials.UIDrivers.VC { var codec = Codec as IHasDirectory; - if (codec.CurrentDirectoryResultIsNotDirectoryRoot.BoolValue) + if (codec == null) { - SetCurrentDirectoryToRoot(); - - RefreshDirectory(); + return; } + + if (!codec.CurrentDirectoryResultIsNotDirectoryRoot.BoolValue) + { + return; + } + + SetCurrentDirectoryToRoot(); } /// @@ -1095,8 +1103,7 @@ namespace PepperDash.Essentials.UIDrivers.VC /// void dir_DirectoryResultReturned(object sender, DirectoryEventArgs e) { - - RefreshDirectory(); + RefreshDirectory(e.Directory); } /// @@ -1125,16 +1132,27 @@ namespace PepperDash.Essentials.UIDrivers.VC } - /// - /// - /// - /// - void RefreshDirectory() + /// + /// + /// + void RefreshDirectory() { - if ((Codec as IHasDirectory).CurrentDirectoryResult.CurrentDirectoryResults.Count > 0) + var codec = Codec as IHasDirectory; + + if (codec == null) + { + return; + } + + RefreshDirectory(codec.CurrentDirectoryResult); + } + + void RefreshDirectory(CodecDirectory directory) + { + if (directory.CurrentDirectoryResults.Count > 0) { ushort i = 0; - foreach (var r in (Codec as IHasDirectory).CurrentDirectoryResult.CurrentDirectoryResults) + foreach (var r in directory.CurrentDirectoryResults) { if (i == DirectoryList.MaxCount) { @@ -1154,12 +1172,13 @@ namespace PepperDash.Essentials.UIDrivers.VC // If more than one contact method, show contact method modal dialog DirectoryList.SetItemButtonAction(i, b => { - if (!b) + if (b) { - // Refresh the contact methods list - RefreshContactMethodsModalList(dc); - Parent.PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.MeetingsOrContacMethodsListVisible); + return; } + // Refresh the contact methods list + RefreshContactMethodsModalList(dc); + Parent.PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.MeetingsOrContacMethodsListVisible); }); } @@ -1206,8 +1225,7 @@ namespace PepperDash.Essentials.UIDrivers.VC DirectoryList.SetItemMainText(1, "No Results Found"); } - - } + } void RefreshContactMethodsModalList(DirectoryContact contact) {