Пример #1
0
        public override void ViewWillAppear(bool animated)
        {
            try
            {
                base.ViewWillAppear(animated);

                SetSexChoice();
                Email.Text        = Session.Email;
                Username.Text     = Session.Username;
                Name.Text         = Session.Name;
                rc.uploadedImages = new List <string>(Session.Pictures);

                int i;
                for (i = ImagesUploaded.Subviews.Length - 1; i >= 0; i--)
                {
                    ImagesUploaded.Subviews[i].RemoveFromSuperview();
                }
                ImagesUploaded.RefitImagesContainer();

                i = 0;
                foreach (string image in rc.uploadedImages)
                {
                    ImagesUploaded.AddPicture(image, i);
                    i++;
                }

                if (rc.uploadedImages.Count > 1)
                {
                    ImagesProgressText.Text = LangEnglish.ImagesRearrange;
                }
                else
                {
                    ImagesProgressText.Text = "";
                }

                //works only if activity is resuming. It is recreated when pressing cancel and coming here again. Can it happen?
                if (rc.imagesUploading)
                {
                    rc.StartAnim();
                }

                DescriptionText.Text = Session.Description;

                UseLocationSwitch.On = (bool)Session.UseLocation;
                rc.EnableLocationSwitches((bool)Session.UseLocation);
                rc.SetLocationShareLevel((byte)Session.LocationShare);
                rc.SetDistanceShareLevel((byte)Session.DistanceShare);

                if ((bool)Session.ActiveAccount)
                {
                    DeactivateAccount.SetTitle(LangEnglish.DeactivateAccount, UIControlState.Normal);
                }
                else
                {
                    DeactivateAccount.SetTitle(LangEnglish.ActivateAccount, UIControlState.Normal);
                }
            }
            catch (Exception ex)
            {
                c.ReportErrorSilent(ex.Message + Environment.NewLine + ex.StackTrace);
            }
        }
Пример #2
0
        public async override void ViewWillAppear(bool animated)
        {
            try
            {
                base.ViewWillAppear(animated);

                if (!(ListActivity.listProfiles is null))
                {
                    ListActivity.listProfiles.Clear();
                    ListActivity.totalResultCount = null;
                }

                Session.LastDataRefresh = null;
                Session.LocationTime    = null;

                registerCompleted = false;

                if (File.Exists(regSaveFile))
                {
                    string[] arr = File.ReadAllLines(regSaveFile);
                    Sex.Select(int.Parse(arr[0]), 0, false);
                    Email.Text           = arr[1];
                    Password.Text        = arr[2];
                    ConfirmPassword.Text = arr[3];
                    Username.Text        = arr[4];
                    Name.Text            = arr[5];
                    if (arr[6] != "") //it would give one element
                    {
                        string[] images = arr[6].Split("|");
                        rc.uploadedImages = new List <string>(images);
                    }
                    else
                    {
                        rc.uploadedImages = new List <string>();
                    }

                    int i;
                    for (i = ImagesUploaded.Subviews.Length - 1; i >= 0; i--)
                    {
                        ImagesUploaded.Subviews[i].RemoveFromSuperview();
                    }
                    ImagesUploaded.RefitImagesContainer();
                    //ImagesUploaded.drawOrder = new List<int>();

                    i = 0;
                    foreach (string image in rc.uploadedImages)
                    {
                        ImagesUploaded.AddPicture(image, i);
                        i++;
                    }

                    if (rc.uploadedImages.Count > 1)
                    {
                        ImagesProgressText.Text = LangEnglish.ImagesRearrange;
                    }
                    else
                    {
                        ImagesProgressText.Text = "";
                    }

                    //works only if activity is resuming. It is recreaed when pressing cancel and coming here again.
                    if (rc.imagesUploading)
                    {
                        rc.StartAnim();
                    }

                    DescriptionText.Text = arr[7].Replace("[newline]", "\n");

                    UseLocationSwitch.On = bool.Parse(arr[8]);
                    rc.EnableLocationSwitches(UseLocationSwitch.On);
                    rc.SetLocationShareLevel(byte.Parse(arr[9]));
                    rc.SetDistanceShareLevel(byte.Parse(arr[10]));
                }
                else //in case we are stepping back from a successful registration
                {
                    ResetForm();
                }

                string responseString = await c.MakeRequest("action=eula"); //deleting images from server

                if (responseString.Substring(0, 2) == "OK")
                {
                    NSError error      = null;
                    string  s          = "<span style=\"font-family: '-apple-system', 'HelveticaNeue'; font-size: 12px\">" + responseString.Substring(3) + "</span>";
                    var     htmlString = new NSAttributedString(s, new NSAttributedStringDocumentAttributes {
                        DocumentType = NSDocumentType.HTML
                    }, ref error);
                    EulaText.AttributedText = htmlString;
                    EulaText.TextColor      = UIColor.FromName("PrimaryDark");
                }
                else
                {
                    c.ReportError(responseString);
                }
            }
            catch (Exception ex)
            {
                c.ReportErrorSilent(ex.Message + Environment.NewLine + ex.StackTrace);
            }
        }