Exemple #1
0
                void GetAdditionalGroups( )
                {
                    if (RetrievingGroups == false)
                    {
                        RetrievingGroups = true;

                        BlockerView.Show(delegate
                        {
                            GroupFinder.GetGroups(GroupTypeId, StreetValue, CityValue, StateValue, ZipValue, CurrGroupIndex, NumRequestedGroups,
                                                  delegate(MobileAppApi.GroupSearchResult sourceLocation, List <MobileAppApi.GroupSearchResult> groupEntries, bool result)
                            {
                                BlockerView.Hide(delegate
                                {
                                    RetrievingGroups = false;

                                    // for additional groups, only take action if we got something back.
                                    if (result)
                                    {
                                        // increment our index to the next set, or the end of the list, whichever is less
                                        // this will ensure when we hit the end of the list, CurrGroupIndex reflects that.
                                        CurrGroupIndex += Math.Min(groupEntries.Count, NumRequestedGroups);

                                        GroupEntries.AddRange(groupEntries);

                                        UpdateMap(true);
                                    }
                                });
                            });
                        });
                    }
                }
Exemple #2
0
        void RetrieveBiblePassage( )
        {
            ResultView.Hide( );

            BlockerView.Show(delegate
            {
                RequestingBiblePassage = true;

                BibleRenderer.RetrieveBiblePassage(BibleAddress, delegate(string htmlStream)
                {
                    // if it worked, take the html stream and store it
                    if (string.IsNullOrWhiteSpace(htmlStream) == false)
                    {
                        PassageHTML = htmlStream;
                        BibleWebView.LoadHtmlString(PassageHTML, NSBundle.MainBundle.BundleUrl);
                    }
                    else
                    {
                        // otherwise display an error
                        ResultView.Show(GeneralStrings.Network_Status_FailedText,
                                        PrivateControlStylingConfig.Result_Symbol_Failed,
                                        GeneralStrings.Network_Result_FailedText,
                                        GeneralStrings.Retry);
                    }

                    RequestingBiblePassage = false;
                    BlockerView.Hide(null);
                });
            });
        }
        void SubmitPrayerRequest( )
        {
            ResultView.Show(PrayerStrings.PostPrayer_Status_Submitting,
                            "",
                            "",
                            "");

            Success = false;
            Posting = true;

            // hide the toolbar while submitting
            if (Task != null)
            {
                Task.NavToolbar.Reveal(false);
            }

            // fade in our blocker, and when it's complete, send our request off
            BlockerView.Show(delegate
            {
                // sleep this thread for a second to give an appearance of submission
                System.Threading.Thread.Sleep(1000);

                // submit the request
                RockApi.Post_PrayerRequests(PrayerRequest, delegate(System.Net.HttpStatusCode statusCode, string statusDescription)
                {
                    Posting = false;

                    // if they left while posting, screw em.
                    if (IsActive == true)
                    {
                        BlockerView.Hide(null);

                        // show the toolbar for them.
                        Task.NavToolbar.Reveal(true);

                        if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode))
                        {
                            Success = true;

                            ResultView.Show(PrayerStrings.PostPrayer_Status_SuccessText,
                                            PrivateControlStylingConfig.Result_Symbol_Success,
                                            PrayerStrings.PostPrayer_Result_SuccessText,
                                            GeneralStrings.Done);

                            PrayerAnalytic.Instance.Trigger(PrayerAnalytic.Create);
                        }
                        else
                        {
                            Success = false;

                            ResultView.Show(PrayerStrings.PostPrayer_Status_FailedText,
                                            PrivateControlStylingConfig.Result_Symbol_Failed,
                                            PrayerStrings.PostPrayer_Result_FailedText,
                                            GeneralStrings.Retry);
                        }
                    }
                });
            });
        }
