コード例 #1
0
        public async void loadTweets()
        {
            var tweets = new List <Status>();

            if (Reachability.IsHostReachable("http://google.com"))
            {
                bearerToken = await searchManager.getTwitterAuthToken();

                tweets = await searchManager.FetchTweetsOnline(bearerToken, 20, "xamarin");
            }
            if (tweets.Count == 0)
            {
                tweets = await searchManager.FetchTweetsOffline();
            }
            if (tweets.Count > 0)
            {
                loadTableView(tweets);
            }
            else
            {
                hud.Hide(animated: true);
                var alert = new UIAlertView("Warning", "Search request failed, Check Internet connectivity and try again", null, "Cancel", "Retry");
                alert.Show();
                alert.Clicked += (sender, e) =>
                {
                    if (e.ButtonIndex == 0)
                    {
                    }
                    else
                    {
                        loadTweets();
                    }
                };
            }
        }
コード例 #2
0
 public override void FinishedLoading(NSUrlConnection connection)
 {
     BeginInvokeOnMainThread(() => {
         hud.CustomView = new UIImageView(UIImage.FromBundle("37x-Checkmark.png"));
     });
     hud.Mode = MBProgressHUDMode.CustomView;
     hud.Hide(true, 2);
 }
コード例 #3
0
        public void ProcessContentSearchRequest(NSNotification obj)
        {
            var hud = new MTMBProgressHUD(View)
            {
                LabelText = "Loading",
                RemoveFromSuperViewOnHide = true
            };

            View.AddSubview(hud);
            hud.Show(animated: true);

            string       keyword = SearchBar.Text;
            SearchResult res     = SearchUtil.Search(AppDataUtil.Instance.GetCurrentPublication().BookId, AppDataUtil.Instance.GetOpendTOC().ID, keyword);

            if (AppDisplayUtil.Instance.ContentSearchResController != null)
            {
                AppDisplayUtil.Instance.ContentSearchResController.View.RemoveFromSuperview();
            }
            AppDisplayUtil.Instance.ContentSearchResController = new ResultViewController(res);
            AppDisplayUtil.Instance.ContentSearchResController.View.TranslatesAutoresizingMaskIntoConstraints = false;
            ContainerView.AddSubview(AppDisplayUtil.Instance.ContentSearchResController.View);
            ContainerView.AddConstraints(new NSLayoutConstraint[] {
                NSLayoutConstraint.Create(AppDisplayUtil.Instance.ContentSearchResController.View, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Top, 1, 0),
                NSLayoutConstraint.Create(AppDisplayUtil.Instance.ContentSearchResController.View, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Bottom, 1, 0),
                NSLayoutConstraint.Create(AppDisplayUtil.Instance.ContentSearchResController.View, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Leading, 1, 0),
                NSLayoutConstraint.Create(AppDisplayUtil.Instance.ContentSearchResController.View, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Trailing, 1, 0)
            });

            hud.Hide(animated: true, delay: 0.2);
        }
コード例 #4
0
        private async void saveRecord()
        {
            UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;

            //Assign user set values back to object, and persist back to cloud
            detailItem.Title       = txtName.Text;
            detailItem.Description = txtDescription.Text;
            detailItem.Quantity    = int.Parse(txtQuantity.Text);

            _hud.Show(animated: true);

            if (!string.IsNullOrEmpty(detailItem.id))
            {
                await GroceryService.UpdateGroceryItemAsync(detailItem);
            }
            else
            {
                await GroceryService.CreateGroceryItemAsync(detailItem);
            }

            _hud.Hide(animated: true, delay: 5);

            UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;

            NavigationController.PopViewControllerAnimated(true);
        }
