Adding Error Popup and changing views from search. 11/265311/2
authorshivamv <shivam.v2@samsung.com>
Thu, 14 Oct 2021 11:02:23 +0000 (16:32 +0530)
committershivamv <shivam.v2@samsung.com>
Thu, 14 Oct 2021 11:05:47 +0000 (16:35 +0530)
Change-Id: I4eb370a588fd683e77b3cbaa2824e2278b8328b3
Signed-off-by: shivamv <shivam.v2@samsung.com>
music-player/ViewModels/PlayerViewModel.cs
music-player/Views/BaseContentView.cs
music-player/Views/Utils/ErrorPopup.cs [new file with mode: 0755]
packaging/org.tizen.MusicPlayer-1.0.0.tpk

index 6541b40f1c4ffd76939e324c76e650134ca257c9..28a52a144b19197042d2f2c56a4b5b6b19164119 100755 (executable)
@@ -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();
             }
         }
 
index 0169c3441e0054d68240587230141526185e6961..600cdf329d6bc019a0d72765ca7aea8d90e97326 100755 (executable)
@@ -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 (executable)
index 0000000..4858578
--- /dev/null
@@ -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<View> { 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);
+        }
+    }
+}
index 4803830e4e3dfad4e0b82086a6fe31dbcf34c265..0a218496467660f6936886e0034bdb05afe380c2 100755 (executable)
Binary files a/packaging/org.tizen.MusicPlayer-1.0.0.tpk and b/packaging/org.tizen.MusicPlayer-1.0.0.tpk differ