Esempio n. 1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            setstyle();
            if (modeSearch == true)
            {
                sourcePos      = new sourceSecondCategory(null, lstSearch);
                tblMain.Source = sourcePos;
                tblMain.ReloadData();
                setLoadingViewStyle(this.tblMain);
            }
            else
            {
                //starthud ();
                reloading = true;
                var indicator = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.White);
                this.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(indicator);
                indicator.StartAnimating();
                ThreadPool.QueueUserWorkItem(state =>
                {
                    lst = new Mainiportogruaropos().getPost(cat_id, true);
                    //var lst = new iportogruaroLibraryShared.subCategorys().getSubCategorys(cat_id,true);

                    InvokeOnMainThread(delegate {
                        tblMain.Source = new sourcePosItemsCustom(this, lst);
                        tblMain.ReloadData();
                        setLoadingViewStyle(this.tblMain);
                        reloading = false;
                        this.NavigationItem.LeftBarButtonItem = null;
                        //stophud();
                    }
                                       );
                });
            }
        }
Esempio n. 2
0
        public void loadDataServer()
        {
            if (!InternetConnection.IsNetworkAvaialable(true))
            {
                using (var alert = new UIAlertView("iPortogruaro", "Spiacente nessun collegamento internet al momento", null, "OK", null)) {//Viajes Telcel//Aceptar
                    alert.Show();
                }

                return;
            }

            if (reloading)
            {
                return;
            }

            reloading = true;

            UIView.BeginAnimations("slideAnimation");

            UIView.SetAnimationDuration(2);
            UIView.SetAnimationCurve(UIViewAnimationCurve.EaseInOut);
            UIView.SetAnimationRepeatCount(2);
            UIView.SetAnimationRepeatAutoreverses(true);
            this.tblMain.ContentInset = UIEdgeInsets.Zero;
            UIView.CommitAnimations();

            /*
             *  [UIView beginAnimations:nil context:NULL];
             *  [UIView setAnimationDuration:.3];
             *  [tblMain setContentInset:UIEdgeInsetsMake(0.0f, 0.0f, 0.0f, 0.0f)];
             *  [refreshHeaderView setStatus:kPullToReloadStatus];
             *  [refreshHeaderView toggleActivityView:NO];
             *  [UIView commitAnimations];
             */
            if (modeSearch == true)
            {
                sourcePos      = new sourceSecondCategory(null, lstSearch);
                tblMain.Source = sourcePos;
                tblMain.ReloadData();
                setLoadingViewStyle(this.tblMain);
            }
            else
            {
                var indicator = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.White);
                this.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(indicator);
                indicator.StartAnimating();
                starthud();
                NSUserDefaults.StandardUserDefaults.SetInt(1, "pulltoRefresh");
                ThreadPool.QueueUserWorkItem(state =>
                {
                    lst = new Mainiportogruaropos().getPost(cat_id, false);

                    if (lst == null)
                    {
                        InvokeOnMainThread(delegate {
                            using (var alert = new UIAlertView("iPortogruaro", "Impossibile ricevere gli aggiornamenti dal server remoto", null, "OK", null))//Viajes Telcel//Aceptar
                            {
                                alert.Show();
                            }
                        }
                                           );
                    }

                    if (lst.Count <= 0)
                    {
                        InvokeOnMainThread(delegate {
                            using (var alert = new UIAlertView("iPortogruaro", "Impossibile ricevere gli aggiornamenti dal server remoto", null, "OK", null))//Viajes Telcel//Aceptar
                            {
                                alert.Show();
                            }
                        }
                                           );
                    }

                    if (lst[0].poi_id == "0")
                    {
                        InvokeOnMainThread(delegate {
                            using (var alert = new UIAlertView("iPortogruaro", "Impossibile ricevere gli aggiornamenti dal server remoto", null, "OK", null))//Viajes Telcel//Aceptar
                            {
                                alert.Show();
                            }
                        }
                                           );
                    }

                    InvokeOnMainThread(delegate {
                        tblMain.Source = new sourcePosItemsCustom(this, lst);
                        tblMain.ReloadData();
                        setLoadingViewStyle(this.tblMain);
                        this.NavigationItem.LeftBarButtonItem = null;
                        stophud();
                        reloading = false;
                    }
                                       );
                });
            }
            foreach (UIView vin in vLoading)
            {
                vin.RemoveFromSuperview();
                vin.Dispose();
            }
            vLoading.RemoveFromSuperview();
            vLoading.Dispose();
            vLoading = null;
            //startHud();
            //}
        }