Exemple #4
0
        void DownloadRockValues( )
        {
            // only let them submit if they have something beyond "http://" (or some other short crap)
            if (RockUrlField.Text.IsValidURL( ) == true)
            {
                // hide the keyboard
                RockUrlField.ResignFirstResponder( );

                // disable until we're done
                Sync.Enabled = false;
                ToggleSaveButton(false);

                BlockerView.BringToFront( );
                BlockerView.Show(delegate
                {
                    // see if Rock is AT this server.
                    ApplicationApi.IsRockAtURL(RockUrlField.Text,
                                               delegate(System.Net.HttpStatusCode statusCode, string statusDescription)
                    {
                        if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode))
                        {
                            // attempt to contact Rock and get all the required information.
                            Config.Instance.TryBindToRockServer(RockUrlField.Text, RockAuthKeyField.Text,
                                                                delegate(bool result)
                            {
                                // it worked, so Rock is valid.
                                if (result == true)
                                {
                                    ConfigurationTemplates = Config.Instance.TempConfigurationTemplates;
                                    Campuses = Config.Instance.TempCampuses;
                                    HandleDownloadResult(Strings.General_RockBindSuccess);
                                }
                                else
                                {
                                    // error - clear the lists
                                    ClearLists( );

                                    HandleDownloadResult(Strings.General_RockBindError_Data);
                                }
                            });
                        }
                        else
                        {
                            BlockerView.Hide(
                                delegate
                            {
                                // error - clear the lists
                                ClearLists( );

                                HandleDownloadResult(Strings.General_RockBindError_NotFound);
                            });
                        }
                    });
                });
            }
        }
Exemple #5
0
        void RegisterUser()
        {
            if (State == RegisterState.None)
            {
                // make sure they entered all required fields
                if (ValidateInput( ))
                {
                    BlockerView.Show(
                        delegate
                    {
                        // force the UI to scroll back up
                        ScrollView.ContentOffset = CGPoint.Empty;
                        ScrollView.ScrollEnabled = false;

                        State = RegisterState.Trying;

                        // create a new user and submit them
                        Rock.Client.Person newPerson = new Rock.Client.Person();

                        // copy all the edited fields into the person object
                        newPerson.Email = EmailText.Field.Text;

                        // set both the nick name and first name to NickName
                        newPerson.NickName  = NickNameText.Field.Text;
                        newPerson.FirstName = NickNameText.Field.Text;

                        newPerson.LastName = LastNameText.Field.Text;

                        MobileAppApi.RegisterNewUser(UserNameText.Field.Text, PasswordText.Field.Text, NickNameText.Field.Text, LastNameText.Field.Text, EmailText.Field.Text, CellPhoneText.Field.Text,
                                                     delegate(System.Net.HttpStatusCode statusCode, string statusDescription)
                        {
                            if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode) == true)
                            {
                                ProfileAnalytic.Instance.Trigger(ProfileAnalytic.Register);

                                State = RegisterState.Success;
                                ResultView.Show(RegisterStrings.RegisterStatus_Success,
                                                PrivateControlStylingConfig.Result_Symbol_Success,
                                                RegisterStrings.RegisterResult_Success,
                                                GeneralStrings.Done);
                            }
                            else
                            {
                                State = RegisterState.Fail;
                                ResultView.Show(RegisterStrings.RegisterStatus_Failed,
                                                PrivateControlStylingConfig.Result_Symbol_Failed,
                                                statusDescription,
                                                GeneralStrings.Done);
                            }

                            BlockerView.Hide(null);
                        });
                    });
                }
            }
        }
Exemple #6
0
 void HandlePerformSearchResult(bool result, string description)
 {
     // unhide the blocker
     BlockerView.Hide(
         delegate
     {
         Submit.Enabled = true;
         DisplayResult(result, description);
     });
 }
Exemple #7
0
        void UIThread_LoginComplete(System.Net.HttpStatusCode code, string desc)
        {
            BlockerView.Hide(delegate
            {
                switch (code)
                {
                case System.Net.HttpStatusCode.OK:
                    {
                        // see if we should set their viewing campus
                        if (RockMobileUser.Instance.PrimaryFamily.CampusId.HasValue == true)
                        {
                            RockMobileUser.Instance.ViewingCampus = RockMobileUser.Instance.PrimaryFamily.CampusId.Value;
                        }

                        // if they have a profile picture, grab it.
                        RockMobileUser.Instance.TryDownloadProfilePicture(PrivateGeneralConfig.ProfileImageSize, ProfileImageComplete);

                        // hide the activity indicator, because we are now logged in,
                        // but leave the buttons all disabled.
                        //LoginActivityIndicator.Visibility = ViewStates.Gone;
                        BlockerView.Hide( );

                        // update the UI
                        FadeLoginResult(true);
                        LoginResultLabel.Text = string.Format(LoginStrings.Success, RockMobileUser.Instance.PreferredName( ));

                        // start the timer, which will notify the springboard we're logged in when it ticks.
                        LoginSuccessfulTimer.Elapsed += (object sender, System.Timers.ElapsedEventArgs e) =>
                        {
                            // when the timer fires, notify the springboard we're done.
                            Rock.Mobile.Threading.Util.PerformOnUIThread(delegate
                            {
                                SpringboardParent.ModalFragmentDone(null);
                            });
                        };

                        LoginSuccessfulTimer.Start( );
                        break;
                    }

                default:
                    {
                        // if we couldn't get their profile, that should still count as a failed login.
                        SetUIState(LoginState.Out);

                        FadeLoginResult(true);
                        LoginResultLabel.Text = LoginStrings.Error_Unknown;

                        RockMobileUser.Instance.LogoutAndUnbind( );
                        break;
                    }
                }
            });
        }
