Beispiel #1
0
 void OnAircraftUpdateFailed(object sender, AircraftEventArgs e)
 {
     if (updating != null)
     {
         updating.Dispose();
         updating = null;
     }
 }
Beispiel #2
0
        void OnAircraftUpdated(object sender, AircraftEventArgs e)
        {
            if (updating == null)
            {
                // The user probably just saved an aircraft which doesn't match the search criteria.
                Model.ReloadData();
                TableView.ReloadData();
                return;
            }

            // No matter what, reload the main model.
            Model.ReloadData();

            // Now update the UITableView that is currently being displayed.
            var tableView = CurrentTableView;
            var model     = ModelForTableView(tableView);

            // The date may have changed, which means the position may have changed.
            model.ReloadData();

            // Find the new position of the flight log entry.
            int index = model.IndexOf(e.Aircraft, this);
            int section, row;

            if (index == -1 || !model.IndexToSectionAndRow(index, out section, out row))
            {
                // The aircraft no longer exists in this model (doesn't match search criteria?)
                var rows = new NSIndexPath[1];
                rows[0] = updating;

                tableView.DeleteRows(rows, UITableViewRowAnimation.Automatic);
            }
            else
            {
                // Reload the row.
                var rows = new NSIndexPath[1];
                rows[0] = updating;

                tableView.ReloadRows(rows, UITableViewRowAnimation.None);
            }

            // If the currently displayed UITableView isn't the main view, reset state of the main tableview.
            if (tableView != TableView)
            {
                TableView.ReloadData();
            }

            updating.Dispose();
            updating = null;
        }
Beispiel #3
0
        void OnAircraftAdded(object sender, AircraftEventArgs e)
        {
            var tableView = CurrentTableView;
            var model     = ModelForTableView(tableView);

            DetailsViewController.Aircraft = e.Aircraft;
            model.ReloadData();

            int index = model.IndexOf(e.Aircraft, this);

            if (index == -1)
            {
                // This suggests that we are probably displaying the search view and the
                // newly added aircraft does not match the search criteria.

                // Just reload the original TableView...
                Model.ReloadData();
                TableView.ReloadData();
                return;
            }

            int section, row;

            if (!model.IndexToSectionAndRow(index, out section, out row))
            {
                // This shouldn't happen...
                model.ReloadData();
                tableView.ReloadData();
                return;
            }

            NSIndexPath path = NSIndexPath.FromRowSection(row, section);

            // Add the row to the table...
            tableView.InsertRows(new [] { path }, UITableViewRowAnimation.Automatic);

            // Select and scroll to the newly added aircraft...

            // From Apple's documentation:
            //
            // To scroll to the newly selected row with minimum scrolling, select the row using
            // selectRowAtIndexPath:animated:scrollPosition: with UITableViewScrollPositionNone,
            // then call scrollToRowAtIndexPath:atScrollPosition:animated: with
            // UITableViewScrollPositionNone.
            tableView.SelectRow(path, true, UITableViewScrollPosition.None);
            tableView.ScrollToRow(path, UITableViewScrollPosition.None, true);
            path.Dispose();
        }
        void OnAircraftAdded(object sender, AircraftEventArgs added)
        {
            AircraftElement element = new AircraftElement(added.Aircraft);

            element.Changed += OnElementChanged;

            // Disengage search before adding to the list
            FinishSearch();

            Root[0].Add(element);
            Root.Reload(Root[0], UITableViewRowAnimation.Fade);

            // Select the aircraft we just added
            NSIndexPath path = element.IndexPath;

            SelectRow(path, true, UITableViewScrollPosition.Bottom);
        }
Beispiel #5
0
        void OnAircraftWillUpdate(object sender, AircraftEventArgs e)
        {
            var tableView = CurrentTableView;
            var model     = ModelForTableView(tableView);

            updating = PathForVisibleItem(tableView, e.Aircraft);
            if (updating != null)
            {
                // We're done.
                return;
            }

            // Otherwise we gotta do things the hard way...
            int index = model.IndexOf(e.Aircraft, this);
            int section, row;

            if (index == -1 || !model.IndexToSectionAndRow(index, out section, out row))
            {
                return;
            }

            updating = NSIndexPath.FromRowSection(row, section);
        }
 void AircraftChanged(object sender, AircraftEventArgs e)
 {
     dirty = true;
 }
Beispiel #7
0
 void AircraftChanged(object sender, AircraftEventArgs e)
 {
     dirty = true;
 }
        void OnAircraftAdded(object sender, AircraftEventArgs added)
        {
            AircraftElement element = new AircraftElement (added.Aircraft);

            element.Changed += OnElementChanged;

            // Disengage search before adding to the list
            FinishSearch ();

            Root[0].Add (element);
            Root.Reload (Root[0], UITableViewRowAnimation.Fade);

            // Select the aircraft we just added
            NSIndexPath path = element.IndexPath;
            SelectRow (path, true, UITableViewScrollPosition.Bottom);
        }