/// <summary> /// Handles the Lesson fragment's Lesson finished event /// </summary> /// <param name="sender">sender.</param> /// <param name="e">event args.</param> void LessonFragment_LessonFinished(object sender, LessonFinishedEventArgs e) { if (e.ProvideFeedback) { var success = DataHolder.Current.CurrentLesson.Iterations.All(i => i.Status == IterationStatus.Success); // Show success or failure badge if (success) { ivBadge.SetImageResource(Resource.Drawable.irmgard_icon_spiel_supergemacht); } else { ivBadge.SetImageResource(Resource.Drawable.irmgard_icon_spiel_nochmal); } var badgeAnimation = AnimationUtils.LoadAnimation(this, Resource.Animation.ShowFeedbackIcon); badgeAnimation.AnimationEnd += (s2, args2) => { ivBadge.Visibility = ViewStates.Gone; }; ivBadge.Visibility = ViewStates.Visible; ivBadge.StartAnimation(badgeAnimation); // Play random praise or criticism audio depending on lesson success status SoundPlayer.PlaySound(this, success ? praiseFilesAvail.PickRandomItems(1).FirstOrDefault() : criticismFilesAvail.PickRandomItems(1).FirstOrDefault()); SoundPlayer.Completion += (sender2, e2) => { NextLesson(); }; } else { NextLesson(); } }
/// <summary> /// Handles the Lesson fragment's Lesson finished event /// </summary> /// <param name="sender">sender.</param> /// <param name="e">event args.</param> async void LessonFragment_LessonFinished(object sender, LessonFinishedEventArgs e) { if (SoundPlayer.IsPlaying) SoundPlayer.Stop(); var success = DataHolder.Current.CurrentLesson.Iterations.All(i => i.Status == IterationStatus.Success); // Play random praise or criticism audio depending on lesson success status if (e.ProvideFeedback) { isPlayingPraiseOrCriticism = true; SoundPlayer.PlaySound(this, success ? praiseFilesAvail.PickRandomItems(1).FirstOrDefault() : criticismFilesAvail.PickRandomItems(1).FirstOrDefault()); } while (SoundPlayer.IsPlaying) { await Task.Delay(500); } isPlayingPraiseOrCriticism = false; NextLesson(success, e.ProvideFeedback); }