Exemple #8
0
                void GetInitialGroups(int groupTypeId, string streetValue, string cityValue, string stateValue, string zipValue)
                {
                    if (RetrievingGroups == false)
                    {
                        // since this is the first search for the new address, get initial values
                        // so that if they leave the page and return, we can re-populate them.
                        StreetValue = SearchPage.Street.Text;
                        CityValue   = SearchPage.City.Text;
                        StateValue  = SearchPage.State.Text;
                        ZipValue    = SearchPage.ZipCode.Text;

                        RetrievingGroups = true;

                        BlockerView.Show(delegate
                        {
                            GroupTypeId    = groupTypeId;
                            CurrGroupIndex = 0;

                            GroupFinder.GetGroups(groupTypeId, streetValue, cityValue, stateValue, zipValue, CurrGroupIndex, NumRequestedGroups,
                                                  delegate(MobileAppApi.GroupSearchResult sourceLocation, List <MobileAppApi.GroupSearchResult> groupEntries, bool result)
                            {
                                BlockerView.Hide(delegate
                                {
                                    RetrievingGroups = false;

                                    SourceLocation = sourceLocation;

                                    GroupEntries = groupEntries;

                                    UpdateMap(result);

                                    // if the result was valid
                                    string address = StreetValue + " " + CityValue + ", " + StateValue + ", " + ZipValue;
                                    if (result)
                                    {
                                        // take the lesser of the two. The number we requested, or the amount returned, because
                                        // it's possible there weren't as many as we requested.
                                        CurrGroupIndex = Math.Min(NumRequestedGroups, groupEntries.Count);

                                        // record an analytic that they searched
                                        GroupFinderAnalytic.Instance.Trigger(GroupFinderAnalytic.Location, address);
                                        //GroupFinderAnalytic.Instance.Trigger( GroupFinderAnalytic.Neighborhood, GroupEntries[ 0 ].NeighborhoodArea );
                                    }
                                    else
                                    {
                                        // record an analytic that this address failed
                                        GroupFinderAnalytic.Instance.Trigger(GroupFinderAnalytic.OutOfBounds, address);
                                    }
                                });
                            });
                        });
                    }
                }
        void UIThread_LoginComplete(System.Net.HttpStatusCode code, string desc)
        {
            BlockerView.Hide(delegate
            {
                switch (code)
                {
                case System.Net.HttpStatusCode.OK:
                    {
                        // see if we should set their viewing campus
                        if (RockMobileUser.Instance.PrimaryFamily.CampusId.HasValue == true)
                        {
                            RockMobileUser.Instance.ViewingCampus = RockMobileUser.Instance.PrimaryFamily.CampusId.Value;
                        }

                        // if they have a profile picture, grab it.
                        RockMobileUser.Instance.TryDownloadProfilePicture(PrivateGeneralConfig.ProfileImageSize, ProfileImageComplete);

                        // update the UI
                        FadeLoginResult(true);
                        LoginResult.Field.Text = string.Format(LoginStrings.Success, RockMobileUser.Instance.PreferredName( ));

                        // start the timer, which will notify the springboard we're logged in when it ticks.
                        LoginSuccessfulTimer.Elapsed += (object sender, System.Timers.ElapsedEventArgs e) =>
                        {
                            // when the timer fires, notify the springboard we're done.
                            Rock.Mobile.Threading.Util.PerformOnUIThread(delegate
                            {
                                Springboard.ResignModelViewController(this, null);
                            });
                        };

                        LoginSuccessfulTimer.Start( );

                        break;
                    }

                default:
                    {
                        // if we couldn't get their profile, that should still count as a failed login.
                        SetUIState(LoginState.Out);

                        // failed to login for some reason
                        FadeLoginResult(true);
                        LoginResult.Field.Text = LoginStrings.Error_Unknown;

                        RockMobileUser.Instance.LogoutAndUnbind( );
                        break;
                    }
                }
            });
        }
