Example #1
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            System.Diagnostics.Debug.WriteLine("EditItemActivity.OnActivityResult()");

            base.OnActivityResult(requestCode, resultCode, data);

            if (resultCode == Result.Ok)
            {
                System.Diagnostics.Debug.WriteLine("Result ok...");

                int height = Resources.DisplayMetrics.HeightPixels;
                int width  = imageView.Height;
                AndroidHelper.bitmap = tmpImageFile.Path.LoadAndResizeBitmap(width, height);
                if (AndroidHelper.bitmap != null)
                {
                    System.Diagnostics.Debug.WriteLine("bitmap exists...");

                    // Compress
                    FileStream fs = null;
                    AndroidHelper.DeleteImageFromDirectory(tmpImageFile.Path);
                    fs = File.Create(tmpImageFile.Path);
                    AndroidHelper.bitmap.Compress(Bitmap.CompressFormat.Jpeg, 25, fs);
                    fs.Close();

                    // Display
                    imageView.SetColorFilter(null);
                    imageView.SetScaleType(ImageView.ScaleType.CenterCrop);
                    RunOnUiThread(() => DisplayImage(tmpImageFile.Path));

                    // In case there was a previous photo that was deleted, reset flag
                    //deletingPhoto = false;
                }
            }
        }