The "exit" popup has not to be displayed if the DropDownSort is expanded.
The BackKey event is handled from the MediaHubMainPage,
and the DropDownSort is implemented in the FooterNormalStatus.
I added a flag named "DisableBackKeyHandler" to the MediaHubMainPage to control the BackKey event handler.
and the "DisableBackKeyHandler" is toggled by the FooterNormalStatus instance.
The FooterNormalStatus instance was able to access the MediaHubMainPage via the AppMainPage object of the App instance,
so I added event handlers such as the collased and the expanded for the DropDownSort instance.
When DropDownSort is expanded, I set true to the "DisableBackKeyHandler" then the BackKey would blocked.
I also added KeyDown event handler in the FooterNormalStatus instance.
In the event handler, if the DropDownSort is expanded, I collased it.
The KeyDown event handler is added and removed from the Expanded and Collapsed event handler of the DropDownSort instance.
Change-Id: I106d53569471a66c6ff867d92c3d012d3b34f80b
Signed-off-by: Sung-jae Park <nicesj@nicesj.com>
/// </summary>
public string SourceName { get; set; }
+ private bool disableBackKeyHandler;
+
+ public bool DisableBackKeyHandler
+ {
+ set
+ {
+ disableBackKeyHandler = value;
+ OnPropertyChanged();
+ }
+ get => disableBackKeyHandler;
+ }
+
/// <summary>
/// An event that is occurred when property of MediaHubMainPageViewModel is changed
/// </summary>
}
}
+ private void KeyDownHandler(object sender, EventArgs e)
+ {
+ ElmSharp.EcoreKeyEventArgs arg = e as ElmSharp.EcoreKeyEventArgs;
+
+ if (arg != null && arg.KeyName.Contains("Back"))
+ {
+ if (DropdownSort.IsExpanded == true)
+ {
+ DropdownSort.Collapse();
+ }
+ }
+ }
+
/// <summary>
/// A method for initializing footer items
/// </summary>
DropdownSource.ItemsSource = SourceList;
DropdownSort.ItemsSource = SortOptions;
+ DropdownSort.Collapsed += (s, e) =>
+ {
+ if (App.AppMainPage != null && App.AppMainPage.RootPage != null)
+ {
+ (App.AppMainPage.RootPage as MediaHubMainPage).DisableBackKeyHandler = false;
+
+ App.KeyDownEvent.On -= KeyDownHandler;
+ }
+ };
+
+ DropdownSort.Expanded += (s, e) =>
+ {
+ if (App.AppMainPage != null && App.AppMainPage.RootPage != null)
+ {
+ (App.AppMainPage.RootPage as MediaHubMainPage).DisableBackKeyHandler = true;
+
+ App.KeyDownEvent.On += KeyDownHandler;
+ }
+ };
+
DropdownSource.ItemSelected += (s, e) =>
{
OnDropdownSourceItemSelected?.Invoke(s, e);
x:Class="TVMediaHub.Tizen.Views.MediaHubMainPage"
xmlns:Views="clr-namespace:TVMediaHub.Tizen.Views"
Title="MEDIA HUB"
- SourceName="{Binding SourceName}">
+ SourceName="{Binding SourceName}"
+ DisableBackKeyHandler="{Binding DisableBackKeyHandler}">
<Views:VideoTab/>
<Views:ImageTab/>
<Views:MusicTab/>
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MediaHubMainPage : TabbedPage
{
+ public static readonly BindableProperty DisableBackKeyHandlerProperty = BindableProperty.Create("DisableBackKeyHandler", typeof(bool), typeof(MediaHubMainPage), false, BindingMode.OneWayToSource);
+ public bool DisableBackKeyHandler
+ {
+ get { return (bool)GetValue(DisableBackKeyHandlerProperty); }
+ set { SetValue(DisableBackKeyHandlerProperty, value); }
+ }
+
/// <summary>
/// Identifies the SourceName bindable property
/// </summary>
/// <returns>Always returns true</returns>
protected override bool OnBackButtonPressed()
{
+ if (DisableBackKeyHandler == true)
+ {
+ return true;
+ }
+
SynchronizationContext.Current.Post((o) =>
{
#pragma warning disable CS4014