Exemple #10
0
                void SubmitPrayerRequest( )
                {
                    ResultView.Show(PrayerStrings.PostPrayer_Status_Submitting,
                                    "",
                                    "",
                                    "");

                    Success = false;
                    Posting = true;

                    // fade in our blocker, and when it's complete, send our request off
                    BlockerView.Show(delegate
                    {
                        // submit the request
                        RockApi.Post_PrayerRequests(PrayerRequest,
                                                    delegate(System.Net.HttpStatusCode statusCode, string statusDescription)
                        {
                            Posting = false;

                            // if they left while posting, screw em.
                            if (IsActive == true)
                            {
                                BlockerView.Hide(null);

                                if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode))
                                {
                                    Success = true;

                                    ResultView.Show(PrayerStrings.PostPrayer_Status_SuccessText,
                                                    PrivateControlStylingConfig.Result_Symbol_Success,
                                                    PrayerStrings.PostPrayer_Result_SuccessText,
                                                    GeneralStrings.Done);

                                    PrayerAnalytic.Instance.Trigger(PrayerAnalytic.Create);
                                }
                                else
                                {
                                    Success = false;

                                    ResultView.Show(PrayerStrings.PostPrayer_Status_FailedText,
                                                    PrivateControlStylingConfig.Result_Symbol_Failed,
                                                    PrayerStrings.PostPrayer_Result_FailedText,
                                                    GeneralStrings.Retry);
                                }
                            }
                        });
                    });
                }
Exemple #11
0
        public override void OnResume()
        {
            base.OnResume();

            // logged in sanity check.
            if (RockMobileUser.Instance.LoggedIn == false)
            {
                throw new Exception("A user must be logged in before viewing a profile. How did you do this?");
            }

            SpringboardParent.ModalFragmentOpened(this);

            ResultView.Hide( );
            BlockerView.BringToFront( );

            BlockerView.Show(
                delegate
            {
                RockMobileUser.Instance.GetPersonData(delegate(System.Net.HttpStatusCode statusCode, string statusDescription)
                {
                    if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode) == true)
                    {
                        ScrollView.ScrollEnabled = true;

                        // show the latest profile info
                        ModelToUI( );
                    }
                    else
                    {
                        // show failure prompt
                        ResultView.Show(ProfileStrings.ProfileErrorTitle, PrivateControlStylingConfig.Result_Symbol_Failed, ProfileStrings.ProfileErrorDesc, GeneralStrings.Ok);

                        // if the result is "Not Found", then that means their login is no longer valid. Force a logout.
                        if (statusCode == System.Net.HttpStatusCode.NotFound)
                        {
                            // then log them out.
                            RockMobileUser.Instance.LogoutAndUnbind( );
                        }
                    }

                    BlockerView.Hide(null);
                });
            });
        }
        void RefreshProfile( )
        {
            // don't allow a double refresh, obviously.
            if (RefreshingProfile == false)
            {
                RefreshingProfile = true;

                ResultView.Hide( );
                BlockerView.BringToFront( );

                BlockerView.Show(
                    delegate
                {
                    RockMobileUser.Instance.GetPersonData(delegate(System.Net.HttpStatusCode statusCode, string statusDescription)
                    {
                        RefreshingProfile = false;

                        if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode) == true)
                        {
                            // show the latest profile info
                            ModelToUI( );
                        }
                        else
                        {
                            // show failure prompt
                            ResultView.Show(ProfileStrings.ProfileErrorTitle, PrivateControlStylingConfig.Result_Symbol_Failed, ProfileStrings.ProfileErrorDesc, GeneralStrings.Ok);

                            // if the result is "Not Found", then that means their login is no longer valid. Force a logout.
                            if (statusCode == System.Net.HttpStatusCode.NotFound)
                            {
                                // then log them out.
                                RockMobileUser.Instance.LogoutAndUnbind( );
                            }
                        }

                        BlockerView.Hide(null);
                    });
                });
            }
        }
        void GetAdditionalGroups( )
        {
            if (Searching == false)
            {
                Searching = true;

                BlockerView.Show(delegate
                {
                    GroupFinder.GetGroups(GroupTypeId, StreetValue, CityValue, StateValue, ZipValue, CurrGroupIndex, NumRequestedGroups,
                                          delegate(MobileAppApi.GroupSearchResult sourceLocation, List <MobileAppApi.GroupSearchResult> groupEntries, bool result)
                    {
                        BlockerView.Hide(delegate
                        {
                            Searching = false;

                            if (result)
                            {
                                // increment our index to the next set, or the end of the list, whichever is less
                                // this will ensure when we hit the end of the list, CurrGroupIndex reflects that.
                                CurrGroupIndex += Math.Min(groupEntries.Count, NumRequestedGroups);

                                // add in the new results
                                GroupEntries.AddRange(groupEntries);

                                // update the map
                                UpdateMap(result);

                                // and reload the table
                                GroupFinderTableView.ReloadData( );

                                // since we're only loading additional groups, don't flag the
                                // list as updated. We don't want it to reset to the top.
                                GroupListUpdated = false;
                            }
                        });
                    });
                });
            }
        }
        public void PerformSearch( )
        {
            if (SearchField.GetCurrentValue( ).Length > Settings.General_MinSearchLength)
            {
                // put the list at the top, so that when we refresh it, it correctly resizes each row
                TableView.SetContentOffset(CGPoint.Empty, true);

                SearchField.ResignFirstResponder( );

                BlockerView.BringToFront( );

                BlockerView.Show(
                    delegate
                {
                    // search for the family
                    RockApi.Get_Groups_FamiliesByPersonNameSearch(SearchField.GetCurrentValue( ),
                                                                  delegate(System.Net.HttpStatusCode statusCode, string statusDescription, List <Rock.Client.Family> model)
                    {
                        if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode) == true && model != null && model.Count > 0)
                        {
                            Families = model;
                        }
                        else
                        {
                            // error (or no results)
                            Families = new List <Rock.Client.Family>( );

                            DidSearchFail = true;
                        }

                        // reload data
                        ((TableSource)TableView.Source).FamiliesUpdated(TableView);
                        TableView.ReloadData( );

                        BlockerView.Hide( );
                    });
                });
            }
        }
