diff options
author | Sung-jae Park <nicesj@nicesj.com> | 2017-09-07 13:06:42 +0900 |
---|---|---|
committer | Sung-jae Park <nicesj@nicesj.com> | 2017-09-07 13:06:42 +0900 |
commit | 8ad997d013a0444f5f70c754a7537bbe31e61145 (patch) | |
tree | 8377942624c39ea5fe75a1fe8b35499cbc4c524a | |
parent | f4366e392d9f7e56f80f44c68054b32d19634fc3 (diff) | |
download | mediahub-8ad997d013a0444f5f70c754a7537bbe31e61145.tar.gz mediahub-8ad997d013a0444f5f70c754a7537bbe31e61145.tar.bz2 mediahub-8ad997d013a0444f5f70c754a7537bbe31e61145.zip |
The async method should run its code in a task.
The task will run in the different thread.
Change-Id: I70b3b50ddac0c01fc160edaada313c38efcab7e0
Signed-off-by: Sung-jae Park <nicesj@nicesj.com>
-rw-r--r-- | TVMediaHub.sln | 8 | ||||
-rwxr-xr-x | TVMediaHub/TVMediaHub.Tizen/Models/ContentProvider.cs | 65 | ||||
-rwxr-xr-x | TVMediaHub/TVMediaHub.Tizen/TVMediaHub.Tizen.csproj | 8 | ||||
-rw-r--r-- | TVMediaHub/TVMediaHub.Tizen/Views/ImageGroup.xaml | 2 | ||||
-rwxr-xr-x | TVMediaHub/TVMediaHub.Tizen/Views/ImageTab.xaml.cs | 23 | ||||
-rwxr-xr-x | TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml.cs | 4 |
6 files changed, 65 insertions, 45 deletions
diff --git a/TVMediaHub.sln b/TVMediaHub.sln index 73d10f9..a0fb3a0 100644 --- a/TVMediaHub.sln +++ b/TVMediaHub.sln @@ -3,18 +3,24 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26730.12 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TVMediaHub.Tizen", "TVMediaHub\TVMediaHub.Tizen\TVMediaHub.Tizen.csproj", "{2C968D00-4043-4202-9060-36C831AE6784}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TVMediaHub.Tizen", "TVMediaHub\TVMediaHub.Tizen\TVMediaHub.Tizen.csproj", "{2C968D00-4043-4202-9060-36C831AE6784}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {2C968D00-4043-4202-9060-36C831AE6784}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2C968D00-4043-4202-9060-36C831AE6784}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2C968D00-4043-4202-9060-36C831AE6784}.Debug|x86.ActiveCfg = Debug|x86 + {2C968D00-4043-4202-9060-36C831AE6784}.Debug|x86.Build.0 = Debug|x86 {2C968D00-4043-4202-9060-36C831AE6784}.Release|Any CPU.ActiveCfg = Release|Any CPU {2C968D00-4043-4202-9060-36C831AE6784}.Release|Any CPU.Build.0 = Release|Any CPU + {2C968D00-4043-4202-9060-36C831AE6784}.Release|x86.ActiveCfg = Release|x86 + {2C968D00-4043-4202-9060-36C831AE6784}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/TVMediaHub/TVMediaHub.Tizen/Models/ContentProvider.cs b/TVMediaHub/TVMediaHub.Tizen/Models/ContentProvider.cs index 261ce93..692ec9a 100755 --- a/TVMediaHub/TVMediaHub.Tizen/Models/ContentProvider.cs +++ b/TVMediaHub/TVMediaHub.Tizen/Models/ContentProvider.cs @@ -198,49 +198,50 @@ namespace TVMediaHub.Tizen.Models /// <param name="mediaInformationExList">A list of MediaInformationEx</param> /// <param name="sortOption">The current sort option</param> /// <returns>A list of group item</returns> -#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously private async Task<IEnumerable<GroupItem>> MakeGroupAsync(IEnumerable<MediaInformationEx> mediaInformationExList, SortOption sortOption) -#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously { - DbgPort.D("MG Async"); - List<GroupItem> result = new List<GroupItem>(); - GroupItem lastGroupItem = null; - GroupItem currentGroupItem = null; - - if (mediaInformationExList == null) - { - throw new System.ArgumentException("mediaInformationExList must not be null."); - } - - foreach (MediaInformationEx mediaInformationEx in mediaInformationExList) + return await Task.Run(() => { - var currentInformation = mediaInformationEx; - var shortcutInfo = new MediaShortcutInfo(currentInformation); + DbgPort.D("MG Async"); + List<GroupItem> result = new List<GroupItem>(); + GroupItem lastGroupItem = null; + GroupItem currentGroupItem = null; - // TODO : The catch implementation should be checked once again. - try + if (mediaInformationExList == null) { - currentGroupItem = GetGroupItem(sortOption, currentGroupItem, mediaInformationEx); - } - catch (Exception e) - { - DbgPort.E(e.Message); - return null; + throw new System.ArgumentException("mediaInformationExList must not be null."); } - if (lastGroupItem != currentGroupItem) + foreach (MediaInformationEx mediaInformationEx in mediaInformationExList) { - result.Add(currentGroupItem); - lastGroupItem = currentGroupItem; - } + var currentInformation = mediaInformationEx; + var shortcutInfo = new MediaShortcutInfo(currentInformation); - if (currentGroupItem != null) - { - currentGroupItem.Contents.Add(shortcutInfo); + // TODO : The catch implementation should be checked once again. + try + { + currentGroupItem = GetGroupItem(sortOption, currentGroupItem, mediaInformationEx); + } + catch (Exception e) + { + DbgPort.E(e.Message); + return null; + } + + if (lastGroupItem != currentGroupItem) + { + result.Add(currentGroupItem); + lastGroupItem = currentGroupItem; + } + + if (currentGroupItem != null) + { + currentGroupItem.Contents.Add(shortcutInfo); + } } - } - return result; + return result; + }); } /// <summary> diff --git a/TVMediaHub/TVMediaHub.Tizen/TVMediaHub.Tizen.csproj b/TVMediaHub/TVMediaHub.Tizen/TVMediaHub.Tizen.csproj index 2352403..20e3491 100755 --- a/TVMediaHub/TVMediaHub.Tizen/TVMediaHub.Tizen.csproj +++ b/TVMediaHub/TVMediaHub.Tizen/TVMediaHub.Tizen.csproj @@ -3,6 +3,7 @@ <!-- Setting Tizen Extension Path --> <PropertyGroup Label="Globals"> <TizenProjectExtensionsPath>$(MSBuildExtensionsPath)\Tizen\VisualStudio\</TizenProjectExtensionsPath> + <Platforms>AnyCPU;x86</Platforms> </PropertyGroup> <!-- Import Tizen property in Tizen.NET SDK --> @@ -23,9 +24,16 @@ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugType>portable</DebugType> </PropertyGroup> + + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'"> + <DebugType>portable</DebugType> + </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>None</DebugType> </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'"> + <DebugType>None</DebugType> + </PropertyGroup> <PropertyGroup> <NoWarn>$(NoWarn);NU1605</NoWarn> diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/ImageGroup.xaml b/TVMediaHub/TVMediaHub.Tizen/Views/ImageGroup.xaml index 1577bfc..cbf5ac5 100644 --- a/TVMediaHub/TVMediaHub.Tizen/Views/ImageGroup.xaml +++ b/TVMediaHub/TVMediaHub.Tizen/Views/ImageGroup.xaml @@ -2,7 +2,7 @@ <RelativeLayout xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="TVMediaHub.Tizen.Views.ImageGroup" - ItemsSource="{Binding Contents}"> + ItemsSource="{Binding Contents}"> <Button x:Name="TitleFocusArea" Opacity ="0" RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.085}"/> diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/ImageTab.xaml.cs b/TVMediaHub/TVMediaHub.Tizen/Views/ImageTab.xaml.cs index 59e0525..e5548ed 100755 --- a/TVMediaHub/TVMediaHub.Tizen/Views/ImageTab.xaml.cs +++ b/TVMediaHub/TVMediaHub.Tizen/Views/ImageTab.xaml.cs @@ -351,13 +351,18 @@ namespace TVMediaHub.Tizen.Views { if (ev.PropertyName.Equals("X")) { - galleryGroup.BottomFocusList.ForEach((item) => + Console.WriteLine("Group X: {0} {1}", galleryGroup.X, galleryGroup); + + if (galleryGroup.X > 0) { - var key = galleryGroup.X + item.Key; - BottomButtonList.Add(new KeyValuePair<double, Button>(key, item.Value)); - }); + galleryGroup.BottomFocusList.ForEach((item) => + { + var key = galleryGroup.X + item.Key; + BottomButtonList.Add(new KeyValuePair<double, Button>(key, item.Value)); + }); - SetFooterFocusChain(0); + SetFooterFocusChain(0); + } } }; @@ -439,10 +444,10 @@ namespace TVMediaHub.Tizen.Views var FocusableBoundFrom = scrollX; var FocusableBoundTo = scrollX + SizeUtils.BaseScreenWidth - ItemWidth; - var list = BottomButtonList.FindAll((pair) => - { - return (pair.Key >= FocusableBoundFrom && pair.Key <= FocusableBoundTo); - }); + var list = BottomButtonList.FindAll((pair) => (pair.Key >= FocusableBoundFrom && pair.Key <= FocusableBoundTo)); + + string what = "The number of filtered objects is " + list?.Count + "(" + FocusableBoundFrom + ")" + "(" + FocusableBoundTo + ")"; + Console.WriteLine(what); for (var buttonIndex = 0; buttonIndex < list.Count; buttonIndex++) { diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml.cs b/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml.cs index 9a23ce0..d76667a 100755 --- a/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml.cs +++ b/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml.cs @@ -380,9 +380,9 @@ namespace TVMediaHub.Tizen.Views { string storageName = e.SelectedItem as string; - //BottomButtonList.Clear(); + // BottomButtonList.Clear(); ChangeSourceCommand?.Execute(storageName); - //SetFooterFocusChain(ImageTabScrollView.ScrollX); + // FocusChain(ImageTabScrollView.ScrollX); } /// <summary> |