コード例 #5
0
ファイル: AppDelegate.cs プロジェクト: nvduc2910/homePost
        void ShowWithCustomView()
        {
            // The hud will dispable all input on the view (use the higest view possible in the view hierarchy)
            hud = new MTMBProgressHUD(navController.View);
            navController.View.AddSubview(hud);

            // Set custom view mode
            hud.Mode = MBProgressHUDMode.CustomView;

            // The sample image is based on the work by http://www.pixelpressicons.com, http://creativecommons.org/licenses/by/2.5/ca/
            // Make the customViews 37 by 37 pixels for best results (those are the bounds of the build-in progress indicators)
            hud.CustomView = new UIImageView(UIImage.FromBundle("37x-Checkmark.png"));

            // Regiser for DidHide Event so we can remove it from the window at the right time
            hud.DidHide += HandleDidHide;

            // Add information to your HUD
            hud.LabelText = "Completed";

            // Show the HUD
            hud.Show(true);

            // Hide the HUD after 3 seconds
            hud.Hide(true, 3);
        }
コード例 #6
0
        private async Task ConnectToRelay()
        {
            bool connected = false;

            var waitIndicator = new MTMBProgressHUD(View)
            {
                LabelText                 = "Connecting...",
                DimBackground             = true,
                AnimationType             = MBProgressHUDAnimation.MBProgressHUDAnimationZoomIn,
                Mode                      = MBProgressHUDMode.Indeterminate,
                MinShowTime               = 0,
                RemoveFromSuperViewOnHide = true
            };

            View.AddSubview(waitIndicator);
            waitIndicator.Show(animated: true);

            try
            {
                var prefs = NSUserDefaults.StandardUserDefaults;

                connected = await _remote.Connect(prefs.StringForKey("RelayServerUrl"),
                                                  prefs.StringForKey("RemoteGroup"),
                                                  prefs.StringForKey("HubName"));
            }
            catch (Exception)
            {
            }
            finally
            {
                waitIndicator.Hide(animated: true);
            }

            ShowMessage(connected ? "Connected!" : "Unable to connect");
        }
コード例 #7
0
        void HandleDeviceConnected(object sender, CBPeripheralEventArgs e)
        {
            connectingDialog.Hide(false);

            detailsScreen = Storyboard.InstantiateViewController("DeviceDetailsScreen") as DeviceDetailsScreen;
            detailsScreen.ConnectedPeripheral = e.Peripheral;
            NavigationController.PushViewController(detailsScreen, true);
        }
コード例 #8
0
 public static void HideHUD(this UIViewController vc)
 {
     if (currentHud != null)
     {
         currentHud.Hide(true);
         currentHud.RemoveFromSuperview();
         currentHud = null;
     }
 }
コード例 #9
0
        /// <summary>
        /// This function hide progress view over window.
        /// </summary>
        public static void hideProgressHud()
        {
            if (hud != null)
            {
                hud.Hide(true);
                hud.RemoveFromSuperview();
                hud.Delegate = null;

                hud = null;
            }
        }
コード例 #10
0
        /// <summary>
        /// Shows the toast message.
        /// </summary>
        /// <param name="msg">Message to display.</param>
        public static void showToast(string msg)
        {
            //show message for activation/deactivation hero mode
            MTMBProgressHUD toast = new MTMBProgressHUD(AppDelegate.GetSharedInstance().Window);

            AppDelegate.GetMainWindow().AddSubview(toast);
            toast.Mode = MBProgressHUDMode.Text;
            toast.Show(true);
            toast.DetailsLabelText          = msg;
            toast.RemoveFromSuperViewOnHide = true;
            toast.Hide(true, 1);
        }
コード例 #11
0
        private void Foo()
        {
            var hud = new MTMBProgressHUD(View)
            {
                LabelText = "Waiting...",
                RemoveFromSuperViewOnHide = true
            };

            View.AddSubview(hud);

            hud.Show(animated: true);
            hud.Hide(animated: true, delay: 5);
        }