Exemple #15
0
        void RetrievePrayerRequests( )
        {
            ResultView.Hide( );

            BlockerView.Show(delegate
            {
                RequestingPrayers = true;

                // request the prayers each time this appears
                RockApi.Get_PrayerRequests_Public(delegate(System.Net.HttpStatusCode statusCode, string statusDescription, List <Rock.Client.PrayerRequest> prayerRequests)
                {
                    // force this onto the main thread so that if there's a race condition in requesting prayers we won't hit it.
                    InvokeOnMainThread(delegate
                    {
                        // only process this if the view is still active. It's possible this request came in after we left the view.
                        if (ViewActive == true)
                        {
                            PrayerRequests.Clear( );
                            Carousel.Clear( );

                            RequestingPrayers = false;

                            BlockerView.Hide(null);

                            // somestimes our prayers can be received with errors in the xml, so ensure we have a valid model.
                            if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode) && prayerRequests != null)
                            {
                                if (prayerRequests.Count > 0)
                                {
                                    // sort the prayers based on prayer count (least prayed for first)
                                    prayerRequests.Sort(delegate(Rock.Client.PrayerRequest x, Rock.Client.PrayerRequest y)
                                    {
                                        if (x.PrayerCount < y.PrayerCount)
                                        {
                                            return(-1);
                                        }

                                        if (x.PrayerCount > y.PrayerCount)
                                        {
                                            return(1);
                                        }

                                        return(0);
                                    });

                                    // update our timestamp since this was successful
                                    LastDownload = DateTime.Now;

                                    // setup the card positions to be to the offscreen to the left, centered on screen, and offscreen to the right
                                    for (int i = 0; i < Math.Min(prayerRequests.Count, PrivatePrayerConfig.MaxPrayers); i++)
                                    {
                                        PrayerCard card = new PrayerCard(prayerRequests[i], CardSize);
                                        PrayerRequests.Add(card);
                                        Carousel.AddCard(card.View);
                                    }
                                }
                                else
                                {
                                    ResultView.Show(PrayerStrings.ViewPrayer_StatusText_NoPrayers, null, PrayerStrings.ViewPrayer_Result_NoPrayersText, GeneralStrings.Retry);
                                }

                                // add a read analytic
                                PrayerAnalytic.Instance.Trigger(PrayerAnalytic.Read);
                            }
                            else
                            {
                                ResultView.Show(PrayerStrings.ViewPrayer_StatusText_Failed,
                                                PrivateControlStylingConfig.Result_Symbol_Failed,
                                                PrayerStrings.Error_Retrieve_Message,
                                                GeneralStrings.Retry);

                                Task.NavToolbar.SetCreateButtonEnabled(false);
                            }
                        }
                    });
                });
            });
        }
        public void LoginComplete(System.Net.HttpStatusCode statusCode, string statusDescription)
        {
            switch (statusCode)
            {
            // if we received No Content, we're logged in
            case System.Net.HttpStatusCode.NoContent:
            {
                RockMobileUser.Instance.GetPersonData(
                    delegate(System.Net.HttpStatusCode code, string desc)
                    {
                        Rock.Mobile.Threading.Util.PerformOnUIThread(delegate
                        {
                            UIThread_LoginComplete(code, desc);
                        });
                    });
                break;
            }

            case System.Net.HttpStatusCode.Unauthorized:
            {
                BlockerView.Hide(delegate
                    {
                        // allow them to attempt logging in again
                        SetUIState(LoginState.Out);

                        // wrong user name / password
                        FadeLoginResult(true);
                        LoginResult.Field.Text = LoginStrings.Error_Credentials;
                    });
                break;
            }

            case System.Net.HttpStatusCode.ResetContent:
            {
                // consider this a cancellation
                BlockerView.Hide(delegate
                    {
                        // allow them to attempt logging in again
                        SetUIState(LoginState.Out);

                        LoginResult.Field.Text = "";
                    });

                break;
            }

            default:
            {
                BlockerView.Hide(delegate
                    {
                        // allow them to attempt logging in again
                        SetUIState(LoginState.Out);

                        // failed to login for some reason
                        FadeLoginResult(true);
                        LoginResult.Field.Text = LoginStrings.Error_Unknown;
                    });
                break;
            }
            }
        }
