From: shivamv Date: Thu, 14 Oct 2021 11:02:23 +0000 (+0530) Subject: Adding Error Popup and changing views from search. X-Git-Tag: submit/tizen/20211109.094344~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3712fb492ddfdef7a028462a39675704c6f56c5c;p=profile%2Fiot%2Fapps%2Fdotnet%2Fmusic-player.git Adding Error Popup and changing views from search. Change-Id: I4eb370a588fd683e77b3cbaa2824e2278b8328b3 Signed-off-by: shivamv --- diff --git a/music-player/ViewModels/PlayerViewModel.cs b/music-player/ViewModels/PlayerViewModel.cs index 6541b40..28a52a1 100755 --- a/music-player/ViewModels/PlayerViewModel.cs +++ b/music-player/ViewModels/PlayerViewModel.cs @@ -4,6 +4,7 @@ using System.Text; using MusicPlayer.Models; using MusicPlayer.Common; using MusicPlayer.Core; +using MusicPlayer.Views.Utils; using Tizen.NUI; using Tizen.Multimedia; using System.Threading.Tasks; @@ -339,6 +340,9 @@ namespace MusicPlayer.ViewModels else if(e.Type == EventType.Error) { Tizen.Log.Error(AppConstants.LogTag, "ThreadId: " + System.Threading.Thread.CurrentThread.ManagedThreadId + ", Error Occured: " + e.Description); + ErrorPopup errorPopup = new ErrorPopup(); + errorPopup.GetAlertDialog().Message = e.Description; + PlayNext(); } } diff --git a/music-player/Views/BaseContentView.cs b/music-player/Views/BaseContentView.cs index 0169c34..600cdf3 100755 --- a/music-player/Views/BaseContentView.cs +++ b/music-player/Views/BaseContentView.cs @@ -91,8 +91,8 @@ namespace MusicPlayer.Views } if(subcontentView != null) { - Tizen.Log.Error(AppConstants.LogTag, "subcontent view already added , remove it first"); - return; + Tizen.Log.Error(AppConstants.LogTag, "subcontent view already added , removing it first"); + RemoveSubContentView(); } subContentViewContainer.Show(); subContentViewContainer.Add(baseSubContentView); diff --git a/music-player/Views/Utils/ErrorPopup.cs b/music-player/Views/Utils/ErrorPopup.cs new file mode 100755 index 0000000..4858578 --- /dev/null +++ b/music-player/Views/Utils/ErrorPopup.cs @@ -0,0 +1,73 @@ +using System.Collections.Generic; +using Tizen.NUI.BaseComponents; +using Tizen.NUI; +using Tizen.NUI.Components; +using MusicPlayer.Common; + +namespace MusicPlayer.Views.Utils +{ + class ErrorPopup : View + { + private Button okButton; + private AlertDialog errorDialog; + public ErrorPopup() : base() + { + AddOkButton(); + errorDialog = new AlertDialog() + { + Size2D = new Size2D(1184, 368), + Title = "Unable to play track", + Message = "", + Actions = new List { okButton }, + }; + + TextLabel textLabel = (TextLabel)errorDialog.TitleContent; + textLabel.FontStyle = UIFontStyles.AllNormal; + Window.Instance.Add(errorDialog); + } + + private void AddOkButton() + { + okButton = new Button() + { + Text = "OK", + }; + okButton.TextLabel.FontStyle = UIFontStyles.AllNormal; + okButton.IsSelectable = true; + okButton.Clicked += OkButtonClicked; + } + + private void OkButtonClicked(object sender, ClickedEventArgs e) + { + RemoveThePopup(); + } + + public void RemoveThePopup() + { + Window.Instance.Remove(errorDialog); + Dispose(DisposeTypes.Explicit); + } + + public AlertDialog GetAlertDialog() + { + return errorDialog; + } + + protected override void Dispose(DisposeTypes type) + { + if (Disposed) + { + return; + } + if (type == DisposeTypes.Explicit) + { + errorDialog?.Dispose(); + errorDialog = null; + okButton?.Dispose(); + okButton = null; + } + + base.Dispose(type); + } + } +} diff --git a/packaging/org.tizen.MusicPlayer-1.0.0.tpk b/packaging/org.tizen.MusicPlayer-1.0.0.tpk index 4803830..0a21849 100755 Binary files a/packaging/org.tizen.MusicPlayer-1.0.0.tpk and b/packaging/org.tizen.MusicPlayer-1.0.0.tpk differ