diff options
author | Sung-jae Park <nicesj@nicesj.com> | 2017-09-11 04:57:48 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@review.ap-northeast-2.compute.internal> | 2017-09-11 04:57:48 +0000 |
commit | c19d865a3c356e2f445bc659e33692c44c981bb0 (patch) | |
tree | 91d66a8a332b137d603c362087ac9f2988b99b2c | |
parent | 0708eb630654eb8e30a305c9275cc9ecbe98df76 (diff) | |
parent | b09929ea4b3627cccf59f8a80e8e7946ce88e4fe (diff) | |
download | mediahub-c19d865a3c356e2f445bc659e33692c44c981bb0.tar.gz mediahub-c19d865a3c356e2f445bc659e33692c44c981bb0.tar.bz2 mediahub-c19d865a3c356e2f445bc659e33692c44c981bb0.zip |
Merge "The async method should run its code in a task." into tizen
-rwxr-xr-x | TVMediaHub/TVMediaHub.Tizen/Models/ContentProvider.cs | 130 |
1 files changed, 66 insertions, 64 deletions
diff --git a/TVMediaHub/TVMediaHub.Tizen/Models/ContentProvider.cs b/TVMediaHub/TVMediaHub.Tizen/Models/ContentProvider.cs index 4072c37..328323c 100755 --- a/TVMediaHub/TVMediaHub.Tizen/Models/ContentProvider.cs +++ b/TVMediaHub/TVMediaHub.Tizen/Models/ContentProvider.cs @@ -310,9 +310,11 @@ namespace TVMediaHub.Tizen.Models foreach (MediaInfo mediaInformation in mediaInformationList) { - var mediaInformationEx = new MediaInformationEx(); + var mediaInformationEx = new MediaInformationEx + { + MediaContentInformation = mediaInformation + }; - mediaInformationEx.MediaContentInformation = mediaInformation; CheckUnavailableContent(mediaInformationEx); mediaInformationExList.Add(mediaInformationEx); } @@ -356,83 +358,83 @@ namespace TVMediaHub.Tizen.Models /// <param name="offset">The start position of the given filter Starting from zero</param> /// <param name="count">The number of items to be searched with respect to the offset</param> /// <returns>A list of media informations</returns> -#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously public async Task<IEnumerable<MediaInformationEx>> ReadWithoutGroupAsync(SortOption sortOption, string storageId = null, int offset = -1, int count = -1) -#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously { - // Makes Content Filter by arguments - var selectArguments = new SelectArguments(); + return await Task.Run(() => { + // Makes Content Filter by arguments + var selectArguments = new SelectArguments(); - switch (sortOption) - { - case SortOption.Title: - selectArguments.SortOrder = "MEDIA_DISPLAY_NAME"; - break; - case SortOption.Date: - selectArguments.SortOrder = "MEDIA_RECORDED_DATE"; - break; - case SortOption.Genre: - selectArguments.SortOrder = "MEDIA_GENRE"; - break; - case SortOption.Type: - selectArguments.SortOrder = "MEDIA_TYPE"; - break; - case SortOption.Album: - selectArguments.SortOrder = "MEDIA_ALBUM"; - break; - case SortOption.Artist: - selectArguments.SortOrder = "MEDIA_ARTIST"; - break; - default: - throw new System.ArgumentException("Invalid sorting option."); - } + switch (sortOption) + { + case SortOption.Title: + selectArguments.SortOrder = "MEDIA_DISPLAY_NAME"; + break; + case SortOption.Date: + selectArguments.SortOrder = "MEDIA_RECORDED_DATE"; + break; + case SortOption.Genre: + selectArguments.SortOrder = "MEDIA_GENRE"; + break; + case SortOption.Type: + selectArguments.SortOrder = "MEDIA_TYPE"; + break; + case SortOption.Album: + selectArguments.SortOrder = "MEDIA_ALBUM"; + break; + case SortOption.Artist: + selectArguments.SortOrder = "MEDIA_ARTIST"; + break; + default: + throw new System.ArgumentException("Invalid sorting option."); + } - if (offset >= 0) - { - selectArguments.StartRowIndex = offset; - } + if (offset >= 0) + { + selectArguments.StartRowIndex = offset; + } - if (count >= 0) - { - selectArguments.TotalRowCount = count; - } + if (count >= 0) + { + selectArguments.TotalRowCount = count; + } - if (storageId != null) - { - selectArguments.StorageId = storageId; - } + if (storageId != null) + { + selectArguments.StorageId = storageId; + } - selectArguments.FilterExpression = GetConditionStringForSelection(); + selectArguments.FilterExpression = GetConditionStringForSelection(); - // Executes the 'select' query - List<MediaInfo> mediaInformationList = new List<MediaInfo>(); - List<MediaInformationEx> mediaInformationExList = new List<MediaInformationEx>(); - try - { + // Executes the 'select' query + List<MediaInfo> mediaInformationList = new List<MediaInfo>(); + List<MediaInformationEx> mediaInformationExList = new List<MediaInformationEx>(); + try + { - var reader = MediaHubImpl.GetInstance.MediaInfoCommand.SelectMedia(selectArguments); + var reader = MediaHubImpl.GetInstance.MediaInfoCommand.SelectMedia(selectArguments); - while (reader.Read()) - { - mediaInformationList.Add(reader.Current); - } + while (reader.Read()) + { + mediaInformationList.Add(reader.Current); + } - foreach (MediaInfo mediaInformation in mediaInformationList) - { - var mediaInformationEx = new MediaInformationEx(); + foreach (MediaInfo mediaInformation in mediaInformationList) + { + var mediaInformationEx = new MediaInformationEx(); - mediaInformationEx.MediaContentInformation = mediaInformation; - CheckUnavailableContent(mediaInformationEx); - mediaInformationExList.Add(mediaInformationEx); + mediaInformationEx.MediaContentInformation = mediaInformation; + CheckUnavailableContent(mediaInformationEx); + mediaInformationExList.Add(mediaInformationEx); + } + } + catch (Exception exception) + { + DbgPort.E(exception.Message); } - } - catch (Exception exception) - { - DbgPort.E(exception.Message); - } - return mediaInformationExList; + return mediaInformationExList; + }); } /// <summary> |