Exemple #1
0
                /// <summary>
                /// Takes the news from LaunchData and populates the NewsPrimaryFragment with it.
                /// </summary>
                void ReloadNews( )
                {
                    Rock.Mobile.Threading.Util.PerformOnUIThread(delegate
                    {
                        Rock.Client.Campus campus = RockLaunchData.Instance.Data.CampusFromId(RockMobileUser.Instance.ViewingCampus);
                        Guid viewingCampusGuid    = campus != null ? campus.Guid : Guid.Empty;

                        // provide the news to the viewer by COPYING it.
                        News.Clear( );
                        foreach (RockNews newsItem in RockLaunchData.Instance.Data.News)
                        {
                            // only add news for "all campuses" and their selected campus.
                            if (newsItem.CampusGuids.Contains(viewingCampusGuid) || newsItem.CampusGuids.Count == 0)
                            {
                                // Limit the amount of news to display to MaxNews so we don't show so many we
                                // run out of memory. If DEVELOPER MODE is on, show them all.
                                if (News.Count < PrivateNewsConfig.MaxNews || MobileApp.Shared.Network.RockLaunchData.Instance.Data.DeveloperModeEnabled == true)
                                {
                                    News.Add(new RockNews(newsItem));
                                }
                            }
                        }

                        if (RockLaunchData.Instance.Data.PECampaign != null)
                        {
                            News.Insert(0, RockLaunchData.Instance.Data.PECampaign);
                        }

                        // if they need to upgrade, push that news item to the top
                        if (RockLaunchData.Instance.Data.NeedsUpgrade)
                        {
                            News.Insert(0, RockLaunchData.Instance.Data.UpgradeNewsItem);
                        }
                    });
                }
Exemple #2
0
 /// <summary>
 /// Helper method for converting a campus' name to its ID
 /// </summary>
 /// <returns>The name to identifier.</returns>
 public int CampusNameToId(string campusName)
 {
     Rock.Client.Campus campusObj = Campuses.Find(c => c.Name == campusName);
     return(campusObj != null ? campusObj.Id : 0);
 }
Exemple #3
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( );
            });
        }
Exemple #4
0
 /// <summary>
 /// Helper method for converting a campus' guid to its name
 /// </summary>
 /// <returns>The identifier to name.</returns>
 public string CampusGuidToName(Guid campusGuid)
 {
     // guard against old, bad values.
     Rock.Client.Campus campusObj = Campuses.Find(c => c.Guid == campusGuid);
     return(campusObj != null ? campusObj.Name : "");
 }