コード例 #12
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Perform any additional setup after loading the view, typically from a nib.
            ConfigureView();

            txtDescription.EditingDidEnd += HandleEditingDidEnd;
            txtDescription.Delegate       = new CatchEnterDelegate();

            txtQuantity.EditingDidEnd += HandleEditingDidEnd;
            txtQuantity.Delegate       = new CatchEnterDelegate();

            txtName.EditingDidEnd += HandleEditingDidEnd;
            txtName.Delegate       = new CatchEnterDelegate();

            _hud = new MTMBProgressHUD(View)
            {
                LabelText = "Saving...",
                RemoveFromSuperViewOnHide = true
            };

            View.AddSubview(_hud);

            btnSave.TouchUpInside += (object sender, EventArgs e) => {
                //Assign user set values back to object, and persist back to cloud
                detailItem.Title       = txtName.Text;
                detailItem.Description = txtDescription.Text;
                detailItem.Quantity    = int.Parse(txtQuantity.Text);

                _hud.Show(animated: true);

                //Use Task Parallel Library (TPL) to show a status message while the data is saving
                Task.Factory.StartNew(() => {
                    if (!string.IsNullOrEmpty(detailItem.ObjectId))
                    {
                        GroceryService.UpdateGroceryItem(detailItem);
                    }
                    else
                    {
                        GroceryService.CreateGroceryItem(detailItem);
                    }

                    System.Threading.Thread.Sleep(new TimeSpan(0, 0, 5));
                }).ContinueWith((prevTask) => {
                    _hud.Hide(animated: true, delay: 5);
                    NavigationController.PopViewControllerAnimated(true);
                }, TaskScheduler.FromCurrentSynchronizationContext());
            };
        }
コード例 #13
0
ファイル: AppDelegate.cs プロジェクト: nvduc2910/homePost
        void ShowTextOnly()
        {
            // Show the hud on top most view
            hud = MTMBProgressHUD.ShowHUD(this.navController.View, true);

            // Configure for text only and offset down
            hud.Mode      = MBProgressHUDMode.Text;
            hud.LabelText = "Some message...";
            hud.Margin    = 10f;
            hud.YOffset   = 150f;
            hud.RemoveFromSuperViewOnHide = true;

            hud.Hide(true, 3);
        }
コード例 #14
0
        public static void ShowSimpleHUD(this UIViewController vc, string message)
        {
            vc.HideHUD();

            var hud = new MTMBProgressHUD(vc.NavigationController.View)
            {
                LabelText = message,
                Mode      = MBProgressHUDMode.Text,
                RemoveFromSuperViewOnHide = true
            };

            vc.NavigationController.View.AddSubview(hud);
            hud.Show(true);
            hud.Hide(true, 1.5);
        }
コード例 #15
0
        private void ShowMessage(string message)
        {
            var hud = new MTMBProgressHUD(View)
            {
                DetailsLabelText          = message,
                RemoveFromSuperViewOnHide = true,
                DimBackground             = false,
                AnimationType             = MBProgressHUDAnimation.MBProgressHUDAnimationZoomIn,
                Mode = MBProgressHUDMode.Text
            };

            View.AddSubview(hud);

            hud.Show(animated: true);
            hud.Hide(animated: true, delay: 1.5);
        }
コード例 #16
0
        /// <summary>
        /// refresh the publication list which displayed in scroll view
        /// invoked when user delete or sorting publication
        /// </summary>
        public void ReloadPublicationList()
        {
            var hud = new MTMBProgressHUD(View)
            {
                LabelText = "Loading",
                RemoveFromSuperViewOnHide = true
            };

            View.AddSubview(hud);
            hud.Show(animated: true);


            UpdatePublicationViewList();
            ShowPublicationViews();

            hud.Hide(animated: true, delay: 0.2);
        }
コード例 #17
0
    public async Task LoginButton_click(UIButton sender)
    {
        hud = new MTMBProgressHUD(View)
        {
            LabelText = "Waiting...",
            RemoveFromSuperViewOnHide = true,
        };

        View.AddSubview(hud);
        hud.Show(animated: true);


        APIClient ApiClient   = new APIClient();
        TestAPI   cd          = new TestAPI(ApiClient);
        var       apiResponse = await cd.ExecuteAsync <YourType>();

        hud.Hide(animated: true);
    }
