Fixing binding, animation and Title issue 93/274393/1
authoraman.jeph <aman.jeph@samsung.com>
Wed, 27 Apr 2022 11:30:00 +0000 (17:00 +0530)
committeraman.jeph <aman.jeph@samsung.com>
Wed, 27 Apr 2022 11:30:00 +0000 (17:00 +0530)
Change-Id: I2f7d69a659da4644c5a837574c0a11674ab2f1da
Signed-off-by: aman.jeph <aman.jeph@samsung.com>
music-player/Views/ListItemLayout.cs
music-player/Views/LyricsView.cs
music-player/Views/PlayerView.cs
music-player/Views/PlaylistDetailView.cs
music-player/music-player.csproj
packaging/org.tizen.MusicPlayer-1.0.0.tpk

index 24f4f2f78b1ff9c5fdb79faae54b0221c770b6dd..8e18b9fe5b16579548fa5f8f22082ac26179021d 100755 (executable)
@@ -9,8 +9,6 @@ namespace MusicPlayer.Views
 {\r
     class ListItemLayout : RecyclerViewItem\r
     {\r
-        private static bool AnimationRequired;\r
-\r
         private const int IconSize = 64;\r
         private const int SeperatorHeight = 2;\r
 \r
@@ -22,6 +20,7 @@ namespace MusicPlayer.Views
         private Button playPauseIcon;\r
         private bool isAnimating = false;\r
         private bool isPlayingStatus = false;\r
+        private bool isAnimationRequired = false;\r
 \r
         public static readonly BindableProperty IsPlayingProperty = BindableProperty.Create(nameof(IsPlaying), typeof(bool), typeof(ListItemLayout), false, propertyChanged: (bindable, oldValue, newValue) =>\r
         {\r
@@ -56,7 +55,7 @@ defaultValueCreator: (bindable) => ((ListItemLayout)bindable).playingStatus);
         public ListItemLayout(bool animationRequired = false) : base()\r
         {\r
             OnInitialize();\r
-            AnimationRequired = animationRequired;\r
+            isAnimationRequired = animationRequired;\r
             WidthSpecification = LayoutParamPolicies.MatchParent;\r
             HeightSpecification = 108.SpToPx();\r
             BackgroundColor = Color.Transparent;\r
@@ -207,11 +206,11 @@ defaultValueCreator: (bindable) => ((ListItemLayout)bindable).playingStatus);
                 {\r
                     subtitleLabel.TextColor = UIColors.HEX1473E6;\r
                 }\r
-                if(AnimationRequired == true && isAnimating == false)\r
+                if(isAnimationRequired && isAnimating == false)\r
                 {\r
                     isAnimating = AddAnimation();\r
                 }\r
-                else if(AnimationRequired == false && isPlayingStatus == false )\r
+                else if(isAnimationRequired == false && isPlayingStatus == false )\r
                 {\r
                     isPlayingStatus = AddPlayingStatus();\r
                 }\r
@@ -219,12 +218,12 @@ defaultValueCreator: (bindable) => ((ListItemLayout)bindable).playingStatus);
             else\r
             {\r
                 UpdateLabelColors();\r
-                if(AnimationRequired == true && isAnimating)\r
+                if(isAnimationRequired && isAnimating)\r
                 {\r
                     RemoveAnimation();\r
                     isAnimating = false;\r
                 }\r
-                else if(AnimationRequired == false && isPlayingStatus == true)\r
+                else if(isAnimationRequired == false && isPlayingStatus == true)\r
                 {\r
                     RemovePlayingStatus();\r
                     isPlayingStatus = false;\r
index d9602a2122cc81dd07f071fed80f5564d6d0d842..091192b207c70248d6ca859458273cc3f727cc70 100755 (executable)
@@ -42,13 +42,13 @@ namespace MusicPlayer.Views
             AddRiveAnimation();
             lyricsViewModel.TrackThumbState += OnTrackStateChanged;
 
-            // This is set to the binding after the Lyrics is added to scene graph.
-            // If we set the binding before view is added to scene-graph/window than binding doesn't seem to work.
-            AddedToWindow += OnAddedToWindow;
+            BindingContextChanged += OnBindingContextChanged;
         }
 
-        private void OnAddedToWindow(object sender, System.EventArgs e)
+        private void OnBindingContextChanged(object sender, System.EventArgs e)
         {
+            //Don't set BindingContext for LyricsView in this callback. this will cause a infinite recursive loop.
+            //Only set Binding context for children of LyricsView class
             thumbView.BindingContext = lyricsViewModel.lyricsModel;
             thumbView.SetBinding(ImageView.ResourceUrlProperty, "ThumbPath");
 
@@ -84,7 +84,7 @@ namespace MusicPlayer.Views
                 thumbView.Dispose();
                 thumbView = null;
                 lyricsViewModel.TrackThumbState -= OnTrackStateChanged;
-                AddedToWindow -= OnAddedToWindow;
+                BindingContextChanged -= OnBindingContextChanged;
             }
             base.Dispose(type);
         }
index 7a5bfc56d42c0f8b3065d7e1a002e369c94f71b1..582175f94860aab6f0f047c49be52f79f54e875a 100755 (executable)
@@ -434,6 +434,28 @@ namespace MusicPlayer.Views
             };
             rightView.Add(controlsView);
             AddControlElements();
+            rightView.BindingContextChanged += OnControlsViewContextChanged;
+        }
+
+        private void OnControlsViewContextChanged(object sender, EventArgs e)
+        {
+            shuffleButton.BindingContext = viewModel.playingListViewModel;
+            shuffleButton.SetBinding(MultiStateButton.CustomStateProperty, "ShuffleButtonState");
+
+            prevButton.BindingContext = viewModel;
+            prevButton.SetBinding(IsEnabledProperty, "HasPreviousTrack");
+
+            playButton.BindingContext = viewModel;
+            playButton.SetBinding(MultiStateButton.CustomStateProperty, "PlayButtonState");
+
+            nextButton.BindingContext = viewModel;
+            nextButton.SetBinding(IsEnabledProperty, "HasNextTrack");
+
+            repeatButton.BindingContext = viewModel.playingListViewModel;
+            repeatButton.SetBinding(MultiStateButton.CustomStateProperty, "RepeatButtonState");
+
+            volumeSlider.BindingContext = viewModel;
+            volumeSlider.SetBinding(Slider.CurrentValueProperty, "VolumeLevel");
         }
 
         private void AddTitleLabel()
