<commit_before>﻿using System;
using Xamarin.Forms;
using ZXing.Net.Mobile.Forms;
using ZXing.Net.Mobile.Forms.Android;
using Android.Runtime;
using Android.App;
using Xamarin.Forms.Platform.Android;
using Android.Views;
using System.ComponentModel;
using System.Reflection;
using Android.Widget;
using ZXing.Mobile;
using System.Threading.Tasks;

[assembly:ExportRenderer(typeof(ZXingScannerView), typeof(ZXingScannerViewRenderer))]
namespace ZXing.Net.Mobile.Forms.Android
{
    [Preserve(AllMembers = true)]
    public class ZXingScannerViewRenderer : ViewRenderer<ZXingScannerView, ZXing.Mobile.ZXingSurfaceView>
    {       
        public static void Init ()
        {
            var temp = DateTime.Now;
        }

        ZXingScannerView formsView;
        IntermediaryScanner intermediaryScanner;

        internal ZXingSurfaceView zxingSurface;
        internal Task<bool> requestPermissionsTask;

        internal TaskCompletionSource<bool> finishedSetup;

        protected override async void OnElementChanged(ElementChangedEventArgs<ZXingScannerView> e)
        {
            formsView = Element;


            if (zxingSurface == null) {
                finishedSetup = new TaskCompletionSource<bool> ();

                // We'll proxy our requests through an intermediate layer that can intercept
                // the scanning so it can ask for permission
                intermediaryScanner = new IntermediaryScanner {
                    Parent = this                
                };
                formsView.InternalNativeScannerImplementation = intermediaryScanner;

                var activity = Context as Activity;

                if (activity != null)                
                    await PermissionsHandler.RequestPermissions (activity);
                
                zxingSurface = new ZXingSurfaceView (Xamarin.Forms.Forms.Context as Activity);
                zxingSurface.LayoutParameters = new LayoutParams (LayoutParams.MatchParent, LayoutParams.MatchParent);
                  
                base.SetNativeControl (zxingSurface);     

                finishedSetup.TrySetResult (true);
            }

            base.OnElementChanged (e);
        }

        public override bool OnTouchEvent (MotionEvent e)
        {
            var x = e.GetX ();            
            var y = e.GetY ();<commit_msg>Move base call up to top to fix crash on android<commit_after>﻿using System;
using Xamarin.Forms;
using ZXing.Net.Mobile.Forms;
using ZXing.Net.Mobile.Forms.Android;
using Android.Runtime;
using Android.App;
using Xamarin.Forms.Platform.Android;
using Android.Views;
using System.ComponentModel;
using System.Reflection;
using Android.Widget;
using ZXing.Mobile;
using System.Threading.Tasks;

[assembly:ExportRenderer(typeof(ZXingScannerView), typeof(ZXingScannerViewRenderer))]
namespace ZXing.Net.Mobile.Forms.Android
{
    [Preserve(AllMembers = true)]
    public class ZXingScannerViewRenderer : ViewRenderer<ZXingScannerView, ZXing.Mobile.ZXingSurfaceView>
    {       
        public static void Init ()
        {
            var temp = DateTime.Now;
        }

        ZXingScannerView formsView;
        IntermediaryScanner intermediaryScanner;

        internal ZXingSurfaceView zxingSurface;
        internal Task<bool> requestPermissionsTask;

        internal TaskCompletionSource<bool> finishedSetup;

        protected override async void OnElementChanged(ElementChangedEventArgs<ZXingScannerView> e)
        {
            base.OnElementChanged (e);

            formsView = Element;

            if (zxingSurface == null) {
                finishedSetup = new TaskCompletionSource<bool> ();

                // We'll proxy our requests through an intermediate layer that can intercept
                // the scanning so it can ask for permission
                intermediaryScanner = new IntermediaryScanner {
                    Parent = this                
                };
                formsView.InternalNativeScannerImplementation = intermediaryScanner;

                var activity = Context as Activity;

                if (activity != null)                
                    await PermissionsHandler.RequestPermissions (activity);
                
                zxingSurface = new ZXingSurfaceView (Xamarin.Forms.Forms.Context as Activity);
                zxingSurface.LayoutParameters = new LayoutParams (LayoutParams.MatchParent, LayoutParams.MatchParent);
                  
                base.SetNativeControl (zxingSurface);     

                finishedSetup.TrySetResult (true);
            }
        }

        public override bool OnTouchEvent (MotionEvent e)
        {
            var x = e.GetX ();            
            var y = e.GetY ();
{'fraction_non_alphanumeric': 0.06866048862679022, 'fraction_numerical': 0.0, 'mean_word_length': 2.1492042440318304, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '678179', 'n_tokens_mistral': 1212, 'n_tokens_neox': 1152, 'n_words': 284}