protected override void LoadComplete() { base.LoadComplete(); SelectedItem.BindValueChanged(item => { // the underlying playlist is regularly cleared for maintenance purposes (things which probably need to be fixed eventually). // to avoid exposing a state change when there may actually be none, ignore all nulls for now. if (item.NewValue == null) { return; } downloadTracker?.RemoveAndDisposeImmediately(); selectedBeatmap = null; beatmapLookupCache.GetBeatmapAsync(item.NewValue.Beatmap.OnlineID).ContinueWith(task => Schedule(() => { var beatmap = task.GetResultSafely(); if (SelectedItem.Value?.Beatmap.OnlineID == beatmap.OnlineID) { selectedBeatmap = beatmap; beginTracking(); } }), TaskContinuationOptions.OnlyOnRanToCompletion); }, true); }
protected override void LoadComplete() { base.LoadComplete(); SelectedItem.BindValueChanged(item => { // the underlying playlist is regularly cleared for maintenance purposes (things which probably need to be fixed eventually). // to avoid exposing a state change when there may actually be none, ignore all nulls for now. if (item.NewValue == null) { return; } downloadTracker?.RemoveAndDisposeImmediately(); Debug.Assert(item.NewValue.Beatmap.Value.BeatmapSet != null); downloadTracker = new BeatmapDownloadTracker(item.NewValue.Beatmap.Value.BeatmapSet); AddInternal(downloadTracker); downloadTracker.State.BindValueChanged(_ => Scheduler.AddOnce(updateAvailability), true); downloadTracker.Progress.BindValueChanged(_ => { if (downloadTracker.State.Value != DownloadState.Downloading) { return; } // incoming progress changes are going to be at a very high rate. // we don't want to flood the network with this, so rate limit how often we send progress updates. if (progressUpdate?.Completed != false) { progressUpdate = Scheduler.AddDelayed(updateAvailability, progressUpdate == null ? 0 : 500); } }, true); // handles changes to hash that didn't occur from the import process (ie. a user editing the beatmap in the editor, somehow). realmSubscription?.Dispose(); realmSubscription = realm.RegisterForNotifications(r => filteredBeatmaps(), (items, changes, ___) => { if (changes == null) { return; } Scheduler.AddOnce(updateAvailability); }); }, true); }
private void load(OverlayColourProvider colourProvider) { coverGradient.Colour = ColourInfo.GradientVertical(colourProvider.Background6.Opacity(0.3f), colourProvider.Background6.Opacity(0.8f)); BeatmapSet.BindValueChanged(setInfo => { Picker.BeatmapSet = rulesetSelector.BeatmapSet = author.BeatmapSet = beatmapAvailability.BeatmapSet = Details.BeatmapSet = setInfo.NewValue; cover.OnlineInfo = setInfo.NewValue; downloadTracker?.RemoveAndDisposeImmediately(); if (setInfo.NewValue == null) { onlineStatusPill.FadeTo(0.5f, 500, Easing.OutQuint); fadeContent.Hide(); loading.Show(); downloadButtonsContainer.FadeOut(transition_duration); favouriteButton.FadeOut(transition_duration); } else { downloadTracker = new BeatmapDownloadTracker(setInfo.NewValue); downloadTracker.State.BindValueChanged(_ => updateDownloadButtons()); AddInternal(downloadTracker); fadeContent.FadeIn(500, Easing.OutQuint); loading.Hide(); title.Text = new RomanisableString(setInfo.NewValue.TitleUnicode, setInfo.NewValue.Title); artist.Text = new RomanisableString(setInfo.NewValue.ArtistUnicode, setInfo.NewValue.Artist); explicitContent.Alpha = setInfo.NewValue.HasExplicitContent ? 1 : 0; spotlight.Alpha = setInfo.NewValue.FeaturedInSpotlight ? 1 : 0; featuredArtist.Alpha = setInfo.NewValue.TrackId != null ? 1 : 0; onlineStatusPill.FadeIn(500, Easing.OutQuint); downloadButtonsContainer.FadeIn(transition_duration); favouriteButton.FadeIn(transition_duration); updateDownloadButtons(); } }, true); }
protected override void LoadComplete() { base.LoadComplete(); SelectedItem.BindValueChanged(item => { // the underlying playlist is regularly cleared for maintenance purposes (things which probably need to be fixed eventually). // to avoid exposing a state change when there may actually be none, ignore all nulls for now. if (item.NewValue == null) { return; } downloadTracker?.RemoveAndDisposeImmediately(); Debug.Assert(item.NewValue.Beatmap.Value.BeatmapSet != null); downloadTracker = new BeatmapDownloadTracker(item.NewValue.Beatmap.Value.BeatmapSet); AddInternal(downloadTracker); downloadTracker.State.BindValueChanged(_ => updateAvailability(), true); downloadTracker.Progress.BindValueChanged(_ => { if (downloadTracker.State.Value != DownloadState.Downloading) { return; } // incoming progress changes are going to be at a very high rate. // we don't want to flood the network with this, so rate limit how often we send progress updates. if (progressUpdate?.Completed != false) { progressUpdate = Scheduler.AddDelayed(updateAvailability, progressUpdate == null ? 0 : 500); } }, true); }, true); // These events are needed for a fringe case where a modified/altered beatmap is imported with matching OnlineIDs. // During the import process this will cause the existing beatmap set to be silently deleted and replaced with the new one. // This is not exposed to us via `BeatmapDownloadTracker` so we have to take it into our own hands (as we care about the hash matching). beatmapManager.ItemUpdated += itemUpdated; beatmapManager.ItemRemoved += itemRemoved; }
protected override void LoadComplete() { base.LoadComplete(); SelectedItem.BindValueChanged(item => { // the underlying playlist is regularly cleared for maintenance purposes (things which probably need to be fixed eventually). // to avoid exposing a state change when there may actually be none, ignore all nulls for now. if (item.NewValue == null) { return; } downloadTracker?.RemoveAndDisposeImmediately(); Debug.Assert(item.NewValue.Beatmap.Value.BeatmapSet != null); downloadTracker = new BeatmapDownloadTracker(item.NewValue.Beatmap.Value.BeatmapSet); AddInternal(downloadTracker); downloadTracker.State.BindValueChanged(_ => updateAvailability(), true); downloadTracker.Progress.BindValueChanged(_ => { if (downloadTracker.State.Value != DownloadState.Downloading) { return; } // incoming progress changes are going to be at a very high rate. // we don't want to flood the network with this, so rate limit how often we send progress updates. if (progressUpdate?.Completed != false) { progressUpdate = Scheduler.AddDelayed(updateAvailability, progressUpdate == null ? 0 : 500); } }, true); }, true); }