private void OnItemChanged(PriceTileModel itemModel)
        {
            if (IsViewLoaded)
            {
                var indexOfItem = _model.ActiveCurrencyPairs.IndexOf(itemModel);

                NSIndexPath    path = NSIndexPath.FromRowSection(indexOfItem, 0);
                IPriceTileCell cell = (IPriceTileCell)TableView.CellAt(path);

                if (cell != null)
                {
                    // TODO: Batch the updates up, to only call ReloadRows once per main event loop loop?

                    if (ShouldUpdateCell(itemModel.Status, cell))
                    {
                        //						System.Console.WriteLine ("Cell is APPROPRIATE", indexOfItem);
                        cell.UpdateFrom(itemModel);
                    }
                    else
                    {
                        TableView.ReloadRows(
                            new [] {
                            NSIndexPath.Create(0, indexOfItem)
                        }, UITableViewRowAnimation.None);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void OnItemChanged(PriceTileModel itemModel)
        {
            if (IsViewLoaded)
            {
                var indexOfItem = _model.ActiveCurrencyPairs.IndexOf(itemModel);

                NSIndexPath    path = NSIndexPath.FromRowSection(indexOfItem, 0);
                IPriceTileCell cell = (IPriceTileCell)TableView.CellAt(path);

                if (cell == null)
                {
                    //					System.Console.WriteLine ("Row {0} not found", indexOfItem);
                    // There's no cell bound to that index in the data, so we can ignore the update.
                }
                else
                {
                    //					System.Console.WriteLine ("Row {0} FOUND {1}", indexOfItem, cell.GetType ().ToString ());

                    bool bAppropriateCell = false;                     // TODO: Refactor this elsewhere.

                    switch (itemModel.Status)
                    {
                    case PriceTileStatus.Done:
                    case PriceTileStatus.DoneStale:
                        if (cell.GetType().Equals(Type.GetType("Adaptive.ReactiveTrader.Client.iOSTab.PriceTileTradeAffirmationViewCell", false)))
                        {
                            bAppropriateCell = true;
                        }
                        break;

                    case PriceTileStatus.Streaming:
                    case PriceTileStatus.Executing:
                        if (cell.GetType().Equals(Type.GetType("Adaptive.ReactiveTrader.Client.iOSTab.PriceTileViewCell", false)))
                        {
                            bAppropriateCell = true;
                        }
                        break;

                    case PriceTileStatus.Stale:
                        if (cell.GetType().Equals(Type.GetType("Adaptive.ReactiveTrader.Client.iOSTab.PriceTileErrorViewCell", false)))
                        {
                            bAppropriateCell = true;
                        }
                        break;
                    }

                    // TODO: Batch the updates up, to only call ReloadRows once per main event loop loop?

                    if (bAppropriateCell)
                    {
                        //						System.Console.WriteLine ("Cell is APPROPRIATE", indexOfItem);
                        cell.UpdateFrom(itemModel);
                    }
                    else
                    {
                        // TODO: If the cell is of the wrong type, reload the row instead.

                        TableView.ReloadRows(
                            new [] {
                            NSIndexPath.Create(0, indexOfItem)
                        }, UITableViewRowAnimation.None);
                    }
                }
            }
        }