Changes the IsDeleteStatus property to the TabStatus property according to review comment
Change-Id: Ic67ebf2baa26a2f5907c8d829da359da9cb3965a
Signed-off-by: Hyerim Kim <rimi.kim@samsung.com>
using System.ComponentModel;
using TVMediaHub.Tizen.DataModels;
using Tizen.Content.MediaContent;
+using TVMediaHub.Tizen.ViewModels;
namespace TVMediaHub.Tizen.Models
{
}
/// <summary>
- /// A flag that whether the content is delete mode or not
+ /// An enumeration value indicates current tab's status
/// </summary>
- private bool isDeleteStatus;
-
+ private TabStatus currentTabStatus = TabStatus.Default;
/// <summary>
- /// Gets or sets the isDeleteStatus
+ /// Gets or sets the CurrentTabStatus
/// </summary>
- public bool IsDeleteStatus
+ public TabStatus CurrentTabStatus
{
get
{
- return isDeleteStatus;
+ return currentTabStatus;
}
set
{
- if (isDeleteStatus != value)
+ if (currentTabStatus != value)
{
- isDeleteStatus = value;
- OnPropertyChanged("IsDeleteStatus");
+ currentTabStatus = value;
+ OnPropertyChanged("CurrentTabStatus");
}
}
}
public MediaShortcutInfo(MediaInformationEx information)
{
Information = information;
- IsDeleteStatus = false;
+ CurrentTabStatus = TabStatus.Default;
}
/// <summary>
<Compile Include="ViewModels\MusicTabViewModel.cs" />
<Compile Include="ViewModels\MusicPlayerViewModelLocator.cs" />
<Compile Include="ViewModels\MusicTabViewModelLocator.cs" />
+ <Compile Include="ViewModels\TabStatus.cs" />
<Compile Include="ViewModels\VideoPlayerViewModel.cs" />
<Compile Include="ViewModels\VideoTabViewModel.cs" />
<Compile Include="ViewModels\VideoTabViewModelLocator.cs" />
public ICommand SelectAllContentCommand { get; set; }
/// <summary>
- /// A flag that whether the content is delete mode or not
+ /// An enumeration value indicates current image tab's status
/// </summary>
- private bool isDeleteStatus;
+ private TabStatus imageTabStatus = TabStatus.Default;
/// <summary>
- /// Gets or sets the isDeleteStatus
+ /// Gets or sets the ImageTabStatus
/// </summary>
- public bool IsDeleteStatus
+ public TabStatus ImageTabStatus
{
get
{
- return isDeleteStatus;
+ return imageTabStatus;
}
set
{
- if (isDeleteStatus != value)
+ if (imageTabStatus != value)
{
- isDeleteStatus = value;
- OnPropertyChanged("IsDeleteStatus");
+ imageTabStatus = value;
+ OnPropertyChanged("ImageTabStatus");
}
}
}
{
SelectedList.Clear();
OnPropertyChanged("SelectedCount");
- IsDeleteStatus = !IsDeleteStatus;
+
+ if (ImageTabStatus == TabStatus.Default)
+ {
+ ImageTabStatus = TabStatus.Delete;
+ }
+ else
+ {
+ ImageTabStatus = TabStatus.Default;
+ }
foreach (var group in ImageList)
{
foreach (var info in group.Contents)
{
- info.IsDeleteStatus = IsDeleteStatus;
+ info.CurrentTabStatus = ImageTabStatus;
}
}
});
SetCurrentImageInfo = new Command<MediaInformationEx>((info) =>
{
- if (IsDeleteStatus)
+ if (ImageTabStatus == TabStatus.Delete)
{
if (SelectedList.Contains(info))
{
* limitations under the License.
*/
+using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
+using System.IO;
using System.Threading;
using System.Windows.Input;
using TVMediaHub.Tizen.DataModels;
public ICommand GetInformationsCommand { get; set; }
/// <summary>
+ /// A command for deleting a video content
+ /// </summary>
+ public ICommand DeleteContentCommand { get; set; }
+
+ /// <summary>
+ /// A command for selecting all video contents
+ /// </summary>
+ public ICommand SelectAllContentCommand { get; set; }
+
+ /// <summary>
+ /// A command to set current music information
+ /// </summary>
+ public ICommand SelectMusicItem { get; set; }
+
+ /// <summary>
/// A command for changing Source
/// </summary>
public ICommand ChangeSourceCommand { get; set; }
/// <summary>
+ /// A command for changing tab's status
+ /// </summary>
+ public ICommand ChangeTabStatusCommand { get; set; }
+
+ /// <summary>
/// The information of the current music
/// </summary>
public MediaInformationEx CurrentMusic { get; set; }
/// <summary>
+ /// A value indicates current Music tab's status
+ /// </summary>
+ private TabStatus musicTabStatus = TabStatus.Default;
+
+ /// <summary>
+ /// Gets or sets the MusicTabStatus
+ /// </summary>
+ public TabStatus MusicTabStatus
+ {
+ get
+ {
+ return musicTabStatus;
+ }
+
+ set
+ {
+ if (musicTabStatus != value)
+ {
+ musicTabStatus = value;
+ OnPropertyChanged("MusicTabStatus");
+ }
+ }
+ }
+
+ /// <summary>
+ /// A list of video contents to be displayed
+ /// </summary>
+ public List<MediaInformationEx> SelectedList { get; set; }
+
+ /// <summary>
+ /// A count of SelectedList
+ /// </summary>
+ public int SelectedCount
+ {
+ get
+ {
+ return SelectedList.Count;
+ }
+ }
+
+ /// <summary>
/// The sort option to display items of the music tab
/// </summary>
private SortOption option = SortOption.Title;
{
MusicList = new ObservableCollection<GroupItem>();
sourcePairList = new Dictionary<string, string>();
+ SelectedList = new List<MediaInformationEx>();
InitializeFooterItemsSource();
InitializeCommands();
}
/// <summary>
- /// A method for initializing commands that are used in Image tab
+ /// A method for initializing commands that are used in Music tab
/// </summary>
private void InitializeCommands()
{
+ ChangeTabStatusCommand = new Command(() =>
+ {
+ SelectedList.Clear();
+ OnPropertyChanged("SelectedCount");
+
+ if (MusicTabStatus.Equals(TabStatus.Default))
+ {
+ MusicTabStatus = TabStatus.Delete;
+ }
+ else
+ {
+ MusicTabStatus = TabStatus.Default;
+ }
+ });
+
+ SelectAllContentCommand = new Command<bool>((IsSelectedAll) =>
+ {
+ if (IsSelectedAll)
+ {
+ foreach (var group in MusicList)
+ {
+ foreach (var info in group.Contents)
+ {
+ if (!SelectedList.Contains(info.Information))
+ {
+ SelectedList.Add(info.Information);
+ }
+ }
+ }
+ }
+ else
+ {
+ SelectedList.Clear();
+ }
+
+ OnPropertyChanged("SelectedCount");
+ });
+
+ DeleteContentCommand = new Command<MediaInformationEx>((SelectedItem) =>
+ {
+ if (SelectedItem != null)
+ {
+ SelectedList.Clear();
+ SelectedList.Add(SelectedItem);
+ }
+
+ foreach (var info in SelectedList)
+ {
+ try
+ {
+ File.Delete(info.MediaContentInformation.FilePath);
+ }
+ catch (Exception exception)
+ {
+ // TODO: Handling exceptions
+ DbgPort.E("Exception - " + exception.Message);
+ return;
+ }
+
+ MediaHubImpl.GetInstance.MusicProviderInstance.Delete(info);
+ }
+ });
+
+ SelectMusicItem = new Command<MediaInformationEx>((info) =>
+ {
+ if (MusicTabStatus == TabStatus.Delete)
+ {
+ if (SelectedList.Contains(info))
+ {
+ SelectedList.Remove(info);
+ }
+ else
+ {
+ SelectedList.Add(info);
+ }
+
+ OnPropertyChanged("SelectedCount");
+ }
+ else
+ {
+ SetCurrentMusic(info);
+ }
+ });
+
ChangeSortOptionCommand = new Command<string>((opt) =>
{
var optionString = opt.ToLower();
}, "");
});
+ OnPropertyChanged("ChangeTabStatusCommand");
OnPropertyChanged("ChangeSortOptionCommand");
}
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace TVMediaHub.Tizen.ViewModels\r
+{\r
+ public enum TabStatus\r
+ {\r
+ Default,\r
+ Delete\r
+ }\r
+}\r
}
/// <summary>
- /// A flag that whether the content is delete mode or not
- /// </summary>
- private bool isDeleteStatus;
-
- /// <summary>
/// A sort option
/// </summary>
private SortOption option = SortOption.Title;
}
/// <summary>
- /// Gets or sets the DeleteStatus
+ /// An enumeration value indicates current video tab's status
+ /// </summary>
+ private TabStatus videoTabStatus = TabStatus.Default;
+
+ /// <summary>
+ /// Gets or sets the VideoTabStatus
/// </summary>
- public bool IsDeleteStatus
+ public TabStatus VideoTabStatus
{
get
{
- return isDeleteStatus;
+ return videoTabStatus;
}
set
{
- if (isDeleteStatus != value)
+ if (videoTabStatus != value)
{
- isDeleteStatus = value;
- OnPropertyChanged("IsDeleteStatus");
+ videoTabStatus = value;
+ OnPropertyChanged("VideoTabStatus");
}
}
}
{
SelectedList.Clear();
OnPropertyChanged("SelectedCount");
- IsDeleteStatus = !IsDeleteStatus;
+ if (VideoTabStatus == TabStatus.Default)
+ {
+ VideoTabStatus = TabStatus.Delete;
+ }
+ else
+ {
+ VideoTabStatus = TabStatus.Default;
+ }
foreach (var group in VideoList)
{
foreach (var info in group.Contents)
{
- info.IsDeleteStatus = IsDeleteStatus;
+ info.CurrentTabStatus = VideoTabStatus;
}
}
});
});
SetCurrentVideoInfo = new Command<MediaInformationEx>((info) =>
{
- if (IsDeleteStatus)
+ if (VideoTabStatus == TabStatus.Delete)
{
if (SelectedList.Contains(info))
{
xmlns:Utils="clr-namespace:TVMediaHub.Tizen.Utils"
xmlns:Views="clr-namespace:TVMediaHub.Tizen.Views"
ImageInfo="{Binding Information}"
- IsDeleteMode="{Binding IsDeleteStatus}">
+ ImageTabStatus="{Binding CurrentTabStatus}">
<Button x:Name="FocusArea"
Opacity="0"
Clicked="OnItemClicked"
using TVMediaHub.Tizen.DataModels;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
+using TVMediaHub.Tizen.ViewModels;
namespace TVMediaHub.Tizen.Views
{
public ContextPopupItemSelectedEventHandler ContextPopupItemSelectedHandler;
/// <summary>
- /// Identifies the IsDeleteMode bindable property
+ /// Identifies the ImageTabStatus bindable property
/// </summary>
- public static readonly BindableProperty IsDeleteModeProperty = BindableProperty.Create("IsDeleteMode", typeof(bool), typeof(ImageItem), false);
+ public static readonly BindableProperty ImageTabStatusProperty = BindableProperty.Create("ImageTabStatus", typeof(TabStatus), typeof(ImageItem), TabStatus.Default);
/// <summary>
- /// Gets or sets the value whether item is delete mode or not
+ /// Gets or sets ImageTabStatus
/// </summary>
- public bool IsDeleteMode
+ public TabStatus ImageTabStatus
{
set
{
- SetValue(IsDeleteModeProperty, value);
+ SetValue(ImageTabStatusProperty, value);
}
get
{
- return (bool)GetValue(IsDeleteModeProperty);
+ return (TabStatus)GetValue(ImageTabStatusProperty);
}
}
ImageArea.LayoutTo(ImageAreaFocusedBounds, 167);
#pragma warning restore CS4014
OnItemClickedHandler?.Invoke(SelectedImage);
- if (IsDeleteMode)
+ if (ImageTabStatus == TabStatus.Delete)
{
if (CurStatus == ItemStatus.Normal)
{
/// <param name="e">A propertyChanged event argument</param>
private void ImageTabPropertyChanged(object sender, PropertyChangedEventArgs e)
{
- if (e.PropertyName.CompareTo("IsDeleteMode") == 0)
+ if (e.PropertyName.CompareTo("ImageTabStatus") == 0)
{
- if (!IsDeleteMode)
+ if (ImageTabStatus == TabStatus.Default)
{
CurStatus = ItemStatus.Normal;
UpdateView();
UnavailableIcon.LayoutTo(ImageFocusedBounds, 500, easing);
}
- if (IsDeleteMode)
+ if (ImageTabStatus == TabStatus.Delete)
{
ImgCheckDimmed.LayoutTo(ImageAreaFocusedBounds, 500, easing);
ImgCheck.LayoutTo(ImageAreaFocusedBounds, 500, easing);
ImgFocused.LayoutTo(ShadowNormalBounds, 167, easing);
ImgDimmed.LayoutTo(ImageAreaNormalBounds, 167, easing);
- if (IsDeleteMode)
+ if (ImageTabStatus == TabStatus.Delete)
{
ImgCheckDimmed.LayoutTo(ImageAreaNormalBounds, 167, easing);
ImgCheck.LayoutTo(ImageAreaNormalBounds, 167, easing);
xmlns:Views="clr-namespace:TVMediaHub.Tizen.Views"
xmlns:ViewModels="clr-namespace:TVMediaHub.Tizen.ViewModels"
ItemsSource="{Binding ImageList}"
- IsDeleteStatus="{Binding IsDeleteStatus}"
+ ImageTabStatus="{Binding ImageTabStatus}"
GetInformationsCommand="{Binding GetInformationsCommand}"
ChangeSortOptionCommand="{Binding ChangeSortOptionCommand}"
ChangeSourceCommand="{Binding ChangeSourceCommand}"
}
/// <summary>
- /// Identifies the IsDeleteStatus bindable property
+ /// Identifies the ImageTabStatus bindable property
/// </summary>
- public static readonly BindableProperty IsDeleteStatusProperty = BindableProperty.Create("IsDeleteStatus", typeof(bool), typeof(ImageTab), false);
+ public static readonly BindableProperty ImageTabStatusProperty = BindableProperty.Create("ImageTabStatus", typeof(TabStatus), typeof(ImageTab), TabStatus.Default);
/// <summary>
- /// Gets or sets IsDeleteStatus
+ /// Gets or sets ImageTabStatus
/// </summary>
- public bool IsDeleteStatus
+ public TabStatus ImageTabStatus
{
- get { return (bool)GetValue(IsDeleteStatusProperty); }
- set { SetValue(IsDeleteStatusProperty, value); }
+ get { return (TabStatus)GetValue(ImageTabStatusProperty); }
+ set { SetValue(ImageTabStatusProperty, value); }
}
/// <summary>
ItemsSource.Clear();
GalleryContentView.Children.Clear();
BottomButtonList.Clear();
- if (IsDeleteStatus)
+ if (ImageTabStatus == TabStatus.Delete)
{
DeleteModeChangeCommand?.Execute("");
FooterNormal.IsVisible = true;
var btn = list[buttonIndex].Value;
if (buttonIndex == 0)
{
- if (IsDeleteStatus)
+ if (ImageTabStatus == TabStatus.Delete)
{
btn.On<Xamarin.Forms.PlatformConfiguration.Tizen>().SetNextFocusDownView(FooterDelete.GetSelectAllButton());
// TODO : FooterDelete.GetSelectAllButton().DropdownSource.ButtonOption.On<Xamarin.Forms.PlatformConfiguration.Tizen>().SetNextFocusUpView(btn);
}
else if (buttonIndex == list.Count - 1)
{
- if (IsDeleteStatus)
+ if (ImageTabStatus == TabStatus.Delete)
{
btn.On<Xamarin.Forms.PlatformConfiguration.Tizen>().SetNextFocusDownView(FooterDelete.GetCancelButton());
FooterDelete.GetCancelButton().On<Xamarin.Forms.PlatformConfiguration.Tizen>().SetNextFocusUpView(btn);
}
else
{
- if (IsDeleteStatus)
+ if (ImageTabStatus == TabStatus.Delete)
{
btn.On<Xamarin.Forms.PlatformConfiguration.Tizen>().SetNextFocusDownView(FooterDelete.GetOkButton());
// TODO :FooterDelete.GetCancelAllButton().ButtonOption.On<Xamarin.Forms.PlatformConfiguration.Tizen>().SetNextFocusUpView(btn);
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using System.Windows.Input;
using TVMediaHub.Tizen.Models;
using TVMediaHub.Tizen.Utils;
using Xamarin.Forms;
}
/// <summary>
+ /// A list of music items
+ /// </summary>
+ public List<MusicItem> MusicItemList { get; set; }
+
+ /// <summary>
+ /// A command will be executed when item is clicked
+ /// </summary>
+ private ICommand ItemClickCommand;
+
+ /// <summary>
/// A constructor
/// </summary>
public MusicGroup()
{
InitializeComponent();
InitializeSize();
+ Init();
PropertyChanged += MusicGroupPropertyChanged;
}
/// <summary>
+ /// A method for initializing several lists and properties that are used in this class
+ /// </summary>
+ private void Init()
+ {
+ MusicItemList = new List<MusicItem>();
+ }
+
+ /// <summary>
/// A method for initializing sizes
/// </summary>
private void InitializeSize()
}
/// <summary>
+ /// A method for setting the command to ItemClickCommand
+ /// </summary>
+ /// <param name="command">A command to be set</param>
+ public void SetClickCommand(ICommand command)
+ {
+ ItemClickCommand = command;
+ }
+
+ /// <summary>
/// This method is called when the properties is changed
/// </summary>
/// <param name="sender">The source of the event</param>
if (e.PropertyName.Equals("ItemsSource"))
{
var index = 0;
+ MusicItemList.Clear();
foreach (var item in ItemsSource)
{
var itemView = new MusicItem();
itemView.BindingContext = item;
+ MusicItemList.Add(itemView);
itemView.OnFocusedEventHandler += (se, ev) =>
{
GroupContentArea.RaiseChild(itemView);
};
+ itemView.OnItemClickedHandler += (info) =>
+ {
+ ItemClickCommand?.Execute(info);
+ };
+
GroupContentArea.Children.Add(itemView, index / 4, index % 4);
index++;
}
public EventHandler OnUnfocusedEventHandler;
/// <summary>
+ /// A delegate will be executed when the item is clicked
+ /// </summary>
+ /// <param name="info">A clicked item's MediaInformation</param>
+ public delegate void ItemEventHandler(MediaInformationEx info);
+ /// <summary>
+ /// A ClickEventHandler for click event of the item
+ /// </summary>
+ public ItemEventHandler OnItemClickedHandler;
+
+ /// <summary>
/// Bounds for TextArea when item is unfocused
/// </summary>
private Rectangle TextAreaNormalBounds;
/// <param name="e">A Focus event's argument</param>
private void OnItemClicked(object sender, EventArgs e)
{
- DbgPort.D("MusicItem is clicked : " + (MusicInfo.MediaContentInformation as AudioInformation).Title);
-
- MusicTabViewModelLocator.ViewModel.SetCurrentMusic(MusicInfo);
+ OnItemClickedHandler?.Invoke(MusicInfo);
}
/// <summary>
ChangeSortOptionCommand="{Binding ChangeSortOptionCommand}"
GetInformationsCommand="{Binding GetInformationsCommand}"
ChangeSourceCommand="{Binding ChangeSourceCommand}"
- ItemsSource="{Binding MusicList}">
+ ItemsSource="{Binding MusicList}"
+ ChangeTabStatusCommand="{Binding ChangeTabStatusCommand}"
+ OnClickCommand="{Binding SelectMusicItem}"
+ DeleteContentCommand="{Binding DeleteContentCommand}"
+ SelectAllContentCommand="{Binding SelectAllContentCommand}"
+ SelectedCount="{Binding SelectedCount}"
+ MusicTabStatus="{Binding MusicTabStatus}">
<!-- TODO : Fix to Guide -->
<RelativeLayout RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
IsVisible="False"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
- SelectedCount="{Binding SelectedCount}" />
+ SelectedCount="{Binding SelectedCount}"
+ ContentType="Music"/>
<Views:FooterNormalStatus x:Name="FooterNormal"
IsVisible="True"
IsFooterEnabled="True"
* limitations under the License.
*/
+using System;
+using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Windows.Input;
private bool IsContentReady = false;
/// <summary>
+ /// The flag that whether all contents are selected or not
+ /// </summary>
+ private bool IsSelectedAll { get; set; }
+
+ /// <summary>
/// Identifies the ItemsSource bindable property
/// </summary>
public static readonly BindableProperty ItemsSourceProperty = BindableProperty.Create("ItemsSource", typeof(ObservableCollection<GroupItem>), typeof(MusicTab), default(ObservableCollection<GroupItem>));
}
/// <summary>
+ /// Identifies the ChangeTabStatusCommand bindable property
+ /// </summary>
+ public static readonly BindableProperty ChangeTabStatusCommandProperty = BindableProperty.Create("ChangeTabStatusCommand", typeof(ICommand), typeof(MusicTab), default(ICommand));
+
+ /// <summary>
+ /// Gets or sets ChangeTabStatus Command
+ /// </summary>
+ public ICommand ChangeTabStatusCommand
+ {
+ get { return (ICommand)GetValue(ChangeTabStatusCommandProperty); }
+ set { SetValue(ChangeTabStatusCommandProperty, value); }
+ }
+
+ /// <summary>
+ /// Identifies the MusicTabStatus bindable property
+ /// </summary>
+ public static readonly BindableProperty MusicTabStatusProperty = BindableProperty.Create("MusicTabStatus", typeof(TabStatus), typeof(MusicTab), TabStatus.Default);
+
+ /// <summary>
+ /// Gets or sets MusicTabStatus
+ /// </summary>
+ public TabStatus MusicTabStatus
+ {
+ get { return (TabStatus)GetValue(MusicTabStatusProperty); }
+ set { SetValue(MusicTabStatusProperty, value); }
+ }
+
+ /// <summary>
+ /// Identifies the DeleteContentCommand bindable property
+ /// </summary>
+ public static readonly BindableProperty DeleteContentCommandProperty = BindableProperty.Create("DeleteContentCommand", typeof(ICommand), typeof(MusicTab), default(ICommand));
+
+ /// <summary>
+ /// Gets or sets DeleteContent Command
+ /// </summary>
+ public ICommand DeleteContentCommand
+ {
+ get { return (ICommand)GetValue(DeleteContentCommandProperty); }
+ set { SetValue(DeleteContentCommandProperty, value); }
+ }
+
+ /// <summary>
+ /// Identifies the DeleteContentCommand bindable property
+ /// </summary>
+ public static readonly BindableProperty SelectAllContentCommandProperty = BindableProperty.Create("SelectAllContentCommand", typeof(ICommand), typeof(MusicTab), default(ICommand));
+
+ /// <summary>
+ /// Gets or sets SelectAllContent Command
+ /// </summary>
+ public ICommand SelectAllContentCommand
+ {
+ get { return (ICommand)GetValue(SelectAllContentCommandProperty); }
+ set { SetValue(SelectAllContentCommandProperty, value); }
+ }
+
+ /// <summary>
+ /// Identifies the OnClickCommand bindable property
+ /// </summary>
+ public static readonly BindableProperty OnClickCommandProperty = BindableProperty.Create("OnClickCommand", typeof(ICommand), typeof(MusicTab), default(ICommand));
+
+ /// <summary>
+ /// Gets or sets OnClick Command
+ /// </summary>
+ public ICommand OnClickCommand
+ {
+ get
+ {
+ return (ICommand)GetValue(OnClickCommandProperty);
+ }
+
+ set
+ {
+ SetValue(OnClickCommandProperty, value);
+ }
+ }
+
+ /// <summary>
+ /// Identifies the SelectedCount bindable property
+ /// </summary>
+ public static readonly BindableProperty SelectedCountProperty = BindableProperty.Create("SelectedCount", typeof(int), typeof(MusicTab), 0);
+
+ /// <summary>
+ /// Gets or sets count of selected item
+ /// </summary>
+ public int SelectedCount
+ {
+ get { return (int)GetValue(SelectedCountProperty); }
+ set { SetValue(SelectedCountProperty, value); }
+ }
+
+ /// <summary>
/// Identifies the GetInformationsCommand bindable property
/// </summary>
public static readonly BindableProperty GetInformationsCommandProperty = BindableProperty.Create("GetInformationsCommand", typeof(ICommand), typeof(MusicTab), default(ICommand));
private void InitializeFooter()
{
FooterNormal.OnDropdownSourceItemSelected += OnSourceChanged;
-
FooterNormal.OnDropdownSortItemSelected += OnSortOptionChanged;
-
FooterNormal.OnSelectedOptionIndexChanged += OnOptionSelected;
+ FooterDelete.SelecteAllButtonEvent += OnSelectAllClicked;
+ FooterDelete.OKButtonEvent += OnOKClicked;
+ FooterDelete.CancelButtonEvent += OnCancelClicked;
}
/// <summary>
var groupItem = e.NewItems[0];
groupView.BindingContext = groupItem;
+ groupView.SetClickCommand(OnClickCommand);
MusicContentView.Children.Add(groupView);
}
else if (e.Action.ToString().Equals(NotifyCollectionChangedAction.Reset.ToString()))
/// <param name="e">A SelectedItemChanged event's argument</param>
private void OnOptionSelected(object sender, ContextPopupSelectedEventArgs e)
{
+ var label = e.Item.Label.Trim().ToLower();
+ if (label.Equals("delete"))
+ {
+ ChangeTabStatusCommand?.Execute("");
+ FooterNormal.IsVisible = false;
+ FooterDelete.IsVisible = true;
+ }
+ else if (label.Equals("detail info"))
+ {
+ // TODO : Display the alert popup
+ }
+ }
+
+ /// <summary>
+ /// This method is called when cancel button is clicked
+ /// </summary>
+ /// <param name="sender">The source of the event</param>
+ /// <param name="e">An event's argument</param>
+ private void OnCancelClicked(object sender, EventArgs e)
+ {
+ ChangeTabStatusCommand?.Execute("");
+ FooterNormal.IsVisible = true;
+ FooterDelete.IsVisible = false;
+ }
+
+ /// <summary>
+ /// This method is called when SelectAll button is clicked
+ /// </summary>
+ /// <param name="sender">The source of the event</param>
+ /// <param name="e">An event's argument</param>
+ private void OnSelectAllClicked(object sender, EventArgs e)
+ {
+ IsSelectedAll = FooterDelete.IsSelectedAll;
+ SelectAllContentCommand?.Execute(IsSelectedAll);
+ }
+
+ /// <summary>
+ /// This method is called when OK button is clicked
+ /// </summary>
+ /// <param name="sender">The source of the event</param>
+ /// <param name="e">An event's argument</param>
+ private async void OnOKClicked(object sender, EventArgs e)
+ {
+ string title = "Delete";
+
+ if (SelectedCount < 1)
+ {
+ return;
+ }
+ else if (SelectedCount > 1)
+ {
+ title = "Delete Selected";
+
+ if (IsSelectedAll)
+ {
+ title = "Delete All";
+ }
+ }
+
+ bool answer = await DisplayAlert(title, "Do you want to delete?", "YES", "NO");
+
+ if (answer)
+ {
+ DeleteContentCommand?.Execute(null);
+ GetInformationsCommand?.Execute("");
+ }
+
+ ChangeTabStatusCommand?.Execute("");
+ FooterNormal.IsVisible = true;
+ FooterDelete.IsVisible = false;
}
}
}
x:Class="TVMediaHub.Tizen.Views.VideoItem"
xmlns:Views="clr-namespace:TVMediaHub.Tizen.Views"
VideoInfo="{Binding Information}"
- IsDeleteMode="{Binding IsDeleteStatus}">
+ VideoTabStatus="{Binding CurrentTabStatus}">
<Button x:Name ="FocusArea"
Opacity="0"
Clicked="OnItemClicked"
using TVMediaHub.Tizen.Utils;
using TVMediaHub.Tizen.DataModels;
using Xamarin.Forms;
+using TVMediaHub.Tizen.ViewModels;
namespace TVMediaHub.Tizen.Views
{
public ContextPopupItemSelectedEventHandler ContextPopupItemSelectedHandler;
/// <summary>
- /// Identifies the IsDeleteMode bindable property
+ /// Identifies the VideoTabStatus bindable property
/// </summary>
- public static readonly BindableProperty IsDeleteModeProperty = BindableProperty.Create("IsDeleteMode", typeof(bool), typeof(VideoItem), false);
+ public static readonly BindableProperty VideoTabStatusProperty = BindableProperty.Create("VideoTabStatus", typeof(TabStatus), typeof(VideoItem), TabStatus.Default);
/// <summary>
- /// Gets or sets the value whether item is delete mode or not
+ /// Gets or sets VideoTabStatus
/// </summary>
- public bool IsDeleteMode
+ public TabStatus VideoTabStatus
{
set
{
- SetValue(IsDeleteModeProperty, value);
+ SetValue(VideoTabStatusProperty, value);
}
get
{
- return (bool)GetValue(IsDeleteModeProperty);
+ return (TabStatus)GetValue(VideoTabStatusProperty);
}
}
PlayImage.FadeTo(0.0, 167);
}
- if (IsDeleteMode)
+ if (VideoTabStatus == TabStatus.Delete)
{
CheckDimImage.LayoutTo(NormalBounds, 167, easing);
CheckImage.LayoutTo(NormalBounds, 167, easing);
PlayImage.FadeTo(0.99, 167);
}
- if (IsDeleteMode)
+ if (VideoTabStatus == TabStatus.Delete)
{
CheckDimImage.LayoutTo(FocusedBounds, 167, easing);
CheckImage.LayoutTo(FocusedBounds, 167, easing);
CheckImage.LayoutTo(FocusedBounds, 167);
ImageArea.LayoutTo(FocusedBounds, 167);
OnItemClickedHandler?.Invoke(VideoInfo);
- if (IsDeleteMode)
+
+ if (VideoTabStatus == TabStatus.Delete)
{
if (CurStatus == ItemStatus.Normal)
{
/// <param name="e">A propertyChanged event argument</param>
private void VideoItemPropertyChanged(object sender, PropertyChangedEventArgs e)
{
- if (e.PropertyName.CompareTo("IsDeleteMode") == 0)
+ if (e.PropertyName.CompareTo("VideoTabStatus") == 0)
{
- if (!IsDeleteMode)
+ if (VideoTabStatus == TabStatus.Default)
{
CurStatus = ItemStatus.Normal;
UpdateView();
xmlns:ViewModels="clr-namespace:TVMediaHub.Tizen.ViewModels"
Title="Movie"
ItemsSource="{Binding VideoList}"
- IsDeleteStatus="{Binding IsDeleteStatus}"
+ VideoTabStatus="{Binding VideoTabStatus}"
ChangeTabStatusCommand="{Binding ChangeTabStatusCommand}"
ChangeSortOptionCommand="{Binding ChangeSortOptionCommand}"
ChangeSourceCommand="{Binding ChangeSourceCommand}"
}
/// <summary>
- /// Identifies the IsDeleteStatus bindable property
+ /// Identifies the VideoTabStatus bindable property
/// </summary>
- public static readonly BindableProperty IsDeleteStatusProperty = BindableProperty.Create("IsDeleteStatus", typeof(bool), typeof(VideoTab), false);
+ public static readonly BindableProperty VideoTabStatusProperty = BindableProperty.Create("VideoTabStatus", typeof(TabStatus), typeof(VideoTab), TabStatus.Default);
/// <summary>
- /// Gets or sets IsDeleteStatus
+ /// Gets or sets VideoTabStatus
/// </summary>
- public bool IsDeleteStatus
+ public TabStatus VideoTabStatus
{
- get { return (bool)GetValue(IsDeleteStatusProperty); }
- set { SetValue(IsDeleteStatusProperty, value); }
+ get { return (TabStatus)GetValue(VideoTabStatusProperty); }
+ set { SetValue(VideoTabStatusProperty, value); }
}
/// <summary>
ItemsSource.Clear();
VideoTabList.Children.Clear();
BottomButtonList.Clear();
- if (IsDeleteStatus)
+ if (VideoTabStatus == TabStatus.Delete)
{
ChangeTabStatusCommand?.Execute("");
FooterNormal.IsVisible = true;
var btn = list[buttonIndex].Value;
if (buttonIndex == 0)
{
- if (IsDeleteStatus)
+ if (VideoTabStatus == TabStatus.Delete)
{
btn.On<Xamarin.Forms.PlatformConfiguration.Tizen>().SetNextFocusDownView(FooterDelete.GetSelectAllButton());
// TODO : FooterDelete.GetSelectAllButton().DropdownSource.ButtonOption.On<Xamarin.Forms.PlatformConfiguration.Tizen>().SetNextFocusUpView(btn);
}
else if (buttonIndex == list.Count - 1)
{
- if (IsDeleteStatus)
+ if (VideoTabStatus == TabStatus.Delete)
{
btn.On<Xamarin.Forms.PlatformConfiguration.Tizen>().SetNextFocusDownView(FooterDelete.GetCancelButton());
FooterDelete.GetCancelButton().On<Xamarin.Forms.PlatformConfiguration.Tizen>().SetNextFocusUpView(btn);
}
else
{
- if (IsDeleteStatus)
+ if (VideoTabStatus == TabStatus.Delete)
{
btn.On<Xamarin.Forms.PlatformConfiguration.Tizen>().SetNextFocusDownView(FooterDelete.GetOkButton());
// TODO :FooterDelete.GetCancelAllButton().ButtonOption.On<Xamarin.Forms.PlatformConfiguration.Tizen>().SetNextFocusUpView(btn);