Example #1
0
        private void InitComponent()
        {
            try
            {
                MRecycler        = (RecyclerView)FindViewById(Resource.Id.recyler);
                EmptyStateLayout = FindViewById <ViewStub>(Resource.Id.viewStub);

                SwipeRefreshLayout = (SwipeRefreshLayout)FindViewById(Resource.Id.swipeRefreshLayout);
                SwipeRefreshLayout.SetColorSchemeResources(Android.Resource.Color.HoloBlueLight, Android.Resource.Color.HoloGreenLight, Android.Resource.Color.HoloOrangeLight, Android.Resource.Color.HoloRedLight);
                SwipeRefreshLayout.Refreshing = true;
                SwipeRefreshLayout.Enabled    = true;

                SwipeRefreshLayout.SetProgressBackgroundColorSchemeColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#424242") : Color.ParseColor("#f7f7f7"));
                SwipeRefreshLayout.SetBackgroundColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#282828") : Color.White);
                MRecycler.SetBackgroundColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#282828") : Color.White);

                TxtSuggestedGroups            = FindViewById <TextView>(Resource.Id.toolbar_title);
                TxtSuggestedGroups.Text       = GetString(Resource.String.Lbl_SuggestedGroups);
                TxtSuggestedGroups.Visibility = ViewStates.Visible;

                CreateButton            = FindViewById <FloatingActionButton>(Resource.Id.floatingActionButtonView);
                CreateButton.Visibility = ViewStates.Visible;
                CreateButton.SetImageResource(Resource.Drawable.ic_add);

                MAdView = FindViewById <AdView>(Resource.Id.adView);
                AdsGoogle.InitAdView(MAdView, MRecycler);
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
        private void InitComponent()
        {
            try
            {
                MRecycler        = (RecyclerView)FindViewById(Resource.Id.recyler);
                EmptyStateLayout = FindViewById <ViewStub>(Resource.Id.viewStub);

                SwipeRefreshLayout = (SwipeRefreshLayout)FindViewById(Resource.Id.swipeRefreshLayout);
                SwipeRefreshLayout.SetColorSchemeResources(Android.Resource.Color.HoloBlueLight, Android.Resource.Color.HoloGreenLight, Android.Resource.Color.HoloOrangeLight, Android.Resource.Color.HoloRedLight);
                SwipeRefreshLayout.Refreshing = true;
                SwipeRefreshLayout.Enabled    = true;
                SwipeRefreshLayout.SetProgressBackgroundColorSchemeColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#424242") : Color.ParseColor("#f7f7f7"));

                SwipeRefreshLayout.SetBackgroundColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#282828") : Color.White);
                MRecycler.SetBackgroundColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#282828") : Color.White);

                TxtCreate            = FindViewById <TextView>(Resource.Id.toolbar_title);
                TxtCreate.Text       = GetString(Resource.String.Lbl_Create);
                TxtCreate.Visibility = ViewStates.Visible;

                MAdView = FindViewById <AdView>(Resource.Id.adView);
                AdsGoogle.InitAdView(MAdView, MRecycler);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        private void InitComponent()
        {
            try
            {
                MRecycler        = (RecyclerView)FindViewById(Resource.Id.recyler);
                EmptyStateLayout = FindViewById <ViewStub>(Resource.Id.viewStub);

                SwipeRefreshLayout = (SwipeRefreshLayout)FindViewById(Resource.Id.swipeRefreshLayout);
                if (SwipeRefreshLayout != null)
                {
                    SwipeRefreshLayout.SetColorSchemeResources(Android.Resource.Color.HoloBlueLight, Android.Resource.Color.HoloGreenLight, Android.Resource.Color.HoloOrangeLight, Android.Resource.Color.HoloRedLight);
                    SwipeRefreshLayout.Refreshing = true;
                    SwipeRefreshLayout.Enabled    = true;
                    SwipeRefreshLayout.SetProgressBackgroundColorSchemeColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#424242") : Color.ParseColor("#f7f7f7"));
                    SwipeRefreshLayout.SetBackgroundColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#282828") : Color.White);
                }

                MAdView = FindViewById <AdView>(Resource.Id.adView);
                AdsGoogle.InitAdView(MAdView, MRecycler);
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
		protected override void OnElementChanged (ElementChangedEventArgs<PullToRefreshContentView> e)
		{
			base.OnElementChanged (e);

			if (refresher != null)
				return;

			refresher = new SwipeRefreshLayout (Xamarin.Forms.Forms.Context);
			refresher.LayoutParameters = new LayoutParams (LayoutParams.MatchParent, LayoutParams.MatchParent);
			refresher.SetColorSchemeResources (Resource.Color.xam_purple);

			refresher.SetOnRefreshListener (this);
			//This gets called when we pull down to refresh to trigger command
			refresher.Refresh += (object sender2, EventArgs e2) => {
				var command = this.Element.RefreshCommand;
				if (command == null)
					return;

				command.Execute (null);
			};

			//HACK as I need to add the sub group to the content group...
			//var text = new Android.Widget.ListView (Xamarin.Forms.Forms.Context);
			//text.LayoutParameters = new LayoutParams (LayoutParams.MatchParent, LayoutParams.MatchParent);
			//text.Text = "Hello world";

			//refresher.AddView (text);

			refresher.SetBackgroundColor (Android.Graphics.Color.Red);
			SetNativeControl (refresher);
		}
        protected override void OnElementChanged(ElementChangedEventArgs <PullToRefreshContentView> e)
        {
            base.OnElementChanged(e);

            if (refresher != null)
            {
                return;
            }

            refresher = new SwipeRefreshLayout(Xamarin.Forms.Forms.Context);
            refresher.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
            refresher.SetColorSchemeResources(Resource.Color.xam_purple);

            refresher.SetOnRefreshListener(this);
            //This gets called when we pull down to refresh to trigger command
            refresher.Refresh += (object sender2, EventArgs e2) => {
                var command = this.Element.RefreshCommand;
                if (command == null)
                {
                    return;
                }

                command.Execute(null);
            };

            //HACK as I need to add the sub group to the content group...
            //var text = new Android.Widget.ListView (Xamarin.Forms.Forms.Context);
            //text.LayoutParameters = new LayoutParams (LayoutParams.MatchParent, LayoutParams.MatchParent);
            //text.Text = "Hello world";

            //refresher.AddView (text);

            refresher.SetBackgroundColor(Android.Graphics.Color.Red);
            SetNativeControl(refresher);
        }
        protected override void OnElementChanged(ElementChangedEventArgs <WebviewContainer> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
                System.Diagnostics.Debug.WriteLine("WebViewRenderer DISPOSE");
            }


            if (e.NewElement != null)
            {
                WebViewer = (e.NewElement as WebviewContainer).WebViewer;

                WebViewer.OnRotate += WebViewer_OnRotate;

                webViewDelegate   = new WebViewDelegate(this);
                webChromeDelegate = new WebChromeDelegate(this);

                Native = new WebView(this.Context);
                Native.SetWebViewClient(webViewDelegate);
                Native.SetWebChromeClient(webChromeDelegate);
                if (Build.VERSION.SdkInt >= BuildVersionCodes.Kitkat)
                {
                    Native.SetLayerType(LayerType.Hardware, null);
                }
                else
                {
                    Native.SetLayerType(LayerType.Software, null);
                }
                Native.Settings.JavaScriptEnabled = true;
                Native.Settings.JavaScriptCanOpenWindowsAutomatically = true;
                Native.Settings.AllowFileAccess   = true;
                Native.Settings.DomStorageEnabled = true;
                Native.Settings.DatabaseEnabled   = true;
                Native.Settings.AllowFileAccess   = true;
                Native.DrawingCacheEnabled        = true;
                Native.Settings.MediaPlaybackRequiresUserGesture = false;
                Native.Settings.LoadWithOverviewMode             = true;
                Native.Settings.UseWideViewPort      = true;
                Native.Settings.BuiltInZoomControls  = false;
                Native.Settings.LoadWithOverviewMode = true;
                //Native.Settings.MixedContentMode = MixedContentHandling.AlwaysAllow;
                Native.ScrollBarStyle         = ScrollbarStyles.OutsideOverlay;
                Native.ScrollbarFadingEnabled = true;
                Native.Settings.SetLayoutAlgorithm(WebSettings.LayoutAlgorithm.SingleColumn);
                Native.Settings.SetAppCacheEnabled(true);
                Native.Settings.SetAppCacheMaxSize(1024 * 1024 * 32);
                Native.Settings.SetAppCachePath(MainActivity.Instance.CacheDir.AbsolutePath);
                Native.Settings.SetGeolocationEnabled(true);
                Native.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);

                WebViewer.BaseUrl = WebViewer.Uri;
                //refreshControl = new CustomRefreshControl(this.Context, Native);
                RefreshControl = new SwipeRefreshLayout(this.Context);
                RefreshControl.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);

                RefreshControl.SetBackgroundColor(Color.Transparent);
                RefreshControl.Refresh += RefreshControlRefresh;
                if (Native.Parent == null)
                {
                    RefreshControl.AddView(Native);
                }
                //RefreshControl.SetDistanceToTriggerSync(50);
                RefreshControl.AddView(new LoadingOverlay(MainActivity.Instance.ApplicationContext, false, WebViewer.Orientation));
                SetNativeControl(RefreshControl);


                if (string.IsNullOrEmpty(homeUrl))
                {
                    homeUrl = WebViewer.Uri;
                }
                WebViewer.PropertyChanged += (sender, ea) =>
                {
                    if (ea.PropertyName == "Action")
                    {
                        switch (WebViewer.Action)
                        {
                        case "GoHome":
                            GoHome(WebViewer.NeedCheckEtag);
                            break;
                        }
                        WebViewer.Action = string.Empty;
                    }
                    else if (ea.PropertyName == "Uri")
                    {
                        LoadUrl();
                    }
                };
                LoadUrl();
            }
        }