コード例 #18
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _MainSection = new Section()
            {
                new ActivityElement()
            };
            Root = new RootElement("Markers")
            {
                _MainSection
            };

            // Simple demo of a progress HUD. Doesn't actually do anything useful.
            // Added after question from audience.
            MTMBProgressHUD progress = new MTMBProgressHUD()
            {
                DimBackground = true,
                LabelText     = "Doing something.",
            };

            View.Add(progress);
            progress.Show(animated: true);
            Task.Factory.StartNew(() => {
                Thread.Sleep(2000);
                InvokeOnMainThread(() => {
                    progress.Hide(animated: true);
                });
            });

            mapController = new MapViewController();
            mapController.NewMarkerCreated += (object sender, MarkerAddedEventArgs e) => {
                InvokeOnMainThread(() => {
                    _Database.SaveMarker(e.MarkerInfo);
                    RefreshMarkers();
                });
            };
            RefreshMarkers();
        }
コード例 #19
0
        public async override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            var hud = new MTMBProgressHUD(View)
            {
                LabelText = "Loading",
                RemoveFromSuperViewOnHide = true
            };

            View.AddSubview(hud);
            hud.Show(animated: true);
            hud.Hide(animated: true, delay: 0.5);

            var onlinePublicationList = await  GetLatestPublicationList();

            if (onlinePublicationList != null)
            {
                publicationList = onlinePublicationList;
                UpdatePublicationViewList();
                ShowPublicationViews();
            }
        }
コード例 #20
0
 public void Hide()
 {
     _hud.Hide(true);
     _hud.RemoveFromSuperview();
 }
