Exemplo n.º 1
0
            public static object Install(Context context)
            {
                File cacheDir           = AndroidUtils.CreateDefaultCacheDir(context);
                HttpResponseCache cache = HttpResponseCache.Installed;

                if (cache == null)
                {
                    long maxSize = AndroidUtils.CalculateDiskCacheSize(cacheDir);
                    cache = HttpResponseCache.Install(cacheDir, maxSize);
                }
                return(cache);
            }
Exemplo n.º 2
0
        /// <summary>
        /// Initialize activity
        /// </summary>
        protected override void OnCreate(Bundle savedInstance)
        {
            base.OnCreate(savedInstance);

            try
            {
                var        httpCacheDir  = new Java.Io.File(GetCacheDir(), "http");
                const long httpCacheSize = 10 * 1024 * 1024; // 10 MB
                HttpResponseCache.Install(httpCacheDir, httpCacheSize);
            }
            catch (IOException ex)
            {
                Log.E(Tag, "HTTP response cache installation failed. " + ex.Message + " " + ex.StackTrace);
            }

            SetContentView(R.Layouts.MainLayout);
            _fixtureList = FindViewById <ListView>(R.Ids.fixtureList);

            _fixturesArray = _fixtures.ToArray();
            _adapter       = new ArrayAdapter <Fixture>(this, Android.R.Layout.Simple_list_item_1, _fixturesArray);
            _fixtureList.SetAdapter(_adapter);

            GetFixturesAsync();
        }
Exemplo n.º 3
0
        protected override void OnCreate(Bundle bundle)
        {
            try
            {
                FormsAppCompatActivity.ToolbarResource   = Resource.Layout.Toolbar;
                FormsAppCompatActivity.TabLayoutResource = Resource.Layout.Tabbar;

                base.OnCreate(bundle);


                if (Settings.TurnFullScreenOn)
                {
                    this.Window.AddFlags(WindowManagerFlags.Fullscreen);
                    this.Window.AddFlags(WindowManagerFlags.KeepScreenOn);
                }

                if (Settings.TurnSecurityProtocolType3072On)
                {
                    ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
                    HttpClient client = new HttpClient(new Xamarin.Android.Net.AndroidClientHandler());
                }

                if (Settings.TurnTrustFailureOn_WebException)
                {
                    //If you are Getting this error >>> System.Net.WebException: Error: TrustFailure /// then Set it to true
                    System.Net.ServicePointManager.ServerCertificateValidationCallback += (o, certificate, chain, errors) => true;
                    System.Security.Cryptography.AesCryptoServiceProvider b = new System.Security.Cryptography.AesCryptoServiceProvider();
                }

                //Methods =>> Copy the text
                AndroidClipboardManager = (ClipboardManager)GetSystemService(ClipboardService);

                CachedImageRenderer.Init();
                var ignore = new CircleTransformation();

                var assembliesToInclude = new List <Assembly>()
                {
                    typeof(CachedImage).GetTypeInfo().Assembly,
                    typeof(CachedImageRenderer).GetTypeInfo().Assembly
                };
                SegmentedControlRenderer.Init();
                PullToRefreshLayoutRenderer.Init();
                FFImageLoading.Forms.Droid.CachedImageRenderer.Init();
                global::Xamarin.Forms.Forms.Init(this, bundle);

                try
                {
                    var  activity      = Xamarin.Forms.Forms.Context;
                    File httpCacheDir  = new File(activity.CacheDir, "http");
                    long httpCacheSize = 10 * 1024 * 1024; // 10 MiB
                    HttpResponseCache.Install(httpCacheDir, httpCacheSize);
                }
                catch (IOException ce)
                {
                }

                UserDialogs.Init(this);

                MobileAds.Initialize(ApplicationContext, Settings.Ad_Unit_ID);

                FormsWebViewRenderer.Initialize();
                LoadApplication(new App());
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }