async Task HandleEpisode(EpisodeResult episodeResult) { await Download.HandleEpisodeTapped(episodeResult.Id, this); UpdateEpisodes(); }
void UpdateEpisodes() { MyEpisodeResultCollection.Clear(); try { var header = Download.downloadHeaders[currentId]; var helper = Download.downloadHelper[currentId]; // App.GetDownloadHeaderInfo(currentId); List <EpisodeResult> activeEpisodes = new List <EpisodeResult>(); foreach (var key in helper.infoIds) { var info = App.GetDownloadInfo(key);//Download.downloads[key]; if (info != null) { Download.downloads[key] = info; if (info.state.totalBytes == 0 && info.state.bytesDownloaded != 1) { print("DC 0 DATAA:::: "); Download.RemoveDownloadCookie(key); } else { int ep = info.info.episode; int ss = info.info.season; string fileUrl = info.info.fileUrl; string fileName = info.info.name; print(info.state.bytesDownloaded + "|" + info.state.totalBytes); int dloaded = (int)info.state.ProcentageDownloaded; // string extra = (info.state.state == App.DownloadState.Downloaded ? "" : App.ConvertBytesToAny(info.state.bytesDownloaded, 0, 2) + " MB of " + App.ConvertBytesToAny(info.state.totalBytes, 0, 2) + " MB"); string extra = $" {dloaded }%"; print("EXTRA: " + extra + "|" + dloaded); //.TapCom = new Command(async (s) => { long pos; long len; double _progress = 0; if ((pos = App.GetViewPos(info.info.id)) > 0) { if ((len = App.GetViewDur(info.info.id)) > 0) { _progress = (double)pos / (double)len; print("SET PROGRES:::" + "|" + _progress); } } var dPlaySource = App.GetImageSource("nexflixPlayBtt.png"); activeEpisodes.Add(new EpisodeResult() { OgTitle = info.info.name, ExtraColor = Settings.ItemBackGroundColor.ToHex(), ExtraDescription = $"{Download.GetExtraString(info.state.state)}{((info.state.state == App.DownloadState.Downloaded || dloaded == -1) ? "" : extra)}", Title = (ep != -1 ? $"S{ss}:E{ep} " : "") + info.info.name, Description = info.info.description, Episode = ep, Season = ss, Id = info.info.id, PosterUrl = info.info.hdPosterUrl, Progress = _progress, TapCom = new Command((s) => { if (info.info.dtype == App.DownloadType.Normal) { MovieResult.SetEpisode("tt" + info.info.id); } Download.PlayDownloadedFile(info); //Download.PlayDownloadedFile(fileUrl, fileName, info.info.episode, info.info.season, info.info.episodeIMDBId, info.info.source); // Download.PlayVLCFile(fileUrl, fileName, info.info.id.ToString()); }), DownloadPlayBttSource = dPlaySource }); } } } activeEpisodes = activeEpisodes.OrderBy(t => (t.Episode + t.Season * 1000)).ToList(); for (int i = 0; i < activeEpisodes.Count; i++) { MyEpisodeResultCollection.Add(activeEpisodes[i]); } episodeView.FadeTo(1, 200, Easing.SinOut); } catch (Exception _ex) { print("EXUpdateDEpisodes::: " + _ex); } SetHeight(); if (MyEpisodeResultCollection.Count == 0) { Navigation.PopModalAsync(); } }