コード例 #21
0
        /// <summary>
        /// Update when content which are going to to be displayed changed
        /// </summary>
        /// <param name="s">S.</param>
        public async void Update(Subject s)
        {
            var hud = new MTMBProgressHUD(View)
            {
                LabelText = "Loading",
                RemoveFromSuperViewOnHide = true
            };

            View.AddSubview(hud);
            hud.Show(animated: true);


            OpenedPublication pcs = (OpenedPublication)s;

            ContentNavigationBar.PopNavigationItem(false);

            string content = "";

            string htmlFilePath = NSBundle.MainBundle.PathForResource("Html/htmlDoc", "html");
            string htmlStr      = File.ReadAllText(htmlFilePath);
            NSUrl  url          = new NSUrl(htmlFilePath);

            if (pcs.OpendContentType == PublicationContentTypeEnum.TOC)
            {
                if (await PageSearchUtil.Instance.IsPBO(AppDataUtil.Instance.GetCurrentPublication().BookId))
                {
                    GotoBarButton.Hidden = false;
                    PageNumLabel.Hidden  = false;
                }
                ContentNavigationBar.PushNavigationItem(ContentNavigationItem, false);
                content = await PublicationContentUtil.Instance.GetContentFromTOC(pcs.P.BookId, pcs.OpendTOCNode);

                content = string.Format("<div data-tocid='{0}' data-toctitle='{1}' class='page_container'>{2}</div>", pcs.OpendTOCNode.ID, pcs.OpendTOCNode.Title, content);
                ContentNavigationItem.LeftBarButtonItems [1].Enabled = AppDataUtil.Instance.CanBack() == true;
                ContentNavigationItem.LeftBarButtonItems [2].Enabled = AppDataUtil.Instance.CanForward() == true;

                TOCNode nextPageNode = AppDataUtil.Instance.GetNextOfTOCNodeWithId(pcs.OpendTOCNode.ID, "next");
                if (nextPageNode != null)
                {
                    htmlStr = htmlStr.Replace("#NEXT_PAGE_TITLE#", nextPageNode.Title).Replace("#NEXT_PAGE_TOCID#", nextPageNode.ID.ToString());
                }
                else
                {
                    htmlStr = htmlStr.Replace("#NEXT_PAGE_TITLE#", "You are on the end.").Replace("#NEXT_PAGE_TOCID#", "-1");                      //"-1" here means no next page any more
                }

                TOCNode previousPageNode = AppDataUtil.Instance.GetNextOfTOCNodeWithId(pcs.OpendTOCNode.ID, "previous");
                if (previousPageNode != null)
                {
                    htmlStr = htmlStr.Replace("#PREVIOUS_PAGE_TITLE#", previousPageNode.Title).Replace("#PREVIOUS_PAGE_TOCID#", previousPageNode.ID.ToString());
                }
                else
                {
                    htmlStr = htmlStr.Replace("#PREVIOUS_PAGE_TITLE#", "You are on the begining.").Replace("#PREVIOUS_PAGE_TOCID#", "-1");                      //"-1" here means no next page any more
                }

                htmlStr = htmlStr.Replace("#PLACE_HOLDER_HIGHLIGHTED_TOCID#", pcs.OpendTOCNode.ID.ToString());
                htmlStr = htmlStr.Replace("#PLACE_HOLDER_HIGHLIGHTED_KEYWORD#", AppDataUtil.Instance.HighlightSearchKeyword);
                AppDataUtil.Instance.HighlightSearchKeyword = "";                //

                htmlStr = htmlStr.Replace("#PLACE_HOLDER_SCROLL_SCRIPT#", "<script type='text/javascript' src='./JS/infinitescroll.js'></script>");

                //When jump to content from index by click content link, selected index of tab bar supposed to be changed to "Contents"
                NSNotificationCenter.DefaultCenter.PostNotificationName("ChangeContentTabBarSelectedIndex", this, new NSDictionary());                 //Suppose to be handled by ContentLeftTabBarController
            }
            else if (pcs.OpendContentType == PublicationContentTypeEnum.Index)
            {
                //TODO,
                GotoBarButton.Hidden = true;
                PageNumLabel.Hidden  = true;
                ContentNavigationBar.PushNavigationItem(IndexNavigationItem, false);
                if (pcs.OpendIndex == null)
                {
                    IndexNavigationItem.LeftBarButtonItem.Title = "";
                    content = "<div class='nocontent'><span>No Index Files Available</span><div>";
                }
                else
                {
                    IndexNavigationItem.LeftBarButtonItem.Title = pcs.OpendIndex.Title [0].ToString();
                    content = await PublicationContentUtil.Instance.GetContentFromIndex(pcs.P.BookId, pcs.OpendIndex);

                    content = string.Format("<div class='page_container'>{0}</div>", content);

                    //Scroll to selected index
                    var scrollToSelectedIndexJS = "(function(){if($(\".main\").first().data(\"filename\") != '" + pcs.OpendIndex.FileName + "'){$(window).scrollTo($(\".main[data-filename='" + pcs.OpendIndex.FileName + "']\"), 300);}})();";
                    htmlStr = htmlStr.Replace("#DOCUMENT_READY_SCRIPT#", scrollToSelectedIndexJS);
                }
                htmlStr = htmlStr.Replace("#PLACE_HOLDER_SCROLL_SCRIPT#", "");
            }
            else if (pcs.OpendContentType == PublicationContentTypeEnum.Annotation)
            {
                //TODO
                GotoBarButton.Hidden = true;
                PageNumLabel.Hidden  = true;
                htmlStr = htmlStr.Replace("#PLACE_HOLDER_SCROLL_SCRIPT#", "");
                content = "<div class='nocontent'><span>You have no annotations, highlight text in your publications to add one</span><div>";
            }
            if (content != null)
            {
                float defaultFontSize = SettingsUtil.Instance.GetFontSize() > 0 ? SettingsUtil.Instance.GetFontSize() : 14;
                htmlStr = htmlStr.Replace("#PLACEHOLDER_DEFAULT_FONT_SIZE#", "" + defaultFontSize);
                htmlStr = htmlStr.Replace("#PLACE_HOLDER_SCROLL_TO_ID#", AppDataUtil.Instance.ScrollToHtmlTagId);
                htmlStr = htmlStr.Replace("#PLACE_HOLDER_HIGHLIGHTED_KEYWORD#", AppDataUtil.Instance.HighlightSearchKeyword);
                content = ContentFormatUtil.Format(content);
                content = Regex.Replace(content, @"<td />", "");
                content = Regex.Replace(content, @"<div[^/^>]*?/>", "");

                htmlStr = htmlStr.Replace("#CONTENT#", content);
                ContentWebView.LoadHtmlString(htmlStr, url);
            }
            hud.Hide(animated: true, delay: 0.2);
        }
