Ejemplo n.º 1
0
        public void getImageBitmapAsync(Bitmap bitmap)
        {
            horizontal_recycler_view.Visibility = ViewStates.Visible;



            var stream = new MemoryStream();

            bitmap.Compress(Bitmap.CompressFormat.Jpeg, 100, stream);
            byte[] imageInByte = stream.ToArray();
            byteList.Add(imageInByte);

            long lengthbmp = imageInByte.Length;

            imageSize = imageSize + lengthbmp;

            AddUpdateImageModel addUpdateImage = new AddUpdateImageModel();

            base64ImageCode = BasicUtils.GetInstance().ConvertBitmapToBase64(bitmap);
            img_event1.SetImageBitmap(bitmap);

            addUpdateImage.bitmap     = bitmap;
            addUpdateImage.ImageUrl   = base64ImageCode;
            addUpdateImage.CountImage = imagesList.Count + 1;
            imagesList.Add(addUpdateImage);
            addUpdateImageAdapter.NotifyDataSetChanged();
            horizontal_recycler_view.SmoothScrollToPosition(imagesList.Count());
        }
Ejemplo n.º 2
0
        internal override void InitViews()
        {
            editTitle                = FindViewById <EditText>(Resource.Id.editTitle);
            cv_userprofile           = FindViewById <Refractored.Controls.CircleImageView>(Resource.Id.cv_userprofile);
            horizontal_recycler_view = FindViewById <RecyclerView>(Resource.Id.horizontal_recycler_view);
            img_event1               = FindViewById <ImageView>(Resource.Id.img_event1);
            tv_username              = FindViewById <TextView>(Resource.Id.tv_username);
            ll_back        = (LinearLayout)FindViewById(Resource.Id.ll_back);
            ll_post        = (LinearLayout)FindViewById(Resource.Id.ll_post);
            ll_photovideo  = (LinearLayout)FindViewById(Resource.Id.ll_photovideo);
            ll_tag_friends = (LinearLayout)FindViewById(Resource.Id.ll_tag_friends);
            ll_camera      = (LinearLayout)FindViewById(Resource.Id.ll_camera);

            LinearLayoutManager mLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.Horizontal, false);

            horizontal_recycler_view.SetLayoutManager(mLayoutManager);
            imagesList.Clear();
            addUpdateImageAdapter = new AddUpdateImageAdapter(this, imagesList);
            horizontal_recycler_view.SetAdapter(addUpdateImageAdapter);

            tv_username.Text = Settings.UserFirstNameSettings + " " + Settings.UserMiddleNameSettings + " " + Settings.UserLastNameSettings;

            BasicUtils.GetInstance().SetImageFromUrl(this, this, Settings.UserImageUrlSettings, cv_userprofile, showMessageObject, false);
        }
Ejemplo n.º 3
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            if (resultCode == Result.Ok)
            {
                if (requestCode == REQUEST_TAKE_GALLERY_VIDEO)
                {
                    horizontal_recycler_view.Visibility = ViewStates.Visible;
                    var    uri  = data.Data;
                    string path = BasicUtils.GetActualPathFromFile(uri, this);
                    System.Diagnostics.Debug.WriteLine("Image path == " + path);
                    Bitmap thumb = ThumbnailUtils.CreateVideoThumbnail(path, ThumbnailKind.MiniKind);

                    AddUpdateImageModel addUpdateImage = new AddUpdateImageModel();
                    base64ImageCode = BasicUtils.GetInstance().ConvertBitmapToBase64(thumb);


                    addUpdateImage.bitmap     = thumb;
                    addUpdateImage.ImageUrl   = base64ImageCode;
                    addUpdateImage.CountImage = imagesList.Count + 1;
                    imagesList.Add(addUpdateImage);
                    addUpdateImageAdapter.NotifyDataSetChanged();
                    horizontal_recycler_view.SmoothScrollToPosition(imagesList.Count());
                }
                if (requestCode == CameraCaptureImageRequestCode)
                {
                    PreviewCapturedImage();
                }
                else if (requestCode == CameraCaptureVideoRequestCode)
                {
                    horizontal_recycler_view.Visibility = ViewStates.Visible;
                    var    uri  = data.Data;
                    string path = BasicUtils.GetActualPathFromFile(uri, this);
                    System.Diagnostics.Debug.WriteLine("Image path == " + path);
                    Bitmap thumb = ThumbnailUtils.CreateVideoThumbnail(path, ThumbnailKind.MiniKind);

                    AddUpdateImageModel addUpdateImage = new AddUpdateImageModel();
                    base64ImageCode = BasicUtils.GetInstance().ConvertBitmapToBase64(thumb);


                    addUpdateImage.bitmap     = thumb;
                    addUpdateImage.ImageUrl   = base64ImageCode;
                    addUpdateImage.CountImage = imagesList.Count + 1;
                    imagesList.Add(addUpdateImage);
                    addUpdateImageAdapter.NotifyDataSetChanged();
                    horizontal_recycler_view.SmoothScrollToPosition(imagesList.Count());
                }
                else if (requestCode == PicFromGallery)
                {
                    fileUri = data.Data;

                    Bitmap bitmap = MediaStore.Images.Media.GetBitmap(ContentResolver, fileUri);


                    GetImageFromGallery();
                }
                else if (requestCode == PicCrop && data != null)
                {
                    //get the returned data
                    Android.Net.Uri extras = data.Data;
                    //get the cropped bitmap

                    if (extras != null)
                    {
                        var inp = context.ContentResolver.OpenInputStream(extras);
                        BitmapFactory.Options options = new BitmapFactory.Options();
                        Bitmap cropped_bitmap         = BitmapFactory.DecodeStream(inp, null, options);
                        newBitmap = cropped_bitmap;
                        getImageBitmapAsync(newBitmap);
                    }
                    else
                    {
                        var inp = context.ContentResolver.OpenInputStream(fileUri);
                        BitmapFactory.Options options = new BitmapFactory.Options();


                        //Bitmap cropped_bitmap =
                        MemoryStream stream = new MemoryStream();
                        BitmapFactory.DecodeStream(inp, null, options).Compress(Bitmap.CompressFormat.Jpeg, 50, stream);

                        byte[] bitmapData = stream.ToArray();
                        Bitmap bitmap     = BitmapFactory.DecodeByteArray(bitmapData, 0, bitmapData.Length);


                        newBitmap = bitmap;
                        getImageBitmapAsync(newBitmap);
                    }
                }
            }
        }