/// </summary>
abstract protected void CheckUnavailableContent(MediaInformationEx mediaContent);
- abstract public void SetContentUpdatedEventListener(EventHandler<ContentUpdatedEventArgs> listener);
+ /// <summary>
+ /// A method for handling ContentUpdatedEvent
+ /// </summary>
+ /// <param name="listener">A handling method</param>
+ abstract public void SetContentUpdatedEventListener(EventHandler listener);
+
+ /// <summary>
+ /// An EventHandler be sent to Image, Video and MusicProvider when ContentUpdated event is triggered
+ /// </summary>
+ public EventHandler ContentUpdateFinished;
/// <summary>
/// A constructor
try
{
ContentDatabase.Connect();
+ ContentDatabase.ContentUpdated += ContentDatabaseContentUpdated;
}
catch (Exception e)
{
}
/// <summary>
+ /// Handles ContentUpdated event that is triggered when db is changed.
+ /// </summary>
+ /// <param name="sender">The source of the event</param>
+ /// <param name="e">A ContentUpdatedEvent arguments</param>
+ private void ContentDatabaseContentUpdated(object sender, ContentUpdatedEventArgs e)
+ {
+ if (e.UpdateType == MediaContentDBUpdateType.Update)
+ {
+ MediaHubImpl.GetInstance.StorageProviderInstance.CheckStorage();
+ ContentUpdateFinished?.Invoke(this, null);
+ }
+ }
+
+ /// <summary>
/// Converts the value of the DateTime object to its equivalent string representation.
/// </summary>
/// <param name="date">A DateTime information</param>
}
}
- public override void SetContentUpdatedEventListener(EventHandler<ContentUpdatedEventArgs> listener)
+ public override void SetContentUpdatedEventListener(EventHandler listener)
{
- ContentDatabase.ContentUpdated += listener;
+ base.ContentUpdateFinished += listener;
}
}
}
}
/// <summary>
+ /// An instance of the StorageProvider
+ /// </summary>
+ private static readonly StorageProvider storageProviderInstance = new StorageProvider();
+ /// <summary>
+ /// Gets an instance of the StorageProvider
+ /// </summary>
+ public StorageProvider StorageProviderInstance
+ {
+ get
+ {
+ return storageProviderInstance;
+ }
+ }
+
+ /// <summary>
/// A constructor
/// </summary>
public MediaHubImpl()
}
}
- public override void SetContentUpdatedEventListener(EventHandler<ContentUpdatedEventArgs> listener)
+ public override void SetContentUpdatedEventListener(EventHandler listener)
{
- ContentDatabase.ContentUpdated += listener;
+ base.ContentUpdateFinished += listener;
}
}
}
public class StorageProvider
{
/// <summary>
+ /// A list of external storage
+ /// </summary>
+ private IEnumerable<Storage> storageList = new List<Storage>();
+
+ /// <summary>
+ /// A list of storage id
+ /// </summary>
+ public List<string> StorageId { get; protected set; }
+
+ /// <summary>
/// A constructor
/// </summary>
public StorageProvider()
{
- /// Connect to the media database to search, insert, remove or modify media information.
- ContentDatabase.Connect();
+ StorageId = new List<string>();
+ CheckStorage();
}
/// <summary>
- /// Returns the ContentCollections with optional filter from the media database.
+ /// Returns the list of the storage id of the media storage.
/// </summary>
/// <returns>Task with the list of the ContentCollection</returns>
- public IEnumerable<Storage> Read()
+ public void CheckStorage()
{
- return ContentManager.Database.SelectAll<Storage>(null);
- }
+ StorageId.Clear();
+ storageList = ContentManager.Database.SelectAll<Storage>(null);
+ foreach (var item in storageList)
+ {
+ StorageId.Add(item.Id);
+ }
+ }
}
}
ContentManager.Database.Update(videoContent.MediaContentInformation);
}
- public override void SetContentUpdatedEventListener(EventHandler<ContentUpdatedEventArgs> listener)
+ public override void SetContentUpdatedEventListener(EventHandler listener)
{
- ContentDatabase.ContentUpdated += listener;
+ base.ContentUpdateFinished += listener;
}
}
}
\ No newline at end of file
using System.Windows.Input;
using Xamarin.Forms;
using System.Linq;
-using Tizen.Content.MediaContent;
using TVMediaHub.Tizen.Models;
using TVMediaHub.Tizen.DataModels;
using System.Threading.Tasks;
public ObservableCollection<GroupItem> ImageList { get; set; }
/// <summary>
+ /// A dictionary list of the source and storage id
+ /// </summary>
+ private Dictionary<string, string> sourcePairList;
+
+ /// <summary>
/// An index of displaying image
/// </summary>
private int displayingImageIndex;
+ /// <summary>
+ /// A sort option
+ /// </summary>
private SortOption option = SortOption.Date;
/// <summary>
public ICommand ChangeSortOptionCommand { get; set; }
/// <summary>
+ /// A command for changing Source
+ /// </summary>
+ public ICommand ChangeSourceCommand { get; set; }
+
+ /// <summary>
/// A command for deleting a image content
/// </summary>
public ICommand DeleteContentCommand { get; set; }
/// </summary>
public ICommand SelectAllContentCommand { get; set; }
- private int SortBy;
/// <summary>
/// A flag that whether the content is delete mode or not
/// </summary>
}
/// <summary>
+ /// A flag that whether the BottomButtonList of Tab is needed to delete or not
+ /// </summary>
+ private bool isNeededClearList;
+
+ /// <summary>
+ /// Gets or sets the isNeededClearList
+ /// </summary>
+ public bool IsNeededClearList
+ {
+ get
+ {
+ return isNeededClearList;
+ }
+
+ set
+ {
+ if (isNeededClearList != value)
+ {
+ isNeededClearList = value;
+ OnPropertyChanged("IsNeededClearList");
+ }
+ }
+ }
+
+ /// <summary>
/// A command for executing when CurrentImageInfo is changed
/// </summary>
public ICommand SetCurrentImageInfo
/// </summary>
public ImageTabViewModel()
{
+ ImageList = new ObservableCollection<GroupItem>();
+ SelectedList = new List<MediaInformationEx>();
+ sourcePairList = new Dictionary<string, string>();
InitializeFooterItemsSource();
InitializeCommands();
CreateImageInfoList();
-
- ImageList = new ObservableCollection<GroupItem>();
- SelectedList = new List<MediaInformationEx>();
OnPropertyChanged("ImageList");
MediaHubImpl.GetInstance.ImageProviderInstance.SetContentUpdatedEventListener((sender, arg) =>
{
- DbgPort.D("Content updated");
- /*
- if (arg.UpdateType.Equals(MediaContentDBUpdateType.Update))
- {
- GetInformationsCommand?.Execute("");
- }
- */
+ AddSourceListItem();
});
}
}
});
+ ChangeSourceCommand = new Command<string>((name) =>
+ {
+ if (name == null)
+ {
+ DbgPort.D("name is null");
+ return;
+ }
+
+ string id = sourcePairList[name];
+ SynchronizationContext.Current.Post((o) =>
+ {
+ ReadImageList(option, id);
+ }, "");
+ });
+
SelectAllContentCommand = new Command<bool>((IsSelectedAll) =>
{
if (IsSelectedAll)
OnPropertyChanged("ChangeSortOptionCommand");
}
- private void GetImageData(int source, int sortby)
+ /// <summary>
+ /// A method for making the source list
+ /// </summary>
+ private void AddSourceListItem()
{
+ int index = 1;
+ sourcePairList.Clear();
+ List<string> tempList = new List<string>();
- }
+ sourcePairList.Add("ALL SOURCE", null);
+ sourcePairList.Add("DEVICE", "media");
- private void OnSourceChanged(int source)
- {
+ tempList.Add("ALL SOURCE");
+ tempList.Add("DEVICE");
- }
-
- void OnSortbyChanged(int sortby)
- {
- if (SortBy != sortby)
+ foreach (var item in MediaHubImpl.GetInstance.StorageProviderInstance.StorageId)
{
- SortBy = sortby;
+ sourcePairList.Add("USB " + index, item);
+ tempList.Add("USB " + index);
+ index++;
}
- }
+ SourceList = tempList;
+
+ OnPropertyChanged("SourceList");
+ }
/// <summary>
/// Finds specific Image in list and sets the DisplayingImageIndex
/// A method for reading image contents through ImageProvider and updating ImageList
/// </summary>
/// <param name="option">A current sort option</param>
- private async void ReadImageList(SortOption option)
+ private async void ReadImageList(SortOption option, string storageId = null)
{
ImageList.Clear();
- IEnumerable<GroupItem> tempList = await MediaHubImpl.GetInstance.ImageProviderInstance.ReadAsync(option);
+ IEnumerable<GroupItem> tempList = await MediaHubImpl.GetInstance.ImageProviderInstance.ReadAsync(option, storageId);
foreach (var group in tempList)
{
await MediaHubImpl.GetInstance.ImageProviderInstance.CheckThumbnail(group.Contents);
}
+
+ IsNeededClearList = true;
+
foreach (var group in tempList)
{
// TODO : remove delay
await Task.Delay(1);
ImageList.Add(group);
}
+
+ IsNeededClearList = false;
}
/// <summary>
/// </summary>
private void InitializeFooterItemsSource()
{
- var list = new List<string>
- {
- "ALL SOURCE",
- };
- SourceList = list;
- OnPropertyChanged("SourceList");
+ AddSourceListItem();
- list = new List<string>
+ var list = new List<string>
{
"EVENT",
"FILE FORMAT",
using System.IO;
using System.Threading;
using System.Windows.Input;
-using Tizen.Content.MediaContent;
using TVMediaHub.Tizen.Models;
using TVMediaHub.Tizen.Utils;
using TVMediaHub.Tizen.DataModels;
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
+ private Dictionary<string, string> sourcePairList;
+
/// <summary>
/// A method for invoking PropertyChanged event
/// </summary>
public ICommand ChangeSortOptionCommand { get; set; }
/// <summary>
+ /// A command for changing Source
+ /// </summary>
+ public ICommand ChangeSourceCommand { get; set; }
+
+ /// <summary>
/// A command for getting the list of video contents
/// </summary>
public ICommand GetInformationsCommand { get; set; }
get;
}
+ /// <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>
}
/// <summary>
+ /// A flag that whether the BottomButtonList of Tab is needed to delete or not
+ /// </summary>
+ private bool isNeededClearList;
+
+ /// <summary>
+ /// Gets or sets the isNeededClearList
+ /// </summary>
+ public bool IsNeededClearList
+ {
+ get
+ {
+ return isNeededClearList;
+ }
+
+ set
+ {
+ if (isNeededClearList != value)
+ {
+ isNeededClearList = value;
+ OnPropertyChanged("IsNeededClearList");
+ }
+ }
+ }
+
+ /// <summary>
/// A list of video contents to be displayed
/// </summary>
public List<MediaInformationEx> SelectedList { get; set; }
public VideoTabViewModel()
{
DbgPort.D("Binding Context cotr " + DateTime.Now);
- InitializeFooterItemsSource();
- InitializeCommands();
VideoList = new ObservableCollection<GroupItem>();
SelectedList = new List<MediaInformationEx>();
PlayList = new List<MediaInformationEx>();
-
+ sourcePairList = new Dictionary<string, string>();
+ InitializeFooterItemsSource();
+ InitializeCommands();
OnPropertyChanged("VideoList");
MediaHubImpl.GetInstance.VideoProviderInstance.SetContentUpdatedEventListener((sender, arg) =>
{
- DbgPort.D("Content updated");
- /*
- if (arg.UpdateType.Equals(MediaContentDBUpdateType.Update))
- {
- GetInformationsCommand?.Execute("");
- }
- */
+ AddSourceListItem();
});
}
ReadVideoList(option);
}, "");
});
+ ChangeSourceCommand = new Command<string>((name) =>
+ {
+ if (name == null)
+ {
+ DbgPort.D("name is null");
+ return;
+ }
+ string id = sourcePairList[name];
+ SynchronizationContext.Current.Post((o) =>
+ {
+ ReadVideoList(option, id);
+ }, "");
+ });
SetCurrentVideoInfo = new Command<MediaInformationEx>((info) =>
{
if (IsDeleteStatus)
/// </summary>
private void InitializeFooterItemsSource()
{
- var list = new List<string>
- {
- "ALL SOURCE",
- };
- SourceList = list;
- OnPropertyChanged("SourceList");
+ AddSourceListItem();
- list = new List<string>
+ var list = new List<string>
{
"NAME",
"GENRE",
OnPropertyChanged("OptionList");
}
+ /// <summary>
+ /// A method for making the source list
+ /// </summary>
+ private void AddSourceListItem()
+ {
+ int index = 1;
+ sourcePairList.Clear();
+ List<string> tempList = new List<string>();
+
+ sourcePairList.Add("ALL SOURCE", null);
+ sourcePairList.Add("DEVICE", "media");
+
+ tempList.Add("ALL SOURCE");
+ tempList.Add("DEVICE");
+
+ foreach (var item in MediaHubImpl.GetInstance.StorageProviderInstance.StorageId)
+ {
+ sourcePairList.Add("USB " + index, item);
+ tempList.Add("USB " + index);
+ index++;
+ }
+
+ SourceList = tempList;
+
+ OnPropertyChanged("SourceList");
+ }
+
private void ReadRecentlyWatchedContent()
{
// TODO : Read from VideoProvider
/// A method for reading video contents through VideoProvider and updating VideoList
/// </summary>
/// <param name="option">A current sort option</param>
- private async void ReadVideoList(SortOption option)
+ private async void ReadVideoList(SortOption option, string storageId = null)
{
VideoList.Clear();
- IEnumerable<GroupItem> tempList = await MediaHubImpl.GetInstance.VideoProviderInstance.ReadAsync(option);
+
+ IEnumerable<GroupItem> tempList = await MediaHubImpl.GetInstance.VideoProviderInstance.ReadAsync(option, storageId);
foreach (var group in tempList)
{
await MediaHubImpl.GetInstance.VideoProviderInstance.CheckThumbnail(group.Contents);
}
+ IsNeededClearList = true;
+
foreach (var group in tempList)
{
//await Task.Delay(1);
VideoList.Add(group);
}
+ IsNeededClearList = false;
+
foreach (var group in VideoList)
{
foreach (var item in group.Contents)
};
view.OnUnfocusedEventHandler += (se, ev) =>
{
- if (focusedItem.Equals(view as ImageItem))
+ if (focusedItem != null && focusedItem.Equals(view as ImageItem))
{
focusedItem = null;
}
IsDeleteStatus="{Binding IsDeleteStatus}"
GetInformationsCommand="{Binding GetInformationsCommand}"
ChangeSortOptionCommand="{Binding ChangeSortOptionCommand}"
+ ChangeSourceCommand="{Binding ChangeSourceCommand}"
DeleteModeChangeCommand="{Binding DeleteModeChangeCommand}"
OnClickCommand="{Binding SetCurrentImageInfo}"
DeleteContentCommand="{Binding DeleteContentCommand}"
SelectAllContentCommand="{Binding SelectAllContentCommand}"
SelectedCount="{Binding SelectedCount}"
+ IsNeededClearList="{Binding IsNeededClearList}"
Title="Gallery">
<RelativeLayout
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
using System.Collections.ObjectModel;
using System.Threading;
using System.Windows.Input;
-using Tizen.Content.MediaContent;
using Tizen.Xamarin.Forms.Extension;
using TVMediaHub.Tizen.Controls;
using TVMediaHub.Tizen.DataModels;
}
/// <summary>
+ /// Identifies the ChangeSourceCommand bindable property
+ /// </summary>
+ public static readonly BindableProperty ChangeSourceCommandProperty = BindableProperty.Create("ChangeSourceCommand", typeof(ICommand), typeof(ImageTab), default(ICommand));
+
+ /// <summary>
+ /// Gets or sets ChangeSourceCommand Command
+ /// </summary>
+ public ICommand ChangeSourceCommand
+ {
+ get { return (ICommand)GetValue(ChangeSourceCommandProperty); }
+ set { SetValue(ChangeSourceCommandProperty, value); }
+ }
+
+ /// <summary>
/// Identifies the DeleteModeChangeCommand bindable property
/// </summary>
public static readonly BindableProperty DeleteModeChangeCommandProperty = BindableProperty.Create("DeleteModeChangeCommand", typeof(ICommand), typeof(ImageTab), default(ICommand));
}
/// <summary>
+ /// Identifies the IsNeededClearList bindable property
+ /// </summary>
+ public static readonly BindableProperty IsNeededClearListProperty = BindableProperty.Create("IsNeededClearList", typeof(bool), typeof(ImageTab), false);
+
+ /// <summary>
+ /// Gets or sets IsNeededClearList
+ /// </summary>
+ public bool IsNeededClearList
+ {
+ get { return (bool)GetValue(IsNeededClearListProperty); }
+ set { SetValue(IsNeededClearListProperty, value); }
+ }
+
+ /// <summary>
/// A list of bottom buttons
/// </summary>
private List<KeyValuePair<double, Button>> BottomButtonList;
InitializeFonts();
InitializeFooter();
ItemsSource.CollectionChanged += ItemsSourceCollectionChanged;
-
+ PropertyChanged += ImageTabPropertyChanged;
SynchronizationContext.Current.Post((o) =>
{
}
/// <summary>
+ /// This method is called when the properties is changed
+ /// </summary>
+ /// <param name="sender">The source of the event</param>
+ /// <param name="e">A propertyChanged event argument</param>
+ private void ImageTabPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
+ {
+ if (e.PropertyName.Equals("IsNeededClearList"))
+ {
+ if (IsNeededClearList)
+ {
+ BottomButtonList.Clear();
+ }
+ }
+ }
+
+ /// <summary>
/// A method for initializing list
/// </summary>
private void InitializeData()
/// </summary>
private void InitializeFooter()
{
-
FooterNormal.OnDropdownSourceItemSelected += OnSourceChanged;
-
FooterNormal.OnDropdownSortItemSelected += OnSortOptionChanged;
-
FooterNormal.OnSelectedOptionIndexChanged += OnOptionSelected;
FooterDelete.SelecteAllButtonEvent += OnSelectAllClicked;
/// <param name="e">A SelectedItemChanged event's argument</param>
private void OnSourceChanged(object sender, SelectedItemChangedEventArgs e)
{
+ String storageName = e.SelectedItem as String;
+
+ BottomButtonList.Clear();
+ ChangeSourceCommand?.Execute(storageName);
+ SetFooterFocusChain(ImageTabScrollView.ScrollX);
}
/// <summary>
/// <param name="e">A SelectedItemChanged event's argument</param>
private void OnSortOptionChanged(object sender, SelectedItemChangedEventArgs e)
{
+ BottomButtonList.Clear();
ChangeSortOptionCommand?.Execute(e.SelectedItem);
+ SetFooterFocusChain(ImageTabScrollView.ScrollX);
}
/// <summary>
};
view.OnUnfocusedEventHandler += (se, ev) =>
{
- if(focusedItem.Equals(view as VideoItem))
+ if (focusedItem != null && focusedItem.Equals(view as VideoItem))
{
focusedItem = null;
}
IsDeleteStatus="{Binding IsDeleteStatus}"
ChangeTabStatusCommand="{Binding ChangeTabStatusCommand}"
ChangeSortOptionCommand="{Binding ChangeSortOptionCommand}"
+ ChangeSourceCommand="{Binding ChangeSourceCommand}"
GetInformationsCommand="{Binding GetInformationsCommand}"
OnClickCommand="{Binding SetCurrentVideoInfo}"
DeleteContentCommand="{Binding DeleteContentCommand}"
SelectAllContentCommand="{Binding SelectAllContentCommand}"
- SelectedCount="{Binding SelectedCount}">
+ SelectedCount="{Binding SelectedCount}"
+ IsNeededClearList="{Binding IsNeededClearList}">
<RelativeLayout
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}">
}
/// <summary>
+ /// Identifies the IsNeededClearList bindable property
+ /// </summary>
+ public static readonly BindableProperty IsNeededClearListProperty = BindableProperty.Create("IsNeededClearList", typeof(bool), typeof(ImageTab), false);
+
+ /// <summary>
+ /// Gets or sets IsNeededClearList
+ /// </summary>
+ public bool IsNeededClearList
+ {
+ get { return (bool)GetValue(IsNeededClearListProperty); }
+ set { SetValue(IsNeededClearListProperty, value); }
+ }
+
+ /// <summary>
/// Identifies the ChangeTabStatusCommand bindable property
/// </summary>
public static readonly BindableProperty ChangeTabStatusCommandProperty = BindableProperty.Create("ChangeTabStatusCommand", typeof(ICommand), typeof(VideoTab), default(ICommand));
public static readonly BindableProperty ChangeSortOptionCommandProperty = BindableProperty.Create("ChangeSortOptionCommand", typeof(ICommand), typeof(VideoTab), default(ICommand));
/// <summary>
- /// Gets or sets ChangeTabStatus Command
+ /// Gets or sets ChangeSortOption Command
/// </summary>
public ICommand ChangeSortOptionCommand
{
}
/// <summary>
+ /// Identifies the ChangeSourceCommand bindable property
+ /// </summary>
+ public static readonly BindableProperty ChangeSourceCommandProperty = BindableProperty.Create("ChangeSourceCommand", typeof(ICommand), typeof(VideoTab), default(ICommand));
+
+ /// <summary>
+ /// Gets or sets ChangeSourceCommand Command
+ /// </summary>
+ public ICommand ChangeSourceCommand
+ {
+ get { return (ICommand)GetValue(ChangeSourceCommandProperty); }
+ set { SetValue(ChangeSourceCommandProperty, value); }
+ }
+
+ /// <summary>
/// Identifies the DeleteContentCommand bindable property
/// </summary>
public static readonly BindableProperty DeleteContentCommandProperty = BindableProperty.Create("DeleteContentCommand", typeof(ICommand), typeof(VideoTab), default(ICommand));
InitializeFonts();
InitializeFooter();
ItemsSource.CollectionChanged += ItemsSourceCollectionChanged;
+ PropertyChanged += VideoTabPropertyChanged;
+ }
+
+ /// <summary>
+ /// This method is called when the properties is changed
+ /// </summary>
+ /// <param name="sender">The source of the event</param>
+ /// <param name="e">A propertyChanged event argument</param>
+ private void VideoTabPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
+ {
+ if (e.PropertyName.Equals("IsNeededClearList"))
+ {
+ if (IsNeededClearList)
+ {
+ BottomButtonList.Clear();
+ }
+ }
}
/// <summary>
private void InitializeFooter()
{
FooterNormal.OnDropdownSourceItemSelected += OnSourceChanged;
-
FooterNormal.OnDropdownSortItemSelected += OnSortOptionChanged;
-
FooterNormal.OnSelectedOptionIndexChanged += OnOptionSelected;
FooterDelete.SelecteAllButtonEvent += OnSelectAllClicked;
}
else if (e.Action.ToString().Equals("Reset"))
{
- BottomButtonList.Clear();
VideoTabList.Children.Clear();
VideoGroupList.Clear();
if (!VideoNoContents.IsVisible)
/// <param name="e">A SelectedItemChanged event's argument</param>
private void OnSourceChanged(object sender, SelectedItemChangedEventArgs e)
{
- // TODO : Source Change
+ String storageName = e.SelectedItem as String;
+
+ ChangeSourceCommand?.Execute(storageName);
+ SetFooterFocusChain(VideoTabScrollView.ScrollX);
}
/// <summary>
private void OnSortOptionChanged(object sender, SelectedItemChangedEventArgs e)
{
ChangeSortOptionCommand?.Execute(e.SelectedItem);
+ SetFooterFocusChain(VideoTabScrollView.ScrollX);
}
/// <summary>