コード例 #22
0
 public static void HideProgress()
 {
     hud.Hide(animated: true);
 }
コード例 #23
0
 public void Dispose()
 {
     _hud.Hide(true);
 }
コード例 #24
0
        async partial void SendResetPasswordRequest(Foundation.NSObject sender)
        {
            var hud = new MTMBProgressHUD(View)
            {
                LabelText = "Loading",
                RemoveFromSuperViewOnHide = true
            };

            View.AddSubview(hud);
            hud.Show(animated: true);

            var    selectedRegion = regions.Find(o => o.CountryName == RegionNameTextField.Text);
            string regionCode     = selectedRegion == null ? "": selectedRegion.CountryCode;

            var resetPasswordResponse = await LoginUtil.Instance.ResetPassword(EmailTextField.Text, regionCode);


            //TODO, I18N, code refactor
            string errorMessage = "";

            switch (resetPasswordResponse)
            {
            case PasswordResetEnum.EmailNotExist:
                errorMessage = "Email address does not exist.";
                break;

            case PasswordResetEnum.InvalidEmail:
                errorMessage = "Enter valid email address";
                break;

            case PasswordResetEnum.DeviceIdNotMatched:
                errorMessage = "Device id is not mapped to the email address provided.";
                break;

            case PasswordResetEnum.NetDisconnected:
                errorMessage = "Unable to communicate with LexisNexis Red services. Please ensure you have an internet connection, or try again later as the servers may be busy.";
                break;

            case PasswordResetEnum.ResetFailure:
                errorMessage = "Failed to reset password.";
                break;

            case PasswordResetEnum.SelectCountry:
                errorMessage = "Please select a country.";
                break;

            case PasswordResetEnum.ResetSuccess:
                break;

            default:
                errorMessage = "Reset password failed, unknow error.";
                break;
            }


            var alertTitle = "";
            var alertMsg   = "";

            if (errorMessage.Equals(""))
            {
                alertTitle = "Done";
                alertMsg   = "Your password reset request has been sent.";
            }
            else
            {
                alertTitle = resetPasswordResponse == PasswordResetEnum.NetDisconnected ? "Server Error" : "Error!!";
                alertMsg   = errorMessage;
            }
            var resetPasswordAlert = UIAlertController.Create(alertTitle, alertMsg, UIAlertControllerStyle.Alert);

            if (errorMessage.Equals(""))
            {
                resetPasswordAlert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Cancel, Action => DismissResetSuccessAlertView()));
            }
            else
            {
                resetPasswordAlert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Cancel, null));
            }
            PresentViewController(resetPasswordAlert, true, null);

            hud.Hide(animated: true, delay: 1);
        }
