The async method should run its code in a task. 61/148161/1
authorSung-jae Park <nicesj@nicesj.com>
Thu, 7 Sep 2017 04:06:42 +0000 (13:06 +0900)
committerSung-jae Park <nicesj@nicesj.com>
Thu, 7 Sep 2017 04:06:42 +0000 (13:06 +0900)
The task will run in the different thread.

Change-Id: I70b3b50ddac0c01fc160edaada313c38efcab7e0
Signed-off-by: Sung-jae Park <nicesj@nicesj.com>
TVMediaHub.sln
TVMediaHub/TVMediaHub.Tizen/Models/ContentProvider.cs
TVMediaHub/TVMediaHub.Tizen/TVMediaHub.Tizen.csproj
TVMediaHub/TVMediaHub.Tizen/Views/ImageGroup.xaml
TVMediaHub/TVMediaHub.Tizen/Views/ImageTab.xaml.cs
TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml.cs

index 73d10f9..a0fb3a0 100644 (file)
@@ -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
index 261ce93..692ec9a 100755 (executable)
@@ -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>
index 2352403..20e3491 100755 (executable)
@@ -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 -->
   <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>
index 1577bfc..cbf5ac5 100644 (file)
@@ -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}"/>
 
index 59e0525..e5548ed 100755 (executable)
@@ -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++)
             {
index 9a23ce0..d76667a 100755 (executable)
@@ -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>