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 IPriceTileCell GetCell(UITableView tableView, PriceTileModel model)
        {
            IPriceTileCell priceTileCell = null;

            switch (model.Status)
            {
            case PriceTileStatus.Done:
            case PriceTileStatus.DoneStale:
                priceTileCell = tableView.DequeueReusableCell(PriceTileTradeAffirmationViewCell.Key) as PriceTileTradeAffirmationViewCell;
                if (priceTileCell == null)
                {
                    priceTileCell = PriceTileTradeAffirmationViewCell.Create();
                }
                break;

            case PriceTileStatus.Streaming:
            case PriceTileStatus.Executing:
                priceTileCell = tableView.DequeueReusableCell(PriceTileViewCell.Key) as PriceTileViewCell;
                if (priceTileCell == null)
                {
                    priceTileCell = PriceTileViewCell.Create();
                }
                break;

            case PriceTileStatus.Stale:
                priceTileCell = tableView.DequeueReusableCell(PriceTileErrorViewCell.Key) as PriceTileViewCell;
                if (priceTileCell == null)
                {
                    priceTileCell = PriceTileErrorViewCell.Create();
                }
                break;
            }

            return(priceTileCell);
        }
        private static bool ShouldUpdateCell(PriceTileStatus status, IPriceTileCell cell)
        {
            switch (status) {
                case PriceTileStatus.Done:
                case PriceTileStatus.DoneStale:

                    if (cell is PriceTileTradeAffirmationViewCell) {
                        return true;
                    }

                    break;

                case PriceTileStatus.Streaming:
                case PriceTileStatus.Executing:

                    if (cell is PriceTileViewCell) {
                        return true;
                    }

                    break;

                case PriceTileStatus.Stale:

                    if (cell is PriceTileErrorViewCell) {
                        return true;
                    }

                    break;
            }

            return false;
        }
        private static bool ShouldUpdateCell(PriceTileStatus status, IPriceTileCell cell)
        {
            switch (status)
            {
            case PriceTileStatus.Done:
            case PriceTileStatus.DoneStale:

                if (cell is PriceTileTradeAffirmationViewCell)
                {
                    return(true);
                }

                break;

            case PriceTileStatus.Streaming:
            case PriceTileStatus.Executing:

                if (cell is PriceTileViewCell)
                {
                    return(true);
                }

                break;

            case PriceTileStatus.Stale:

                if (cell is PriceTileErrorViewCell)
                {
                    return(true);
                }

                break;
            }

            return(false);
        }
Ejemplo n.º 5
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);
                    }
                }
            }
        }