Exemple #17
0
        void HandleDownloadResult(string result)
        {
            // unhide the blocker
            BlockerView.Hide(
                delegate
            {
                Sync.Enabled = true;
                DisplaySyncResult(result);

                // reset the currently selected rows if necessary, so that the text color is visible
                if (CampusTableView.IndexPathForSelectedRow != null)
                {
                    ((CampusTableData)CampusTableView.Source).SetRowColor(CampusTableView, CampusTableView.IndexPathForSelectedRow, UIColor.Black);
                }

                if (TemplateTableView.IndexPathForSelectedRow != null)
                {
                    ((TemplateTableData)TemplateTableView.Source).SetRowColor(TemplateTableView, TemplateTableView.IndexPathForSelectedRow, UIColor.Black);
                }

                CampusTableView.ReloadData( );
                TemplateTableView.ReloadData( );

                // now set the appropriate campus selection
                if (Campuses.Count > 0)
                {
                    int campusIndex = 0;

                    // try to find the selected campus in the newly downloaded list.
                    Rock.Client.Campus campus = Campuses.Where(c => c.Id == Config.Instance.Campuses[Config.Instance.SelectedCampusIndex].Id).SingleOrDefault( );
                    if (campus != null)
                    {
                        // we found it, so take its index and set it.
                        campusIndex = Campuses.IndexOf(campus);

                        // update the table selections
                        NSIndexPath rowToSelect = NSIndexPath.FromRowSection(campusIndex, 0);
                        CampusTableView.SelectRow(rowToSelect, false, UITableViewScrollPosition.None);
                        ((CampusTableData)CampusTableView.Source).SetRowColor(CampusTableView, rowToSelect, UIColor.White);
                    }
                }


                // and theme
                if (ConfigurationTemplates.Count > 0)
                {
                    int themeIndex = 0;

                    // try to find the selected campus in the newly downloaded list.
                    Rock.Client.DefinedValue configTemplate = ConfigurationTemplates.Where(ct => ct.Id == Config.Instance.ConfigurationTemplateId).SingleOrDefault( );
                    if (configTemplate != null)
                    {
                        // we found it, so take its index and set it.
                        themeIndex = ConfigurationTemplates.IndexOf(configTemplate);

                        // update the table selections
                        NSIndexPath rowToSelect = NSIndexPath.FromRowSection(themeIndex, 0);
                        TemplateTableView.SelectRow(rowToSelect, false, UITableViewScrollPosition.None);
                        ((TemplateTableData)TemplateTableView.Source).SetRowColor(TemplateTableView, rowToSelect, UIColor.White);
                    }
                }

                // run this to see if we can enable the save button.
                RowSelected( );
            });
        }
        void GetInitialGroups(int groupTypeId, string street, string city, string state, string zip)
        {
            if (Searching == false)
            {
                // since this is the first search for the new address, get initial values
                // so that if they leave the page and return, we can re-populate them.
                StreetValue = SearchPage.Street.Text;
                CityValue   = SearchPage.City.Text;
                StateValue  = SearchPage.State.Text;
                ZipValue    = SearchPage.ZipCode.Text;

                Searching = true;

                BlockerView.Show(delegate
                {
                    // set the group index we'll begin with
                    CurrGroupIndex = 0;
                    GroupTypeId    = groupTypeId;

                    // request groups from CurrGroupIndex thru CurrGroupIndex + NumRequestedGroups
                    GroupFinder.GetGroups(groupTypeId, StreetValue, CityValue, StateValue, ZipValue, CurrGroupIndex, NumRequestedGroups,
                                          delegate(MobileAppApi.GroupSearchResult sourceLocation, List <MobileAppApi.GroupSearchResult> groupEntries, bool result)
                    {
                        BlockerView.Hide(delegate
                        {
                            Searching = false;

                            // store the source location
                            SourceLocation = sourceLocation;

                            // take the initial group entries
                            GroupEntries = groupEntries;

                            // update the map
                            UpdateMap(result);

                            // reload the table.
                            GroupFinderTableView.ReloadData( );

                            // flag that our group list was updated so that
                            // on the region updated callback from the map, we
                            // can select the appropriate group
                            GroupListUpdated = true;

                            // and record an analytic for the neighborhood that this location was apart of. This helps us know
                            // which neighborhoods get the most hits.
                            string address = StreetValue + " " + CityValue + ", " + StateValue + ", " + ZipValue;

                            // send an analytic if the request went thru ok
                            if (result)
                            {
                                if (groupEntries.Count > 0)
                                {
                                    // increment our index to the next set, or the final amount available, whichever is less.
                                    // this will ensure when we hit the end of the list, CurrGroupIndex reflects that.
                                    CurrGroupIndex = CurrGroupIndex + Math.Min(groupEntries.Count, NumRequestedGroups);

                                    // record an analytic that they searched
                                    GroupFinderAnalytic.Instance.Trigger(GroupFinderAnalytic.Location, address);
                                    //GroupFinderAnalytic.Instance.Trigger( GroupFinderAnalytic.Neighborhood, groupEntries[ 0 ].NeighborhoodArea );
                                }
                                else
                                {
                                    // record that this address failed
                                    GroupFinderAnalytic.Instance.Trigger(GroupFinderAnalytic.OutOfBounds, address);
                                }
                            }
                        });
                    });
                });
            }
        }
        public void TryFacebookBind( )
        {
            SetUIState(LoginState.Trying);

            // have our rock mobile user begin the facebook bind process
            RockMobileUser.Instance.BindFacebookAccount(delegate(string fromUri)
            {
                // it's ready, so create a webView that will take them to the FBLogin page
                WebLayout = new WebLayout(ScrollView.Frame);
                WebLayout.DeleteCacheAndCookies( );

                ScrollView.AddSubview(WebLayout.ContainerView);

                // set it totally transparent so we can fade it in
                //WebLayout.ContainerView.BackgroundColor = UIColor.Green;
                WebLayout.ContainerView.Layer.Opacity = 0.00f;
                //WebLayout.SetCancelButtonColor( ControlStylingConfig.TextField_PlaceholderTextColor );
                WebLayout.LayoutChanged(new CGRect(0, 0, ScrollView.Frame.Width, ScrollView.Frame.Height));

                View.SetNeedsLayout( );

                // do a nice fade-in
                SimpleAnimator_Float floatAnimator = new SimpleAnimator_Float(0.00f, 1.00f, .25f,
                                                                              delegate(float percent, object value)
                {
                    WebLayout.ContainerView.Layer.Opacity = (float)value;
                },
                                                                              delegate
                {
                    // once faded in, begin loading the page
                    WebLayout.ContainerView.Layer.Opacity = 1.00f;

                    WebLayout.LoadUrl(fromUri, delegate(WebLayout.Result result, string url)
                    {
                        BlockerView.Hide( );

                        // if fail/success comes in
                        if (result != WebLayout.Result.Cancel)
                        {
                            // see if it's a valid facebook response

                            // if an empty url was returned, it's NOT. Fail.
                            if (string.IsNullOrEmpty(url) == true)
                            {
                                WebLayout.ContainerView.RemoveFromSuperview( );
                                BindComplete(false);
                            }
                            // otherwise, try to parse the response and move forward
                            else if (RockMobileUser.Instance.HasFacebookResponse(url))
                            {
                                // it is, continue the bind process
                                BlockerView.Show();

                                WebLayout.ContainerView.RemoveFromSuperview( );
                                RockMobileUser.Instance.FacebookCredentialResult(url, BindComplete);

                                ProfileAnalytic.Instance.Trigger(ProfileAnalytic.Login, "Facebook");
                            }
                        }
                        else
                        {
                            // they pressed cancel, so simply cancel the attempt
                            WebLayout.ContainerView.RemoveFromSuperview( );
                            LoginComplete(System.Net.HttpStatusCode.ResetContent, "");
                        }
                    });
                });

                floatAnimator.Start( );
            });
        }