@@ -1031,6 +1053,12 @@ namespace MusicPlayer.Views
             {
                 viewModel.FavouriteStatusChanged();
             };
+
+            actionButtonView.BindingContextChanged += (object o, System.EventArgs e) =>
+            {
+                favouriteButton.BindingContext = viewModel;
+                favouriteButton.SetBinding(MultiStateButton.CustomStateProperty, "FavouriteButtonState");
+            };
         }
 
         private void OnListButtonClicked(object sender, ClickedEventArgs e)
index e2f3bd5dac94ef7389742c5d4425fba081287cb8..f542809ffb3cd18ffcd2798bfdd489cb6aaa7bf7 100755 (executable)
@@ -55,6 +55,11 @@ namespace MusicPlayer.Views
             }
         }
 
+        public override string GetTitleText()
+        {
+            return viewModel.PlaylistName;
+        }
+
         public override void DeleteSubView()
         {
             base.DeleteSubView();
index f655062ddccf1651152d062c2a199455ee9e212c..960ec0a4113a0691a7dedad24f41415705f555b8 100755 (executable)
@@ -19,7 +19,7 @@
   </ItemGroup>\r
 \r
   <ItemGroup>\r
-    <PackageReference Include="Tizen.NET" Version="10.0.0.17133" />\r
+    <PackageReference Include="Tizen.NET" Version="10.0.0.17150" />\r
     <PackageReference Include="Tizen.NET.Sdk" Version="1.1.7" />\r
   </ItemGroup>\r
 \r
index b5b20fc85e733dcad86f056984fb614a6589f3eb..ed27737dbbd059711dcd3e9e25fdcb32127891a1 100755 (executable)
Binary files a/packaging/org.tizen.MusicPlayer-1.0.0.tpk and b/packaging/org.tizen.MusicPlayer-1.0.0.tpk differ