private async Task <IEnumerable <IContentItem> > getItemChildren(IContentItem item, bool silent) { if (item.IsRoot) { lastChannelsLoaded = DateTime.Now; var result = await ContentClient.GetChannels(); canRefresh = true; if ((result != null) && result.Any()) { return(result); } else { var isConnected = await RestService.Instance.GetIsConnected(); if (!silent && isConnected) { Device.BeginInvokeOnMainThread(() => Application.Current.MainPage.DisplayAlert("Error", "Unable to get channel list. Please make sure you are online, and try again.", "OK")); } return(null); } } else { if (item.IsChannel) { var channel = item as ChannelEx; if (!channel.IsAvailable) { return(null); } if ((channel.LoginInfo != null) && channel.LoginInfo.HasCredentials) { channel.LoginInfo.LoginPerformed = true; var result = await ContentClient.LoginAndGetChildren(item.ID, channel.LoginInfo); if (result == null) { var validation = await SettingsClient.ValidateCredentials(channel.ID, channel.LoginInfo); if ((validation != null) && !validation.Success) { channel.LoginInfo.ValidationSuccessful = false; Device.BeginInvokeOnMainThread(() => AlertViewService.Instance.ShowAlert(validation.Message)); } } else { channel.LoginInfo.ValidationSuccessful = true; UserStoreService.Instance.StoreRecordInKeychain(getAccountEmail() + "channel-" + item.ID, JsonConvert.SerializeObject((item as ChannelEx).LoginInfo)); } channel.RefreshIsSearchVisible(); return(result); } else if (channel.CredentialsType != ChannelCredentialsType.Anonymous) { return(await ContentClient.LoginAndGetChildren(item.ID, new ChannelLoginInfo())); } } return(await ContentClient.GetChildren(item.ID)); } }