Karamunting.Android.Alhazmy13.MediaPicker 2.4.0

dotnet add package Karamunting.Android.Alhazmy13.MediaPicker --version 2.4.0
NuGet\Install-Package Karamunting.Android.Alhazmy13.MediaPicker -Version 2.4.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Karamunting.Android.Alhazmy13.MediaPicker" Version="2.4.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Karamunting.Android.Alhazmy13.MediaPicker --version 2.4.0
#r "nuget: Karamunting.Android.Alhazmy13.MediaPicker, 2.4.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Karamunting.Android.Alhazmy13.MediaPicker as a Cake Addin
#addin nuget:?package=Karamunting.Android.Alhazmy13.MediaPicker&version=2.4.0

// Install Karamunting.Android.Alhazmy13.MediaPicker as a Cake Tool
#tool nuget:?package=Karamunting.Android.Alhazmy13.MediaPicker&version=2.4.0
// Created by Rofiq Setiawan (rofiqsetiawan@gmail.com)

using System.Collections.Generic;
using System.Linq;
using Android.App;
using Android.Content;
using Android.Graphics;
using Android.OS;
using Android.Runtime;
using Android.Util;
using Android.Views;
using Android.Widget;
using Net.Alhazmy13.MediaPicker;
using Net.Alhazmy13.MediaPicker.Image;
using Fragment = Android.App.Fragment;
using R = MediaPickerDemo.Resource;

namespace MediaPickerDemo
{
    public sealed class ImageFragment : Fragment
    {
        private ImageView _imageView;
        private TextView _path;

        private const string MyTag = "MainActivity";
        private List<string> _pathList;

        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(R.Layout.image_layout, container, false);

            _imageView = view.FindViewById<ImageView>(R.Id.iv_image);
            _path = view.FindViewById<TextView>(R.Id.tv_path);
            view.FindViewById<Button>(R.Id.bt_pick).Click += (s, e) => PickImage();

            return view;
        }

        private void PickImage()
        {
            new ImagePicker.Builder(Activity)
                .Mode(ImagePicker.Mode.CameraAndGallery)
                .CompressLevel(ImagePicker.ComperesLevel.Medium)
                .Directory(ImagePicker.Directory.Default)
                .Extension(ImagePicker.Extension.Jpg)
                .AllowOnlineImages(false)
                .Scale(600, 600)
                .AllowMultipleImages(true)
                .EnableDebuggingMode(false)
                .Build();
        }

        public override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);
#if DEBUG
            Log.Debug(
                MyTag,
                $"OnActivityResult() called with: requestCode = [{requestCode}], resultCode = [{resultCode}], data = [{data}]"
            );
#endif
            if (requestCode == ImagePicker.ImagePickerRequestCode && resultCode == Result.Ok)
            {
                // .ToList() available on "Net.Alhazmy13.MediaPicker" namespace
                _pathList = data.GetSerializableExtra(ImagePicker.ExtraImagePath).ToList();

                LoadImage();
            }
        }

        private void LoadImage()
        {
#if DEBUG
            Log.Debug(MyTag, $"LoadImage: {_pathList.Count}");
#endif
            _path.Text = (_pathList[0]);
            _imageView.SetImageBitmap(BitmapFactory.DecodeFile(_pathList[0]));
        }
    }
}
Product Compatible and additional computed target framework versions.
MonoAndroid monoandroid81 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.4.0 826 9/2/2018