Пример #1
0
        public ListViewController(UITableViewStyle style) : base(style)
        {
            numberOfSongsToGet = 20;
            UIBarButtonItem bbi = new UIBarButtonItem();

            bbi.Title = "Info";
            bbi.Style = UIBarButtonItemStyle.Bordered;
            this.NavigationItem.SetRightBarButtonItem(bbi, true);
            bbi.Clicked += (object sender, EventArgs e) => {
                // Create the channel view controller
                channelViewController = new ChannelViewController(UITableViewStyle.Grouped);

                if (this.SplitViewController != null)
                {
                    this.transferBarButtonItem(channelViewController);
                    UINavigationController nvc = new UINavigationController(channelViewController);

                    // Create an array with our nav controller and this new VC's nav controller
                    UINavigationController[] vcs = new UINavigationController[] { this.NavigationController, nvc };

                    // Grab a pointer to the split view controller
                    // and reset its view controllers array
                    this.SplitViewController.ViewControllers = vcs;

                    // Make detail view controller the delegate of the split view controller
                    // - ignore the warning for now
                    this.SplitViewController.WeakDelegate = channelViewController;
                    if (webViewController.popover != null)
                    {
                        webViewController.popover.Dismiss(true);
                    }

                    // If a row has been selected, deselect it so that a row
                    // is not selected when viewing the info
                    NSIndexPath selectedRow = this.TableView.IndexPathForSelectedRow;
                    if (selectedRow != null)
                    {
                        this.TableView.DeselectRow(selectedRow, true);
                    }
                }
                else
                {
                    this.NavigationController.PushViewController(channelViewController, true);
                }

                // Give the VC the channel object through the interface method
                channelViewController.listViewControllerHandleObject(this, BNRFeedStore.channel);
            };

            rssType        = ListViewControllerRSSType.BNRFeed;
            rssTypeControl = new UISegmentedControl(new string[] { "Onobytes", "Apple" });
            rssTypeControl.SelectedSegment = 0;

            if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0) || UIDevice.CurrentDevice.CheckSystemVersion(7, 1))
            {
                rssTypeControl.TintAdjustmentMode = UIViewTintAdjustmentMode.Normal;
            }
            rssTypeControl.ValueChanged += (object sender, EventArgs e) => {
                rssType = (ListViewControllerRSSType)(int)rssTypeControl.SelectedSegment;
                if (rssType == ListViewControllerRSSType.Apple)
                {
                    BNRFeedStore.items.Clear();

                    // Alert to select number of songs
                    UIAlertView aiView = new UIAlertView("Get Top Songs", "Enter how many songs to get", null, "OK", null);
                    aiView.AlertViewStyle               = UIAlertViewStyle.PlainTextInput;
                    aiView.GetTextField(0).Text         = numberOfSongsToGet.ToString();
                    aiView.GetTextField(0).KeyboardType = UIKeyboardType.NumberPad;
                    aiView.WeakDelegate = this;
                    aiView.Show();

                    // Comment out if above is commented in
//					this.TableView.ReloadData();
//					fetchEntries();
                }
                else
                {
                    BNRFeedStore.items.Clear();
                    this.TableView.ReloadData();
                    fetchEntries();
                }
            };
            this.NavigationItem.TitleView  = rssTypeControl;
            this.TableView.BackgroundColor = UIColor.Black;
            fetchEntries();
        }
Пример #2
0
        public ListViewController(UITableViewStyle style)
            : base(style)
        {
            numberOfSongsToGet = 20;
            UIBarButtonItem bbi = new UIBarButtonItem();
            bbi.Title = "Info";
            bbi.Style = UIBarButtonItemStyle.Bordered;
            this.NavigationItem.SetRightBarButtonItem(bbi,true);
            bbi.Clicked += (object sender, EventArgs e) => {
                // Create the channel view controller
                channelViewController = new ChannelViewController(UITableViewStyle.Grouped);

                if (this.SplitViewController != null) {
                    this.transferBarButtonItem(channelViewController);
                    UINavigationController nvc = new UINavigationController(channelViewController);

                    // Create an array with our nav controller and this new VC's nav controller
                    UINavigationController[] vcs = new UINavigationController[]{this.NavigationController, nvc};

                    // Grab a pointer to the split view controller
                    // and reset its view controllers array
                    this.SplitViewController.ViewControllers = vcs;

                    // Make detail view controller the delegate of the split view controller
                    // - ignore the warning for now
                    this.SplitViewController.WeakDelegate = channelViewController;
                    if (webViewController.popover != null)
                        webViewController.popover.Dismiss(true);

                    // If a row has been selected, deselect it so that a row
                    // is not selected when viewing the info
                    NSIndexPath selectedRow = this.TableView.IndexPathForSelectedRow;
                    if (selectedRow != null)
                        this.TableView.DeselectRow(selectedRow, true);

                } else {
                    this.NavigationController.PushViewController(channelViewController, true);
                }

                // Give the VC the channel object through the interface method
                channelViewController.listViewControllerHandleObject(this, BNRFeedStore.channel);

            };

            rssType = ListViewControllerRSSType.BNRFeed;
            rssTypeControl = new UISegmentedControl(new string[]{"BNR", "Apple"});
            rssTypeControl.SelectedSegment = 0;

            if (UIDevice.CurrentDevice.CheckSystemVersion(7,0) || UIDevice.CurrentDevice.CheckSystemVersion(7,1))
                rssTypeControl.TintAdjustmentMode = UIViewTintAdjustmentMode.Normal;
            rssTypeControl.ValueChanged += (object sender, EventArgs e) => {
                rssType = (ListViewControllerRSSType)(int)rssTypeControl.SelectedSegment;
                if (rssType == ListViewControllerRSSType.Apple) {

                    BNRFeedStore.items.Clear();

                    // Alert to select number of songs
                    UIAlertView aiView = new UIAlertView("Get Top Songs", "Enter how many songs to get", null, "OK", null);
                    aiView.AlertViewStyle = UIAlertViewStyle.PlainTextInput;
                    aiView.GetTextField(0).Text = numberOfSongsToGet.ToString();
                    aiView.GetTextField(0).KeyboardType = UIKeyboardType.NumberPad;
                    aiView.WeakDelegate = this;
                    aiView.Show();

                    // Comment out if above is commented in
            //					this.TableView.ReloadData();
            //					fetchEntries();
                }
                else {
                    BNRFeedStore.items.Clear();
                    this.TableView.ReloadData();
                    fetchEntries();
                }
            };
            this.NavigationItem.TitleView = rssTypeControl;
            this.TableView.BackgroundColor = UIColor.Black;
            fetchEntries();
        }