Exemple #20
0
        void Internal_DisplayView( )
        {
            // default all controls to hidden, and we'll figure out what to show in the layout method.
            HideControls(true);

            IsDownloading = true;

            BlockerView.Show(delegate
            {
                MobileAppApi.GetGroupSummary(GroupEntry.Id,
                                             delegate(MobileAppApi.GroupInfo groupInfo, System.IO.MemoryStream familyPhoto, System.IO.MemoryStream groupPhoto)
                {
                    try
                    {
                        IsDownloading = false;

                        if (familyPhoto != null)
                        {
                            // setup the family image
                            FamilyImage.Image = familyPhoto;

                            float imageSize    = Rock.Mobile.Graphics.Util.UnitToPx(PrivateConnectConfig.GroupInfo_Leader_ImageSize);
                            FamilyImage.Bounds = new RectangleF(0, 0, imageSize, imageSize);

                            // if we had a valid image stream, dispose of it now
                            FamilyImageValid = true;
                            familyPhoto.Dispose( );
                        }
                        else
                        {
                            FamilyImageValid = false;
                        }

                        // setup the group image
                        if (groupPhoto != null)
                        {
                            GroupImage.Image = groupPhoto;

                            float imageSize   = Rock.Mobile.Graphics.Util.UnitToPx(PrivateConnectConfig.GroupInfo_Group_ImageSize);
                            GroupImage.Bounds = new RectangleF(0, 0, imageSize, imageSize);

                            GroupImageValid = true;
                            groupPhoto.Dispose( );
                        }
                        else
                        {
                            // if we had a valid image stream, dispose of it now
                            GroupImageValid = false;
                        }

                        // set the details for the group (distance, meeting time, etc)

                        // set the group title
                        GroupTitle.Text = GroupEntry.Name;

                        if (string.IsNullOrWhiteSpace(GroupEntry.MeetingTime) == false)
                        {
                            MeetingTime.Text = GroupEntry.MeetingTime;
                        }
                        else
                        {
                            MeetingTime.Text = ConnectStrings.GroupFinder_ContactForTime;
                        }

                        // add the distance
                        MeetingTime.Text += "\n" + string.Format("{0:##.0} {1}", GroupEntry.DistanceFromSource, ConnectStrings.GroupFinder_MilesSuffix);

                        // childcare provided header
                        if (string.IsNullOrWhiteSpace(groupInfo.Filters) == false && groupInfo.Filters.Contains(PrivateConnectConfig.GroupFinder_Childcare_Filter))
                        {
                            ChildcareProvided.Text = ConnectStrings.GroupFinder_OffersChildcare;
                        }
                        else
                        {
                            ChildcareProvided.Text = string.Empty;
                        }

                        // young adults header
                        if (string.IsNullOrWhiteSpace(groupInfo.Filters) == false && groupInfo.Filters.Contains(PrivateConnectConfig.GroupFinder_YoungAdults_Filter))
                        {
                            YoungAdults.Text = ConnectStrings.GroupFinder_YoungAdults;
                        }
                        else
                        {
                            YoungAdults.Text = string.Empty;
                        }

                        // childcare description (if its blank, it'll be hidden)
                        ChildDesc.Text = groupInfo.ChildcareDesc;

                        // group description (if its blank, it'll be hidden)
                        GroupDesc.Text = groupInfo.Description;


                        BlockerView.Hide( );

                        GroupSummaryResult(HttpStatusCode.OK, string.Empty);
                    }
                    catch
                    {
                        BlockerView.Hide( );

                        ResultView.Show(ConnectStrings.GroupInfo_Failed,
                                        PrivateControlStylingConfig.Result_Symbol_Failed,
                                        ConnectStrings.GroupInfoResult_Failed,
                                        GeneralStrings.Retry);

                        GroupSummaryResult(HttpStatusCode.NotFound, string.Empty);
                    }
                });
            });
        }