/// <returns>A condition string</returns>
abstract protected string GetConditionStringForSelection();
- /// <summary>
- /// An event handler for update event
- /// </summary>
- private EventHandler UpdateListeners;
+ abstract public void SetContentUpdatedEventListener(EventHandler<ContentUpdatedEventArgs> listener);
private string TAG = "MediaHub";
try
{
ContentManager.Database.Update(media);
- UpdateListeners?.Invoke(this, EventArgs.Empty);
}
catch (Exception exception)
{
return true;
}
-
- /// <summary>
- /// A method for adding update event handler
- /// </summary>
- /// <param name="listener">An event handler to be executed</param>
- void SetUpdateListener(EventHandler listener)
- {
- UpdateListeners += listener;
- }
}
}
* limitations under the License.
*/
+using System;
+using Tizen.Content.MediaContent;
+using TVMediaHub.Tizen.Utils;
+
namespace TVMediaHub.Tizen.Models
{
/// <summary>
{
return "(MEDIA_TYPE=0) AND (MEDIA_MIME_TYPE LIKE 'image%') AND NOT (MEDIA_PATH LIKE '%.tn')";
}
+
+ public override void SetContentUpdatedEventListener(EventHandler<ContentUpdatedEventArgs> listener)
+ {
+ ContentDatabase.ContentUpdated += listener;
+ }
}
}
* limitations under the License.
*/
+using System;
+using Tizen.Content.MediaContent;
+
namespace TVMediaHub.Tizen.Models
{
/// <summary>
{
return "(MEDIA_TYPE=8)";
}
+
+ public override void SetContentUpdatedEventListener(EventHandler<ContentUpdatedEventArgs> listener)
+ {
+ ContentDatabase.ContentUpdated += listener;
+ }
}
}
DbgPort.D("PlayedAt : " + videoContent.PlayedAt.ToString());
ContentManager.Database.Update(videoContent);
}
+
+ public override void SetContentUpdatedEventListener(EventHandler<ContentUpdatedEventArgs> listener)
+ {
+ ContentDatabase.ContentUpdated += listener;
+ }
}
}
\ No newline at end of file
/// </summary>
private int displayingImageIndex;
+ private SortOption option = SortOption.Title;
+
/// <summary>
/// Gets or sets the displayingImageIndex
/// </summary>
ImageList = new ObservableCollection<GroupItem>();
SelectedList = new List<MediaInformation>();
OnPropertyChanged("ImageList");
+ MediaHubImpl.GetInstance.ImageProviderInstance.SetContentUpdatedEventListener((sender, arg) =>
+ {
+ DbgPort.D("Content updated");
+ /*
+ if (arg.UpdateType.Equals(MediaContentDBUpdateType.Update))
+ {
+ GetInformationsCommand?.Execute("");
+ }
+ */
+ });
}
/// <summary>
}
});
- SelectAllContentCommand = new Command(() =>
+ SelectAllContentCommand = new Command<bool>((IsSelectedAll) =>
{
- foreach (var group in ImageList)
+ if (IsSelectedAll)
{
- foreach (var info in group.Contents)
+ foreach (var group in ImageList)
{
- if (!SelectedList.Contains(info.Information))
+ foreach (var info in group.Contents)
{
- SelectedList.Add(info.Information);
+ if (!SelectedList.Contains(info.Information))
+ {
+ SelectedList.Add(info.Information);
+ }
}
}
}
+ else
+ {
+ SelectedList.Clear();
+ }
OnPropertyChanged("SelectedCount");
});
ChangeSortOptionCommand = new Command<string>((opt) =>
{
- var option = opt.ToLower();
- switch (option)
+ var optionString = opt.ToLower();
+ switch (optionString)
{
case "name":
ReadImageList(SortOption.Title);
+ option = SortOption.Title;
break;
case "event":
ReadImageList(SortOption.Date);
+ option = SortOption.Date;
break;
case "file format":
ReadImageList(SortOption.Type);
+ option = SortOption.Type;
break;
}
});
{
SynchronizationContext.Current.Post((o) =>
{
- ReadImageList(SortOption.Title);
+ ReadImageList(option);
}, "");
});
private bool isDeleteStatus;
+ private SortOption option = SortOption.Title;
+
/// <summary>
/// Gets or sets the MediaInformation of current video
/// </summary>
VideoList = new ObservableCollection<GroupItem>();
SelectedList = new List<MediaInformation>();
OnPropertyChanged("VideoList");
+ MediaHubImpl.GetInstance.VideoProviderInstance.SetContentUpdatedEventListener((sender, arg) =>
+ {
+ DbgPort.D("Content updated");
+ /*
+ if (arg.UpdateType.Equals(MediaContentDBUpdateType.Update))
+ {
+ GetInformationsCommand?.Execute("");
+ }
+ */
+ });
}
/// <summary>
});
ChangeSortOptionCommand = new Command<string>((opt) =>
{
- var option = opt.ToLower();
- switch (option)
+ var optionString = opt.ToLower();
+ switch (optionString)
{
case "date":
ReadVideoList(SortOption.Date);
+ option = SortOption.Date;
break;
case "genre":
ReadVideoList(SortOption.Genre);
+ option = SortOption.Genre;
break;
case "name":
ReadVideoList(SortOption.Title);
+ option = SortOption.Title;
break;
}
});
{
SynchronizationContext.Current.Post((o) =>
{
- ReadVideoList(SortOption.Title);
+ ReadVideoList(option);
}, "");
});
}
});
- SelectAllContentCommand = new Command(() =>
+ SelectAllContentCommand = new Command<bool>((IsSelectedAll) =>
{
- foreach (var group in VideoList)
+ if (IsSelectedAll)
{
- foreach (var info in group.Contents)
+ foreach (var group in VideoList)
{
- if (!SelectedList.Contains(info.Information))
+ foreach (var info in group.Contents)
{
- SelectedList.Add(info.Information);
+ if (!SelectedList.Contains(info.Information))
+ {
+ SelectedList.Add(info.Information);
+ }
}
}
}
+ else
+ {
+ SelectedList.Clear();
+ }
OnPropertyChanged("SelectedCount");
});
public EventHandler CancelButtonEvent;
/// <summary>
+ /// The flag that whether all contents are selected or not
+ /// </summary>
+ public bool IsSelectedAll { get; set; }
+
+ /// <summary>
/// Identifies the SelectedCount bindable property
/// </summary>
public static readonly BindableProperty SelectedCountProperty = BindableProperty.Create("SelectedCount", typeof(int), typeof(FooterDeleteStatus), 0);
public FooterDeleteStatus()
{
InitializeComponent();
+ IsSelectedAll = false;
+
SelectAllButton.Clicked += (s, e) =>
{
+ IsSelectedAll = !IsSelectedAll;
+
+ if (IsSelectedAll)
+ {
+ SelectAllButton.Text = "Unselect All";
+ }
+ else
+ {
+ SelectAllButton.Text = "Select All";
+ }
+
SelecteAllButtonEvent?.Invoke(s, e);
};
OkButton.Clicked += (s, e) =>
public List<Button> LeftFocusList { get; protected set; }
public List<Button> RightFocusList { get; protected set; }
public List<KeyValuePair<double, Button>> BottomFocusList { get; protected set; }
+ public List<ImageItem> ImageItemList { get; set; }
public EventHandler<GroupItemFocusEventArgs> GroupItemFocused;
LeftFocusList = new List<Button>();
RightFocusList = new List<Button>();
BottomFocusList = new List<KeyValuePair<double, Button>>();
+ ImageItemList = new List<ImageItem>();
GroupTitle.TextColor = Color.FromRgba(255, 255, 255, 31);
{
var index = 0;
ChildrenFocusList.Clear();
+ ImageItemList.Clear();
foreach (var item in ItemsSource)
{
var view = new ImageItem();
ChildrenFocusList.Add(view.GetFocusArea());
view.BindingContext = item;
+ ImageItemList.Add(view);
view.OnFocusedEventHandler += (se, ev) =>
{
GroupItemFocused?.Invoke(view, new GroupItemFocusEventArgs(X + view.X));
}
}
+ public void UpdateViewSelectAll(bool isSelectedAll)
+ {
+ if (!isSelectedAll)
+ {
+ ImgCheckDimmed.FadeTo(0.0, 167);
+ ImgCheck.FadeTo(0.0, 167);
+ CurStatus = ItemStatus.NORMAL;
+ }
+ else
+ {
+ ImgCheckDimmed.FadeTo(0.75, 167);
+ ImgCheck.FadeTo(0.99, 167);
+ CurStatus = ItemStatus.SELECTED;
+ }
+ }
+
/// <summary>
/// A method for updating view according to current status
/// </summary>
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(ImageTab), default(ObservableCollection<GroupItem>));
/// </summary>
private List<KeyValuePair<double, Button>> BottomButtonList;
+ public List<ImageGroup> ImageGroupList { get; set; }
+
/// <summary>
/// Identifies the SelectedCount bindable property
/// </summary>
private void InitializeData()
{
BottomButtonList = new List<KeyValuePair<double, Button>>();
+ ImageGroupList = new List<ImageGroup>();
}
/// <summary>
galleryGroup.BindingContext = group;
galleryGroup.SetClickCommand(OnClickCommand);
GalleryContentView.Children.Add(galleryGroup);
+ ImageGroupList.Add(galleryGroup);
galleryGroup.GetTitleFocusArea().Focused += (se, ev) =>
{
else if (e.Action.ToString().Equals("Reset"))
{
GalleryContentView.Children.Clear();
+ ImageGroupList.Clear();
if (!GalleryNoContents.IsVisible)
{
ImageTabScrollView.IsVisible = false;
/// <param name="e">An event's argument</param>
private void OnSelectAllClicked(object sender, EventArgs e)
{
- SelectAllContentCommand?.Execute("");
+ IsSelectedAll = FooterDelete.IsSelectedAll;
+ SelectAllContentCommand?.Execute(IsSelectedAll);
+
+ foreach (var group in ImageGroupList)
+ {
+ foreach (var item in group.ImageItemList)
+ {
+ item.UpdateViewSelectAll(IsSelectedAll);
+ }
+ }
}
/// <summary>
else if (SelectedCount > 1)
{
title = "Delete Selected";
+
+ if (IsSelectedAll)
+ {
+ title = "Delete All";
+ }
}
bool answer = await DisplayAlert(title, "Do you want to delete?", "YES", "NO");
GetInformationsCommand?.Execute("");
}
+ DeleteModeChangeCommand?.Execute("");
FooterNormal.IsVisible = true;
FooterDelete.IsVisible = false;
SetFooterFocusChain(ImageTabScrollView.ScrollX);
DeleteModeChangeCommand?.Execute("");
FooterNormal.IsVisible = false;
FooterDelete.IsVisible = true;
+ SetFooterFocusChain(ImageTabScrollView.ScrollX);
}
}
public List<KeyValuePair<double, Button>> BottomFocusList { get; protected set; }
/// <summary>
+ /// A list of video items
+ /// </summary>
+ public List<VideoItem> VideoItemList { get; set; }
+
+ /// <summary>
/// A constructor
/// Initializes several lists and properties that are used in this class
/// Initializes several size of the items that are used in this class
LeftFocusList = new List<Button>();
RightFocusList = new List<Button>();
BottomFocusList = new List<KeyValuePair<double, Button>>();
+ VideoItemList = new List<VideoItem>();
GroupTitle = new Xamarin.Forms.Label();
GroupTitleFocusArea = new Button();
{
var index = 0;
ChildrenFocusList.Clear();
+ VideoItemList.Clear();
foreach (var item in ItemsSource)
{
var view = new VideoItem();
ChildrenFocusList.Add(view.GetFocusArea());
view.BindingContext = item;
+ VideoItemList.Add(view);
view.OnFocusedEventHandler += (se, ev) =>
{
GroupItemFocused?.Invoke(view, new GroupItemFocusEventArgs(X + view.X));
}
}
+ public void UpdateViewSelectAll(bool isSelectedAll)
+ {
+ if (!isSelectedAll)
+ {
+ CheckDimImage.FadeTo(0.0, 167);
+ CheckImage.FadeTo(0.0, 167);
+ CurStatus = ItemStatus.NORMAL;
+ }
+ else
+ {
+ CheckDimImage.FadeTo(0.75, 167);
+ CheckImage.FadeTo(0.99, 167);
+ CurStatus = ItemStatus.SELECTED;
+ }
+ }
+
/// <summary>
/// A method for updating view according to current status
/// </summary>
private bool IsContentReady = false;
/// <summary>
+ /// The flag that whether all contents are selected or not
+ /// </summary>
+ private bool IsSelectedAll { get; set; }
+
+ public List<VideoGroup> VideoGroupList { get; set; }
+
+ /// <summary>
/// Identifies the ItemsSource bindable property
/// </summary>
public static readonly BindableProperty ItemsSourceProperty = BindableProperty.Create("ItemsSource", typeof(ObservableCollection<GroupItem>), typeof(VideoTab), default(ObservableCollection<GroupItem>));
private void InitializeData()
{
BottomButtonList = new List<KeyValuePair<double, Button>>();
+ VideoGroupList = new List<VideoGroup>();
}
/// <summary>
groupView.BindingContext = GroupItem;
groupView.SetClickCommand(OnClickCommand);
VideoTabList.Children.Add(groupView);
+ VideoGroupList.Add(groupView);
groupView.GroupTitleFocusArea.Focused += (se, ev) =>
{
{
BottomButtonList.Clear();
VideoTabList.Children.Clear();
+ VideoGroupList.Clear();
if (!VideoNoContents.IsVisible)
{
VideoTabScrollView.IsVisible = false;
/// <param name="e">An event's argument</param>
private void OnSelectAllClicked(object sender, EventArgs e)
{
- SelectAllContentCommand?.Execute("");
+ IsSelectedAll = FooterDelete.IsSelectedAll;
+ SelectAllContentCommand?.Execute(IsSelectedAll);
+
+ foreach (var group in VideoGroupList)
+ {
+ foreach (var item in group.VideoItemList)
+ {
+ item.UpdateViewSelectAll(IsSelectedAll);
+ }
+ }
}
/// <summary>
else if (SelectedCount > 1)
{
title = "Delete Selected";
+
+ if (IsSelectedAll)
+ {
+ title = "Delete All";
+ }
}
bool answer = await DisplayAlert(title, "Do you want to delete?", "YES", "NO");
GetInformationsCommand?.Execute("");
}
+ ChangeTabStatusCommand?.Execute("");
FooterNormal.IsVisible = true;
FooterDelete.IsVisible = false;
SetFooterFocusChain(VideoTabScrollView.ScrollX);