}
}
});
- DeleteContentCommand = new Command(() =>
+ DeleteContentCommand = new Command<MediaInformation>((SelectedItem) =>
{
+ if (!SelectedItem.Equals(""))
+ {
+ SelectedList.Clear();
+ SelectedList.Add(SelectedItem);
+ }
foreach (var info in SelectedList)
{
try
using TVMediaHub.Tizen.Utils;
using Xamarin.Forms;
using Xamarin.Forms.PlatformConfiguration.TizenSpecific;
+using Tizen.Content.MediaContent;
namespace TVMediaHub.Tizen.Views
{
/// </summary>
private ICommand ItemClickCommand;
+ public delegate void ItemDeleteHandler(MediaInformation info);
+
+ public ItemDeleteHandler OnItemDeleteHandler;
/// <summary>
/// Gets or sets source of list items
/// </summary>
/// </summary>
public List<KeyValuePair<double, Button>> BottomFocusList { get; protected set; }
+ private VideoItem focusedItem;
+
+
/// <summary>
/// A list of video items
/// </summary>
{
GroupItemFocused?.Invoke(view, new GroupItemFocusEventArgs(X + view.X));
GroupContentArea.RaiseChild(view);
+ focusedItem = view;
+ };
+ view.OnUnfocusedEventHandler += (se, ev) =>
+ {
+ if(focusedItem.Equals(view as VideoItem))
+ {
+ focusedItem = null;
+ }
};
view.OnItemClickedHandler += (info) =>
{
ItemClickCommand?.Execute(info);
};
+ view.DeleteItemHandler += (info) =>
+ {
+ OnItemDeleteHandler?.Invoke(info);
+ };
GroupContentArea.Children.Add(view, index / 3, index % 3);
index++;
{
ItemClickCommand = command;
}
+
+ /// <summary>
+ /// If there is focused video item, notify the menu key pressed event to focused video item for show context popup
+ /// </summary>
+ /// <returns>If group has a focused video item, true; otherwise, false</returns>
+ public bool NotifyMenuKeyPressedToFocusedItem()
+ {
+ if(focusedItem != null)
+ {
+ focusedItem.ShowContextPopup();
+ return true;
+ }
+ return false;
+ }
}
}
using System;
using System.ComponentModel;
using Tizen.Content.MediaContent;
+using Tizen.Xamarin.Forms.Extension;
using TVMediaHub.Tizen.Utils;
using Xamarin.Forms;
/// A delegate will be executed when the item is clicked
/// </summary>
/// <param name="info">A clicked item's MediaInformation</param>
- public delegate void ClickEventHandler(MediaInformation info);
+ public delegate void ItemEventHandler(MediaInformation info);
/// <summary>
/// A ClickEventHandler for click event of the item
/// </summary>
- public ClickEventHandler OnItemClickedHandler;
+ public ItemEventHandler OnItemClickedHandler;
+
+ public ItemEventHandler DeleteItemHandler;
/// <summary>
/// Identifies the IsDeleteMode bindable property
/// <param name="e">A Focus event's argument</param>
public void OnUnfocused(object sender, FocusEventArgs e)
{
+ OnUnfocusedEventHandler?.Invoke(sender, e);
Easing easing = new Easing(EasingFunction.EasyIn2);
this.AbortAnimation("TextSliding");
this.AbortAnimation("FocusAnimation");
}
}
}
+
+ public void ShowContextPopup()
+ {
+ if (!FocusArea.IsFocused)
+ {
+ return;
+ }
+
+ ContextPopup popup = new ContextPopup();
+ popup.Items.Add(new ContextPopupItem("FILE INFO"));
+ popup.Items.Add(new ContextPopupItem("DELETE"));
+ popup.SelectedIndexChanged += selectedIndexChanged;
+ popup.Show(this, this.Width/2, this.Height + SizeUtils.GetHeightSize(72));
+
+ }
+
+ private void selectedIndexChanged(object sender, EventArgs e)
+ {
+ var ctxPopup = sender as ContextPopup;
+ switch (ctxPopup.SelectedIndex)
+ {
+ case 0:
+ DbgPort.D("File info selected");
+ break;
+ case 1:
+ DeleteItemHandler?.Invoke(VideoInfo);
+ break;
+ }
+ ctxPopup.Dismiss();
+ }
}
}
using TVMediaHub.Tizen.ViewModels;
using Xamarin.Forms;
using Xamarin.Forms.PlatformConfiguration.TizenSpecific;
+using Tizen.Content.MediaContent;
namespace TVMediaHub.Tizen.Views
{
var GroupItem = e.NewItems[0];
groupView.BindingContext = GroupItem;
groupView.SetClickCommand(OnClickCommand);
+ groupView.OnItemDeleteHandler += (info) =>
+ {
+ ShowDeletePopup(info);
+ };
+
VideoTabList.Children.Add(groupView);
VideoGroupList.Add(groupView);
VideoTabList.TranslateTo(0, h0, 667);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
}
+
+ protected override void OnAppearing()
+ {
+ base.OnAppearing();
+ // add Listener
+ App.MainWindow.KeyGrab(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName, false);
+ App.MainWindow.KeyUp += MenuKeyListener;
+ }
+
+ protected override void OnDisappearing()
+ {
+ base.OnDisappearing();
+ // remove listener
+ App.MainWindow.KeyUp -= MenuKeyListener;
+ App.MainWindow.KeyUngrab(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName);
+ }
+ private void MenuKeyListener(object sender, ElmSharp.EvasKeyEventArgs e)
+ {
+ if (e.KeyName.Equals(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName))
+ {
+ NotifyMenuKeyPressed();
+ }
+ }
+
+ private void NotifyMenuKeyPressed()
+ {
+ if (VideoTabList.Children.Count > 0)
+ {
+ foreach(VideoGroup group in VideoTabList.Children)
+ {
+ if (group.NotifyMenuKeyPressedToFocusedItem())
+ {
+ break;
+ }
+ }
+
+ }
+ }
+
+
+ private async void ShowDeletePopup(MediaInformation item)
+ {
+ bool answer = await DisplayAlert("Delete", "Delete '" + item.Title + "'?", "Yes", "No");
+ if (answer)
+ {
+ DeleteContentCommand?.Execute(item);
+ }
+
+ }
}
}