コード例 #25
0
        private async void SendLoginRequest()
        {
            var hud = new MTMBProgressHUD(View)
            {
                LabelText = "Loading",
                RemoveFromSuperViewOnHide = true
            };

            hud.YOffset = 90.0f;
            View.AddSubview(hud);
            hud.Show(animated: true);

            //invoke login business logic
            var    selectedRegion = regions.Find(o => o.CountryName == selectedRegionTextField.Text);
            string regionCode     = selectedRegion == null ? "": selectedRegion.CountryCode;

            var loginResponse = await SignIn(emailTextField.Text, passwordTextField.Text, regionCode);

            string alertTitle = "";
            string alertMsg   = "";

            switch (loginResponse)
            {
            case LoginStatusEnum.LoginSuccess:
                hud.Hide(animated: true, delay: 1);
                var curUser = GlobalAccess.Instance.CurrentUserInfo;
                if (curUser.NeedChangePassword)
                {
                    ChangePasswordController changePasswordVC = new ChangePasswordController();
                    UINavigationController   navController    = new UINavigationController(changePasswordVC);
                    navController.ModalPresentationStyle = UIModalPresentationStyle.FormSheet;
                    PresentViewController(navController, true, null);
                }
                else
                {
                    NavigationController.PopViewController(false);
                    AppDisplayUtil.Instance.AppDelegateInstance.LoginInterceptorVC.GoToMyPublicationViewController();
                }
                break;

            case LoginStatusEnum.EmptyEmailAndEmptyPwd:
            case LoginStatusEnum.EmptyemailAndValidPwd:
            case LoginStatusEnum.EmptyemailAndInvalidPwd:
                alertTitle = "Login Failed";
                alertMsg   = "Please enter your email address to login.";
                break;

            case LoginStatusEnum.InvalidemailAndEmptyPwd:
            case LoginStatusEnum.ValidemailAndEmptyPwd:
                alertTitle = "Login Failed";
                alertMsg   = "Please enter your password to login.";
                break;

            case LoginStatusEnum.SelectCountry:
                alertTitle = "Login Failed";
                alertMsg   = "Please select a country to login.";
                break;

            case LoginStatusEnum.InvalidemailAndInvalidPwd:
            case LoginStatusEnum.InvalidemailAndValidPwd:
            case LoginStatusEnum.ValidemailAndInvalidPwd:
            case LoginStatusEnum.EmailOrPwdError:
                alertTitle = "Login Failed";
                alertMsg   = "Either the email or password you entered is incorrect. Please try again.";
                break;

            case LoginStatusEnum.AccountNotExist:
                alertTitle = "Login Failed";
                alertMsg   = "Email address does not exist.";
                break;

            case LoginStatusEnum.DeviceLimit:
                alertTitle = "Login Failed";
                alertMsg   = "Exceed device limition";
                break;

            case LoginStatusEnum.NetDisconnected:
                alertTitle = "Server Error";
                alertMsg   = "Unable to communicate with LexisNexis Red services. Please ensure you have an internet connection, or try again later as the servers may be busy.";
                break;
            }


            if (alertMsg != "")
            {
                var loginAlert = UIAlertController.Create(alertTitle, alertMsg, UIAlertControllerStyle.Alert);
                loginAlert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                PresentViewController(loginAlert, true, null);
            }

            hud.Hide(animated: true, delay: 1);
        }
コード例 #26
0
 public void HideLoading()
 {
     progressDialog?.Hide(true);
     progressDialog?.RemoveFromSuperview();
     progressDialog = null;
 }
コード例 #27
0
 public void HideHud()
 {
     Hud?.Hide(true);
 }
コード例 #28
0
 private void HideProgress()
 {
     hud.Hide(true);
     hud = null;
 }
