コード例 #1
0
                public override void OnPause()
                {
                    base.OnPause();

                    IsActive = false;

                    Carousel.Clear( );
                }
コード例 #2
0
                public override void OnResume()
                {
                    base.OnResume();

                    IsActive = true;

                    ParentTask.NavbarFragment.NavToolbar.SetBackButtonEnabled(false);
                    ParentTask.NavbarFragment.NavToolbar.SetShareButtonEnabled(false, null);
                    ParentTask.NavbarFragment.NavToolbar.SetCreateButtonEnabled(true, delegate
                    {
                        ParentTask.OnClick(this, 0);
                    });
                    ParentTask.NavbarFragment.NavToolbar.Reveal(true);

                    if (IsRequesting == false)
                    {
                        TimeSpan deltaTime = DateTime.Now - LastDownloadTime;
                        if (deltaTime.TotalHours > PrivatePrayerConfig.PrayerDownloadFrequency.TotalHours)
                        {
                            Rock.Mobile.Util.Debug.WriteLine("Downloading Prayers");
                            DownloadPrayers( );
                        }
                        else
                        {
                            Rock.Mobile.Util.Debug.WriteLine("Not downloading prayers");

                            // We already have cached prayers, so simply restore them.
                            StatusLayer.Visibility = ViewStates.Invisible;
                            ResultLayer.Visibility = ViewStates.Invisible;
                            RetryButton.Visibility = ViewStates.Invisible;

                            // setup the carousel again
                            Carousel.Clear( );
                            foreach (PrayerCard prayerCard in PrayerRequestCards)
                            {
                                Carousel.AddCard(prayerCard.View);
                            }

                            // prayers received and are being viewed
                            PrayerAnalytic.Instance.Trigger(PrayerAnalytic.Read);
                        }

                        LayoutChanged( );
                    }
                    else
                    {
                        // we're still in the process of requesting, so restore the "request UI"
                        SetUIRequestingPrayers( );
                    }
                }
コード例 #3
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);
                            }
                        }
                    });
                });
            });
        }