private async void Refresh() { string setTitle; string addonId; if (!NavigationContext.QueryString.TryGetValue("id", out addonId) || !NavigationContext.QueryString.TryGetValue("title", out setTitle)) { if (NavigationService.CanGoBack) NavigationService.GoBack(); return; } AddonName = HttpUtility.UrlDecode(setTitle); IsLoading = true; try { var addon = await App.Context.Connection.Xbmc.Addons.GetAddonDetailsAsync(addonId); AddonDetails = new ExtendedAddonDetailsBase(addon); AddonDetails.Value.Description = AddonDetails.Value.Description.Replace("[CR]", "\n"); GetImageAsync(addon.Thumbnail); } catch (Exception ex) { App.TrackException(ex); MessageBox.Show(AppResources.Global_Error_Message, AppResources.ApplicationTitle, MessageBoxButton.OK); } finally { IsLoading = false; } }
private async void EnableAddon(ExtendedAddonDetailsBase addon, bool enabled) { if (addon == null || addon.Value.Enabled == enabled) { return; } IsLoading = true; await App.Context.Connection.Kodi.Addons.SetAddonEnabledAsync(addon.Value.AddonId, enabled); IsLoading = false; //Refresh(); }
private async Task <object> GetSelectionDetailsAsync(object o) { var selectedAddon = o as ExtendedAddonDetailsBase; if (selectedAddon == null) { return(null); } IsLoading = true; try { var task = Task.Factory.StartNew(async() => { return(await App.Context.Connection.Kodi.Addons.GetAddonDetailsAsync(selectedAddon.Value.AddonId)); }); var addon = task.GetAwaiter().GetResult(); var addonDetails = new ExtendedAddonDetailsBase(addon.Result); addonDetails.Value.Description = addonDetails.Value.Description.Replace("[CR]", "\n"); return(addonDetails); } catch (Exception ex) { App.TrackException(ex); var dialog = new MessageDialog(_resourceLoader.GetString("GlobalErrorMessage"), _resourceLoader.GetString("ApplicationTitle")); await dialog.ShowAsync(); } finally { IsLoading = false; } return(null); }