Пример #1
0
        /// <summary>
        /// Helper for Button.OnClicked that makes the decision whether to request an update from the server
        /// for this leaderboard.
        /// Also a Helper for managePersisedLeaderboard to determine on startup if updates are needed...
        /// No longer have button.clicked.  This is now tested against whenever the user enters the leaderboard page
        /// and fires the reload for any category that is still active and has last reload > MIN_TIME_BETWEEN_RELOADS away
        /// If updating, triggers a leaderboardRequest.
        /// </summary>
        private void reloadAnalysis(CategoryJSON category)
        {
            DateTime timeOfRequest = DateTime.Now;

            if (leaderboardUpdateTimestamps.ContainsKey(category))
            {
                if ((timeOfRequest - leaderboardUpdateTimestamps[category]) > MIN_TIME_BETWEEN_RELOADS)
                {
                    // before firing request, check that this leaderboard is not already in the closed state.
                    if ((category.end > timeOfRequest) && (leaderboardUpdateTimestamps[category] < category.end))
                    {
                        // ending is still in the future and last load was before the category ended.
                        // hmm. if I"m called by managePersistedLeaderboard, this can occur before I have an authToken...
                        // so... check for auth token. if I don't have one, the OnCategoryLoad process catches calls here.
                        if (GlobalStatusSingleton.authToken != null)
                        {
                            RequestLeaderboardEventArgs evtArgs = new RequestLeaderboardEventArgs {
                                Category = category,
                            };
                            if (RequestLeaderboard != null)
                            {
                                RequestLeaderboard(this, evtArgs);
                            }
                        }
                    }
#if DEBUG
                    else
                    {
                        Debug.WriteLine("DHB:LeaderboardPage:reloadAnalysis Hit the closed category no reload case");
                    }
#endif
                }
            }
            else
            {
                // no timestamp info. fire a load.  Request takes care of setting the timestamp.
                RequestLeaderboardEventArgs evtArgs = new RequestLeaderboardEventArgs {
                    Category = category,
                };
                if (RequestLeaderboard != null)
                {
                    RequestLeaderboard(this, evtArgs);
                }
            }
        }
Пример #2
0
 private void CheckCategoryListLoaded(IList <CategoryJSON> categoryList)
 {
     foreach (CategoryJSON category in categoryList)
     {
         if (ListOfLeaderboardsContains(category.categoryId) == false)
         {
             // new category. load it!
             RequestLeaderboardEventArgs evtArgs = new RequestLeaderboardEventArgs {
                 Category = category,
             };
             if (RequestLeaderboard != null)
             {
                 RequestLeaderboard(this, evtArgs);
             }
         }
         else
         {
             // check to see if I should reload this category anyway.
             reloadAnalysis(category);
         }
     }
 }