diff options
author | Rui Marinho <me@ruimarinho.net> | 2017-03-24 17:54:12 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-24 17:54:12 +0000 |
commit | 63af84080454e7b108208b6e8e67bbf503e41209 (patch) | |
tree | 01ca8da27de5acd510c4a075d512b5c66a98b4d3 /Xamarin.Forms.Platform.Android | |
parent | eea0bdcc6e3fdfcf3229abedac32204e47602f60 (diff) | |
download | xamarin-forms-63af84080454e7b108208b6e8e67bbf503e41209.tar.gz xamarin-forms-63af84080454e7b108208b6e8e67bbf503e41209.tar.bz2 xamarin-forms-63af84080454e7b108208b6e8e67bbf503e41209.zip |
[Android] Still look for the normal drawable on resources (#839)
* [Android] Still look for the normal drawable on resources
* [Android]Fix code style
Diffstat (limited to 'Xamarin.Forms.Platform.Android')
-rw-r--r-- | Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs | 4 | ||||
-rw-r--r-- | Xamarin.Forms.Platform.Android/CellAdapter.cs | 6 | ||||
-rw-r--r-- | Xamarin.Forms.Platform.Android/Platform.cs | 7 |
3 files changed, 9 insertions, 8 deletions
diff --git a/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs b/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs index cc474293..1b4afba2 100644 --- a/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs +++ b/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs @@ -744,8 +744,8 @@ namespace Xamarin.Forms.Platform.Android.AppCompat FileImageSource icon = item.Icon; if (!string.IsNullOrEmpty(icon)) { - var iconBitmap = new BitmapDrawable(context.Resources, ResourceManager.GetBitmap(context.Resources, icon)); - if (iconBitmap != null && iconBitmap.Bitmap != null) + Drawable iconBitmap = context.Resources.GetDrawable(icon) ?? new BitmapDrawable(context.Resources, ResourceManager.GetBitmap(context.Resources, icon)); + if (iconBitmap != null) menuItem.SetIcon(iconBitmap); } menuItem.SetEnabled(controller.IsEnabled); diff --git a/Xamarin.Forms.Platform.Android/CellAdapter.cs b/Xamarin.Forms.Platform.Android/CellAdapter.cs index dda0c7e1..187ac23c 100644 --- a/Xamarin.Forms.Platform.Android/CellAdapter.cs +++ b/Xamarin.Forms.Platform.Android/CellAdapter.cs @@ -195,9 +195,9 @@ namespace Xamarin.Forms.Platform.Android if (action.Icon != null) { - var iconBitmap = new BitmapDrawable(_context.Resources, ResourceManager.GetBitmap(_context.Resources, action.Icon)); - if (iconBitmap != null && iconBitmap.Bitmap != null) - item.SetIcon(_context.Resources.GetDrawable(action.Icon)); + Drawable iconBitmap = _context.Resources.GetDrawable(action.Icon) ?? new BitmapDrawable(_context.Resources, ResourceManager.GetBitmap(_context.Resources, action.Icon)); + if (iconBitmap != null) + item.SetIcon(iconBitmap); } action.PropertyChanged += changed; diff --git a/Xamarin.Forms.Platform.Android/Platform.cs b/Xamarin.Forms.Platform.Android/Platform.cs index 0fc287c9..c2bb007e 100644 --- a/Xamarin.Forms.Platform.Android/Platform.cs +++ b/Xamarin.Forms.Platform.Android/Platform.cs @@ -359,10 +359,11 @@ namespace Xamarin.Forms.Platform.Android else { IMenuItem menuItem = menu.Add(item.Text); - if (!string.IsNullOrEmpty(item.Icon)) + var icon = item.Icon; + if (!string.IsNullOrEmpty(icon)) { - var iconBitmap = new BitmapDrawable(_context.Resources, ResourceManager.GetBitmap(_context.Resources, item.Icon)); - if (iconBitmap != null && iconBitmap.Bitmap != null) + Drawable iconBitmap = _context.Resources.GetDrawable(icon) ?? new BitmapDrawable(_context.Resources, ResourceManager.GetBitmap(_context.Resources, icon)); + if (iconBitmap != null) menuItem.SetIcon(iconBitmap); } menuItem.SetEnabled(controller.IsEnabled); |