コード例 #29
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = "Keyboard and UITextField";

            #region WebView

            webView.ShouldStartLoad =
                delegate(UIWebView webView,
                         NSUrlRequest request,
                         UIWebViewNavigationType navigationType) {
                var requestString = request.Url.AbsoluteString;

                if (requestString.StartsWith("liddle://", StringComparison.CurrentCultureIgnoreCase))
                {
                    var components = requestString.Split(new[] { @"://" }, StringSplitOptions.None);

                    if (components.Length > 1 && components [0].ToLower() == @"liddle".ToLower() && components [1] == @"Hi")
                    {
                        UIAlertController alert = UIAlertController.Create(@"Hi Title", @"當然是世界好", UIAlertControllerStyle.Alert);


                        UIAlertAction okAction = UIAlertAction.Create(@"OK", UIAlertActionStyle.Default, (action) => {
                            Console.WriteLine(@"OK");
                        });
                        alert.AddAction(okAction);


                        UIAlertAction cancelAction = UIAlertAction.Create(@"Cancel", UIAlertActionStyle.Default, (action) => {
                            Console.WriteLine(@"Cancel");
                        });
                        alert.AddAction(cancelAction);

                        PresentViewController(alert, true, null);


                        return(false);
                    }
                }

                return(true);
            };

            webView.LoadFinished += (object sender, EventArgs e) => {
                InvokeOnMainThread(() => {
                    _hud.Hide(animated: true, delay: 5);
                });


                if (txtUrl.IsFirstResponder)
                {
                    txtUrl.ResignFirstResponder();
                }
            };

            webView.LoadError += (object sender, UIWebErrorArgs e) => {
                Debug.WriteLine(e.Error.LocalizedDescription);

                InvokeOnMainThread(() => {
                    _hud.Hide(animated: true, delay: 5);
                });

                if (txtUrl.IsFirstResponder)
                {
                    txtUrl.ResignFirstResponder();
                }
            };

            #endregion

            #region UITextField

            txtUrl.Placeholder     = @"請輸入網址";
            txtUrl.KeyboardType    = UIKeyboardType.Url;
            txtUrl.SecureTextEntry = false;

            // return true ;
            txtUrl.ShouldReturn += (textField) => {
                if (textField.IsFirstResponder)
                {
                    textField.ResignFirstResponder();
                    // v.s.
                    //textField.BecomeFirstResponder();
                }

                return(true);
            };

            // return true ;
            txtUrl.ShouldChangeCharacters = (textField, range, replacementString) => {
                return(true);

                /*
                 * var newLength = textField.Text.Length + replacementString.Length - range.Length;
                 * return newLength <= 25;
                 */
            };

            txtUrl.EditingDidBegin += (object sender, EventArgs e) => {
                if (sender is UITextField)
                {
                }
            };

            txtUrl.EditingDidEnd += (object sender, EventArgs e) => {
                // Compare with "webView.LoadFinished"
                if (txtUrl.IsFirstResponder)
                {
                    txtUrl.ResignFirstResponder();
                }
            };

            #endregion

            btnGo.TouchUpInside += (object sender, EventArgs e) => {
                InvokeOnMainThread(() => {
                    if (txtUrl.IsFirstResponder)
                    {
                        txtUrl.ResignFirstResponder();
                    }
                });

                string urlString = txtUrl.Text.Trim();

                var alertController = UIAlertController.Create("網址", urlString, UIAlertControllerStyle.Alert);

                var acceptAction = UIAlertAction.Create("確認", UIAlertActionStyle.Default, (action) => {
                    InvokeOnMainThread(() => {
                        _hud = new MTMBProgressHUD(View)
                        {
                            LabelText = "Waiting...",
                            RemoveFromSuperViewOnHide = true
                        };

                        View.AddSubview(_hud);
                        _hud.Show(animated: true);
                    });

                    webView.LoadRequest(new NSUrlRequest(new NSUrl(urlString)));
                });

                var cancelAction = UIAlertAction.Create("取消", UIAlertActionStyle.Cancel, (action) => {
                });

                // Add the actions.
                alertController.AddAction(acceptAction);
                alertController.AddAction(cancelAction);

                InvokeOnMainThread(() => {
                    PresentViewController(alertController, true, null);
                });
            };


            UITapGestureRecognizer tapGestureRecognizer = new UITapGestureRecognizer(() => {
                if (txtUrl.IsFirstResponder)
                {
                    txtUrl.ResignFirstResponder();
                }
            });
            this.View.AddGestureRecognizer(tapGestureRecognizer);


            UIKeyboard.Notifications.ObserveWillChangeFrame((sender, e) => {
                var beginRect = e.FrameBegin;
                var endRect   = e.FrameEnd;

                Debug.WriteLine($"ObserveWillChangeFrame endRect:{endRect.Height}");

                txtUrlBottomConstraint.Constant = endRect.Height + 5;
            });


            UIKeyboard.Notifications.ObserveDidChangeFrame((sender, e) => {
                var beginRect = e.FrameBegin;
                var endRect   = e.FrameEnd;

                Debug.WriteLine($"ObserveDidChangeFrameendRect:{endRect.Height}");

                //txtUrlBottomConstraint.Constant = endRect.Height + 5;
            });
        }