<commit_before>﻿/*
 * Copyright (C) 2015 Refractored LLC & <NAME>: 
 * http://github.com/JamesMontemagno
 * http://twitter.com/JamesMontemagno
 * http://refractored.com
 * 
 * The MIT License (MIT) see GitHub For more information
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows.Input;
using Foundation;
using Refractored.XamForms.PullToRefresh;
using Refractored.XamForms.PullToRefresh.iOS;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;


[assembly:ExportRenderer(typeof(PullToRefreshLayout), typeof(PullToRefreshLayoutRenderer))]
namespace Refractored.XamForms.PullToRefresh.iOS
{

    /// <summary>
    /// Pull to refresh layout renderer.
    /// </summary>
    [Preserve]
    public class PullToRefreshLayoutRenderer : ViewRenderer<Refractored.XamForms.PullToRefresh.PullToRefreshLayout, UIView>
    {
       

        UIRefreshControl refreshControl;

        /// <summary>
        /// Raises the element changed event.
        /// </summary>
        /// <param name="e">E.</param>
        protected override void OnElementChanged (ElementChangedEventArgs<Refractored.XamForms.PullToRefresh.PullToRefreshLayout> e)
        {
            base.OnElementChanged (e);

            if (e.OldElement != null || Element == null)
                return;

  

            refreshControl = new UIRefreshControl ();

            refreshControl.ValueChanged += OnRefresh;

            var packed = RendererFactory.GetRenderer(Element.Content);

            Element.Content.SetValue(RendererProperty, packed);

            SetNativeControl(packed.NativeView);
            try
            {
                TryInsertRefresh(Control);
            }
            catch(Exception ex)
            {
                Debug.WriteLine("View is not supported in PullToRefreshLayout: " + ex);
            }
           

            UpdateColors();
            UpdateIsRefreshing();
            UpdateIsSwipeToRefreshEnabled();
        }

       

        bool TryInsertRefresh(UIView view, int index = 0)
        {
            
            if (view is UITableView)
            {
                view.InsertSubview(refreshControl, index);
                return true;
            }

            if (view is UIScrollView)
            {
                view.InsertSubview(refreshControl, index);
                return true;
            }

            if (view.Subviews == null)
                return false;

            for (int i = 0; i < view.Subviews.Length; i++)
            {
                var control = view.Subviews[i];
                if (TryInsertRefresh(control, i))
                    return true;
            }

            return false;<commit_msg>Add uicollecitonview<commit_after>﻿/*
 * Copyright (C) 2015 Refractored LLC & <NAME>: 
 * http://github.com/JamesMontemagno
 * http://twitter.com/JamesMontemagno
 * http://refractored.com
 * 
 * The MIT License (MIT) see GitHub For more information
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows.Input;
using Foundation;
using Refractored.XamForms.PullToRefresh;
using Refractored.XamForms.PullToRefresh.iOS;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;


[assembly:ExportRenderer(typeof(PullToRefreshLayout), typeof(PullToRefreshLayoutRenderer))]
namespace Refractored.XamForms.PullToRefresh.iOS
{

    /// <summary>
    /// Pull to refresh layout renderer.
    /// </summary>
    [Preserve]
    public class PullToRefreshLayoutRenderer : ViewRenderer<Refractored.XamForms.PullToRefresh.PullToRefreshLayout, UIView>
    {
       

        UIRefreshControl refreshControl;

        /// <summary>
        /// Raises the element changed event.
        /// </summary>
        /// <param name="e">E.</param>
        protected override void OnElementChanged (ElementChangedEventArgs<Refractored.XamForms.PullToRefresh.PullToRefreshLayout> e)
        {
            base.OnElementChanged (e);

            if (e.OldElement != null || Element == null)
                return;

  

            refreshControl = new UIRefreshControl ();

            refreshControl.ValueChanged += OnRefresh;

            var packed = RendererFactory.GetRenderer(Element.Content);

            Element.Content.SetValue(RendererProperty, packed);

            SetNativeControl(packed.NativeView);
            try
            {
                TryInsertRefresh(Control);
            }
            catch(Exception ex)
            {
                Debug.WriteLine("View is not supported in PullToRefreshLayout: " + ex);
            }
           

            UpdateColors();
            UpdateIsRefreshing();
            UpdateIsSwipeToRefreshEnabled();
        }

       

        bool TryInsertRefresh(UIView view, int index = 0)
        {
            
            if (view is UITableView)
            {
                view.InsertSubview(refreshControl, index);
                return true;
            }

            if (view is UICollectionView)
            {
                view.InsertSubview(refreshControl, index);
                return true;
            }

            if (view is UIScrollView)
            {
                view.InsertSubview(refreshControl, index);
                return true;
            }

            if (view.Subviews == null)
                return false;

            for (int i = 0; i < view.Subviews.Length; i++)
            {
                var control = view.Subviews[i];
                if (TryInsertRefresh(control, i))
                    return true;
            }

            return false;
{'fraction_non_alphanumeric': 0.08723540731237973, 'fraction_numerical': 0.001924310455420141, 'mean_word_length': 1.9615384615384615, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 21, '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': '5110471', 'n_tokens_mistral': 1648, 'n_tokens_neox': 1555, 'n_words': 402}