From: gs86.lee Date: Thu, 2 Mar 2017 05:02:27 +0000 (+0900) Subject: Set the default icon if the app icon is not exist X-Git-Tag: submit/tizen/20170808.015446~231 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0521a87af50a5c0757006c7c50a27eb4d8794b74;p=profile%2Ftv%2Fapps%2Fdotnet%2Fhome.git Set the default icon if the app icon is not exist Change-Id: I5df548772df7ed7e98ef22e421031ee8dd2d1cd8 --- diff --git a/TVHome/TVHome.TizenTV/Ports/ApplicationManagerPort.cs b/TVHome/TVHome.TizenTV/Ports/ApplicationManagerPort.cs index ca109c1..431a469 100644 --- a/TVHome/TVHome.TizenTV/Ports/ApplicationManagerPort.cs +++ b/TVHome/TVHome.TizenTV/Ports/ApplicationManagerPort.cs @@ -49,9 +49,9 @@ namespace TVHome.TizenTV.Ports { result = new string[3]; - result[0] = appInfo.Label != null ? appInfo.Label : null; - result[1] = appInfo.ApplicationId != null ? appInfo.ApplicationId : null; - result[2] = appInfo.IconPath != null ? appInfo.IconPath : "AppIcon.png"; + result[0] = (appInfo.Label != null) ? appInfo.Label : null; + result[1] = (appInfo.ApplicationId != null) ? appInfo.ApplicationId : null; + result[2] = (System.IO.File.Exists(appInfo.IconPath)) ? appInfo.IconPath : "AppIcon.png"; resultList.Add(appInfo.ApplicationId, result); } @@ -62,6 +62,9 @@ namespace TVHome.TizenTV.Ports { Dictionary result = null; ApplicationInfo appInfo = null; + string[] icons = { "ic_black.png", "ic_blue.png", "ic_green.png", "ic_red.png", "ic_yellow.png", "AppIcon.png" }; + Random random = new Random(); + try { appInfo = ApplicationManager.GetInstalledApplication(applicationId); @@ -73,7 +76,7 @@ namespace TVHome.TizenTV.Ports result = new Dictionary(); result.Add("Label", appInfo.Label); result.Add("ApplicationId", appInfo.ApplicationId); - result.Add("IconPath", appInfo.IconPath); + result.Add("IconPath", (System.IO.File.Exists(appInfo.IconPath)) ? appInfo.IconPath : icons[random.Next(0, 6)]); } catch(Exception exception) { diff --git a/TVHome/TVHome.TizenTV/Ports/PackageManagerPort.cs b/TVHome/TVHome.TizenTV/Ports/PackageManagerPort.cs index a27a588..e2a90d9 100644 --- a/TVHome/TVHome.TizenTV/Ports/PackageManagerPort.cs +++ b/TVHome/TVHome.TizenTV/Ports/PackageManagerPort.cs @@ -62,32 +62,9 @@ namespace TVHome.TizenTV.Ports { result = new string[3]; - if (item.Label != null) - { - result[0] = item.Label; - } - else - { - result[0] = null; - } - - if (item.Id != null) - { - result[1] = item.Id; - } - else - { - result[1] = null; - } - - if (item.IconPath != null) - { - result[2] = item.IconPath; - } - else - { - result[2] = null; - } + result[0] = (item.Label != null) ? item.Label : null; + result[1] = (item.Id != null) ? item.Id : null; + result[2] = (System.IO.File.Exists(item.IconPath)) ? item.IconPath : "AppIcon.png"; pkgList.Add(item.Label, result); } @@ -99,14 +76,7 @@ namespace TVHome.TizenTV.Ports { Package tempItem = PackageManager.GetPackage(PkgID); - if (tempItem != null) - { - return tempItem.Label; - } - else - { - return null; - } + return (tempItem != null) ? tempItem.Label : null; } } } \ No newline at end of file