Example #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad( );

            // setup the table view and general background view colors
            SeriesTable = new UITableView( );
            SeriesTable.Layer.AnchorPoint = CGPoint.Empty;
            SeriesTable.BackgroundColor   = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor);
            SeriesTable.SeparatorStyle    = UITableViewCellSeparatorStyle.None;
            View.AddSubview(SeriesTable);

            // setup the messages list
            Messages = new List <MessageEntry>();
            TableSource source = new TableSource(this, Messages, Series);

            SeriesTable.Source   = source;
            SeriesTable.Delegate = new TableViewDelegate(source, Task.NavToolbar);

            // log the series they tapped on.
            MessageAnalytic.Instance.Trigger(MessageAnalytic.BrowseSeries, Series.SeriesName);


            IsVisible = true;

            for (int i = 0; i < Series.Messages.Count; i++)
            {
                MessageEntry messageEntry = new MessageEntry();
                Messages.Add(messageEntry);

                messageEntry.Message = Series.Messages[i];
            }


            // do we have the real image?
            if (TryLoadImage(NotesTask.FormatBillboardImageName(Series.SeriesName)) == false)
            {
                // no, so use a placeholder and request the actual image
                SeriesBillboard = new UIImage(NSBundle.MainBundle.BundlePath + "/" + PrivateNoteConfig.NotesMainPlaceholder);

                // request!
                FileCache.Instance.DownloadFileToCache(Series.BillboardUrl, NotesTask.FormatBillboardImageName(Series.SeriesName), null,
                                                       delegate
                {
                    Rock.Mobile.Threading.Util.PerformOnUIThread(
                        delegate
                    {
                        if (IsVisible == true)
                        {
                            TryLoadImage(NotesTask.FormatBillboardImageName(Series.SeriesName));
                        }
                    });
                });
            }
        }
        void SetupSeriesEntries(List <Series> seriesList)
        {
            SeriesEntries.Clear( );

            for (int i = 0; i < seriesList.Count; i++)
            {
                // add the entry to our list
                SeriesEntry entry = new SeriesEntry();
                SeriesEntries.Add(entry);

                // copy over the series and give it a placeholder image
                entry.Series = seriesList[i];


                // attempt to load / download images.

                // for billboards, we ONLY CARE about loading the first series' billboard.
                if (i == 0)
                {
                    bool imageExists = TryLoadImage(ref entry.mBillboard, NotesTask.FormatBillboardImageName(entry.Series.SeriesName));
                    if (imageExists == false)
                    {
                        FileCache.Instance.DownloadFileToCache(entry.Series.BillboardUrl, NotesTask.FormatBillboardImageName(entry.Series.SeriesName), null,
                                                               delegate
                        {
                            Rock.Mobile.Threading.Util.PerformOnUIThread(delegate {
                                if (IsVisible == true)
                                {
                                    TryLoadImage(ref entry.mBillboard, NotesTask.FormatBillboardImageName(entry.Series.SeriesName));
                                }
                            });
                        });
                    }
                }

                // for everything, we care about the thumbnails
                bool thumbExists = TryLoadImage(ref entry.mThumbnail, NotesTask.FormatThumbImageName(entry.Series.SeriesName));
                if (thumbExists == false)
                {
                    FileCache.Instance.DownloadFileToCache(entry.Series.ThumbnailUrl, NotesTask.FormatThumbImageName(entry.Series.SeriesName), null,
                                                           delegate
                    {
                        Rock.Mobile.Threading.Util.PerformOnUIThread(delegate {
                            if (IsVisible == true)
                            {
                                TryLoadImage(ref entry.mThumbnail, NotesTask.FormatThumbImageName(entry.Series.SeriesName));
                            }
                        });
                    });
                }
            }
        }
        /// <summary>
        /// Called when the user pressed the 'Take Notes' button in the primary cell
        /// </summary>
        public void TakeNotesClicked( )
        {
            // maybe technically a hack...we know our parent is a NoteTask,
            // so cast it so we can use the existing NotesViewController.
            NotesTask noteTask = Task as NotesTask;

            if (noteTask != null)
            {
                Series.Message latestMessage = SeriesEntries[0].Series.GetLatestMessage( );

                noteTask.NoteController.NoteName = latestMessage.Name;
                noteTask.NoteController.NoteUrl  = latestMessage.NoteUrl;

                Task.PerformSegue(this, noteTask.NoteController);
            }
        }
Example #4
0
        public void RowClicked(int row, int buttonIndex)
        {
            // 0 would be the audio button
            if (buttonIndex == 0)
            {
                NotesWatchUIViewController viewController = new NotesWatchUIViewController( );
                viewController.MediaUrl  = Series.Messages[row].AudioUrl;
                viewController.ShareUrl  = Series.Messages[row].ShareUrl;
                viewController.Name      = Series.Messages[row].Name;
                viewController.AudioOnly = true;

                Task.PerformSegue(this, viewController);
            }
            // 1 would be the watch button
            else if (buttonIndex == 1)
            {
                NotesWatchUIViewController viewController = new NotesWatchUIViewController( );
                viewController.MediaUrl  = Series.Messages[row].WatchUrl;
                viewController.ShareUrl  = Series.Messages[row].ShareUrl;
                viewController.Name      = Series.Messages[row].Name;
                viewController.AudioOnly = false;

                Task.PerformSegue(this, viewController);
            }
            // 2 would be the Discussion Guide
            else if (buttonIndex == 2)
            {
                NotesDiscGuideViewController viewController = new NotesDiscGuideViewController(Task);
                viewController.DiscGuideURL = Series.Messages[row].DiscussionGuideUrl;

                Task.PerformSegue(this, viewController);
            }
            // and 3 would be the last button, which is Notes
            else if (buttonIndex == 3)
            {
                // maybe technically a hack...we know our parent is a NoteTask,
                // so cast it so we can use the existing NotesViewController.
                NotesTask noteTask = Task as NotesTask;
                if (noteTask != null)
                {
                    noteTask.NoteController.NoteName = Series.Messages[row].Name;
                    noteTask.NoteController.NoteUrl  = Series.Messages[row].NoteUrl;

                    Task.PerformSegue(this, noteTask.NoteController);
                }
            }
        }