<commit_before>using System;
using Android.Content;
using Android.Runtime;
using Android.Util;
using Android.Views;
using Android.Widget;

namespace LoaderImageView
{
    public class LoaderImageView : RelativeLayout
    {
        private Context _context;
        private ProgressBar _progressBar;
        private ImageView _imageView;

        protected LoaderImageView(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
        {
        }

        public LoaderImageView(Context context) : base(context)
        {
            Init(context, null);
        }

        public LoaderImageView(Context context, IAttributeSet attrs) : base(context, attrs)
        {
            Init(context, attrs);
        }

        public LoaderImageView(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle)
        {
            Init(context, attrs);
        }

        private void Init(Context context, IAttributeSet attrs)
        {
            _context = context;

            _progressBar = new ProgressBar(_context, attrs, Android.Resource.Attribute.ProgressBarStyle)
            {
                Id = Resource.Id.LoaderProgressBar,
                Indeterminate = true
            };
            _imageView = new ImageView(_context, attrs)
            {
                Id = Resource.Id.LoaderImageView,
                LayoutParameters = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent),
                Visibility = ViewStates.Invisible
            };

            AddView(_progressBar);
            AddView(_imageView);

            SetProgressBarLayoutParams(LayoutRules.CenterInParent);
            SetImageViewScaleType(ImageView.ScaleType.CenterCrop);
            SetImageViewLayoutParams(LayoutRules.CenterInParent);
        }

        public void SetImageViewScaleType(ImageView.ScaleType scaleType)
        {
            _imageView.SetScaleType(scaleType);
        }

        public void SetImageViewLayoutParams(LayoutRules layoutRules)
        {
            var imageLayoutParams = (LayoutParams)_imageView.LayoutParameters;
            imageLayoutParams.AddRule(layoutRules);
            _imageView.LayoutParameters = imageLayoutParams;
        }

        public void SetProgressBarLayoutParams(LayoutRules layoutRules)
        {
            var progressLayoutParams = (LayoutParams)_progressBar.LayoutParameters;
            progressLayoutParams.AddRule(layoutRules);
            _progressBar.LayoutParameters = progressLayoutParams;
        }

        private void ShowImage()
        {
            _progressBar.Visibility = ViewStates.Gone;
            _imageView.Visibility = ViewStates.Visible;
        }

        private void ShowProgressBar()
        {
            _imageView.Visibility = ViewStates.Invisible;
            _imageView.LayoutParameters.Width = ViewGroup.LayoutParams.MatchParent;
            _imageView.LayoutParameters.Height = ViewGroup.LayoutParams.MatchParent;
            _progressBar.Visibility = ViewStates.Visible;
        }
    }
}
<commit_msg>Function to load local image<commit_after>using System;
using System.IO;
using Android.Content;
using Android.Runtime;
using Android.Util;
using Android.Views;
using Android.Widget;

namespace LoaderImageView
{
    public class LoaderImageView : RelativeLayout
    {
        private Context _context;
        private ProgressBar _progressBar;
        private ImageView _imageView;

        protected LoaderImageView(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
        {
        }

        public LoaderImageView(Context context) : base(context)
        {
            Init(context, null);
        }

        public LoaderImageView(Context context, IAttributeSet attrs) : base(context, attrs)
        {
            Init(context, attrs);
        }

        public LoaderImageView(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle)
        {
            Init(context, attrs);
        }

        private void Init(Context context, IAttributeSet attrs)
        {
            _context = context;

            _progressBar = new ProgressBar(_context, attrs, Android.Resource.Attribute.ProgressBarStyle)
            {
                Id = Resource.Id.LoaderProgressBar,
                Indeterminate = true
            };
            _imageView = new ImageView(_context, attrs)
            {
                Id = Resource.Id.LoaderImageView,
                LayoutParameters = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent),
                Visibility = ViewStates.Invisible
            };

            AddView(_progressBar);
            AddView(_imageView);

            SetProgressBarLayoutParams(LayoutRules.CenterInParent);
            SetImageViewScaleType(ImageView.ScaleType.CenterCrop);
            SetImageViewLayoutParams(LayoutRules.CenterInParent);
        }

        public void SetImageViewScaleType(ImageView.ScaleType scaleType)
        {
            _imageView.SetScaleType(scaleType);
        }

        public void SetImageViewLayoutParams(LayoutRules layoutRules)
        {
            var imageLayoutParams = (LayoutParams)_imageView.LayoutParameters;
            imageLayoutParams.AddRule(layoutRules);
            _imageView.LayoutParameters = imageLayoutParams;
        }

        public void SetProgressBarLayoutParams(LayoutRules layoutRules)
        {
            var progressLayoutParams = (LayoutParams)_progressBar.LayoutParameters;
            progressLayoutParams.AddRule(layoutRules);
            _progressBar.LayoutParameters = progressLayoutParams;
        }

        private void ShowImage()
        {
            _progressBar.Visibility = ViewStates.Gone;
            _imageView.Visibility = ViewStates.Visible;
        }

        private void ShowProgressBar()
        {
            _imageView.Visibility = ViewStates.Invisible;
            _imageView.LayoutParameters.Width = ViewGroup.LayoutParams.MatchParent;
            _imageView.LayoutParameters.Height = ViewGroup.LayoutParams.MatchParent;
            _progressBar.Visibility = ViewStates.Visible;
        }

        public void SetDefalutImage(int resourceID = Android.Resource.Drawable.IcMenuGallery)
        {
            _imageView.LayoutParameters.Width = ViewGroup.LayoutParams.WrapContent;
            _imageView.LayoutParameters.Height = ViewGroup.LayoutParams.WrapContent;
            _imageView.SetImageResource(resourceID);
        }

        public void SetLocalImage(string path)
        {
            ShowProgressBar();
            
            if (File.Exists(path))
                _imageView.SetImageFromFile(path);
            else
                SetDefalutImage();

            ShowImage();
        }
    }
}

{'fraction_non_alphanumeric': 0.06894528384920053, 'fraction_numerical': 0.0, 'mean_word_length': 2.2312796208530807, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6939953', 'n_tokens_mistral': 1671, 'n_tokens_neox': 1616, 'n_words': 303}