void DownloadPrayers( ) { // protect against double requests IsRequesting = true; SetUIRequestingPrayers( ); // request the prayers each time this appears RockApi.Get_PrayerRequests_Public( delegate(System.Net.HttpStatusCode statusCode, string statusDescription, List <Rock.Client.PrayerRequest> prayerRequests) { IsRequesting = false; PrayerRequestCards.Clear( ); // only process this if the view is still active. It's possible this request came in after we left the view. if (IsActive == true) { ActivityIndicator.Visibility = ViewStates.Invisible; if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode) == true && 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); }); LastDownloadTime = DateTime.Now; // success, so hide the status layer, we don't need it StatusLayer.Visibility = ViewStates.Invisible; // create our prayer request layouts for (int i = 0; i < Math.Min(prayerRequests.Count, PrivatePrayerConfig.MaxPrayers); i++) { PrayerCard prayerCard = new PrayerCard(prayerRequests[i], PrayerCardSize); PrayerRequestCards.Add(prayerCard); Carousel.AddCard(prayerCard.View); } // prayers received and are being viewed PrayerAnalytic.Instance.Trigger(PrayerAnalytic.Read); } else { StatusLayer.Visibility = ViewStates.Visible; ResultLayer.Visibility = ViewStates.Visible; RetryButton.Visibility = ViewStates.Visible; StatusText.Text = PrayerStrings.ViewPrayer_StatusText_Failed; ResultText.Text = PrayerStrings.Error_Retrieve_Message; } } }); }
void DownloadPrayers( ) { // protect against double requests IsRequesting = true; SetUIRequestingPrayers( ); // request the prayers each time this appears RockApi.Get_PrayerRequests_Public( delegate(System.Net.HttpStatusCode statusCode, string statusDescription, List<Rock.Client.PrayerRequest> prayerRequests ) { IsRequesting = false; PrayerRequestCards.Clear( ); // only process this if the view is still active. It's possible this request came in after we left the view. if( IsActive == true ) { ActivityIndicator.Visibility = ViewStates.Invisible; if ( Rock.Mobile.Network.Util.StatusInSuccessRange( statusCode ) == true && 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) { return x.PrayerCount < y.PrayerCount ? -1 : 1; }); LastDownloadTime = DateTime.Now; // success, so hide the status layer, we don't need it StatusLayer.Visibility = ViewStates.Invisible; // create our prayer request layouts for( int i = 0; i < Math.Min( prayerRequests.Count, PrivatePrayerConfig.MaxPrayers ); i++ ) { PrayerCard prayerCard = new PrayerCard( prayerRequests[ i ], PrayerCardSize ); PrayerRequestCards.Add( prayerCard ); Carousel.AddCard( prayerCard.View ); } // prayers received and are being viewed PrayerAnalytic.Instance.Trigger( PrayerAnalytic.Read ); } else { StatusLayer.Visibility = ViewStates.Visible; ResultLayer.Visibility = ViewStates.Visible; RetryButton.Visibility = ViewStates.Visible; StatusText.Text = PrayerStrings.ViewPrayer_StatusText_Failed; ResultText.Text = PrayerStrings.Error_Retrieve_Message; } } } ); }