[SuppressMessage("Microsoft.Design", "CA1031: Do not catch general exception types", Justification = "This method is to handle external resources that may throw an exception but ignorable. This method should not interupt the main stream.")]
internal static class ExternalThemeManager
{
- private static readonly Tizen.Applications.ThemeManager.ThemeLoader themeLoader = new Tizen.Applications.ThemeManager.ThemeLoader();
+ private static Tizen.Applications.ThemeManager.ThemeLoader themeLoader = InitializeThemeLoader();
+
private static string sharedResourcePath;
#if DEBUG
private static IExternalTheme theme;
{
get
{
+ if (themeLoader == null)
+ {
+ return string.Empty;
+ }
#if DEBUG
if (theme != null)
{
catch (ArgumentException e)
{
Tizen.Log.Error("NUI", $"{e.GetType().Name} occured while getting theme application info.");
- throw e;
+ throw;
}
catch (InvalidOperationException e)
{
Tizen.Log.Error("NUI", $"{e.GetType().Name} occured while getting theme application info.");
- throw e;
+ throw;
}
if (themePkgInfo == null)
public static void Initialize()
{
+ if (themeLoader == null)
+ {
+ return;
+ }
+
themeLoader.ThemeChanged += OnTizenThemeChanged;
}
public static IExternalTheme GetCurrentTheme()
{
+ if (themeLoader == null)
+ {
+ return null;
+ }
+
#if DEBUG
if (theme != null)
{
public static IExternalTheme GetTheme(string id)
{
+ if (themeLoader == null)
+ {
+ return null;
+ }
+
Tizen.Applications.ThemeManager.Theme tizenTheme = null;
try
sharedResourcePath = null;
ThemeManager.ApplyExternalTheme(new TizenExternalTheme(e.Theme));
}
+
+ private static Tizen.Applications.ThemeManager.ThemeLoader InitializeThemeLoader()
+ {
+ try
+ {
+ return new Tizen.Applications.ThemeManager.ThemeLoader();
+ }
+ catch (DllNotFoundException e)
+ {
+ Tizen.Log.Info("NUI", $"[Ignorable] {e.GetType().Name} occured while setting Tizen.Applications.ThemeManager: {e.Message}");
+ }
+
+ return null;
+ }
}
}