Exemple #1
0
        public void LoadBitmap(int desiredSize)
        {
            try
            {
                if (Image != null)
                {
                    Image.Recycle();
                    Image.Dispose();
                }

                if (string.IsNullOrEmpty(PhotoPath))
                {
                    SetDefaultImage();
                }
                else if (FromContacts)
                {
                    var addressBook = new AddressBook(Application.Context)
                    {
                        PreferContactAggregation = false
                    };
                    var contact = addressBook.Load(PhotoPath);
                    var image   = contact.GetThumbnail();
                    Image = image == null?GetDefaultImage() : image.GetRoundedCornerBitmap();
                }
                else
                {
                    var image = BitmapExtensions.DecodeBitmap(PhotoPath, desiredSize, desiredSize);
                    Image = image == null?GetDefaultImage() : image.GetRoundedCornerBitmap();
                }
            }
            catch (Exception ex)
            {
                GaService.TrackAppException("Player", "LoadBitmap", ex, false);
                SetDefaultImage();
                if (!string.IsNullOrEmpty(PhotoPath))
                {
                    PhotoPath = null;
                }
            }
        }