상속: UITableViewCell
예제 #1
0
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            if (ViewModel.CanLoadMore && !ViewModel.IsBusy && ViewModel.Trips.Count > 0 && indexPath.Row == ViewModel.Trips.Count - 1)
            {
                ViewModel.ExecuteLoadMorePastTripsCommandAsync().ContinueWith((t) =>
                {
                    InvokeOnMainThread(delegate { TableView.ReloadData(); });
                }, scheduler: System.Threading.Tasks.TaskScheduler.Current);
            }

            var trip = ViewModel.Trips[indexPath.Row];

            if (string.IsNullOrEmpty(trip.MainPhotoUrl))
            {
                var cell = tableView.DequeueReusableCell(TripCellIdentifier) as TripTableViewCell;

                if (cell == null)
                {
                    cell = new TripTableViewCell(new NSString(TripCellIdentifier));
                }

                cell.LocationName = trip.Name;
                cell.TimeAgo      = trip.TimeAgo;
                cell.Distance     = trip.TotalDistance;

                return(cell);
            }
            else
            {
                var cell = tableView.DequeueReusableCell(TripCellWithImageIdentifier) as TripTableViewCellWithImage;

                if (cell == null)
                {
                    cell = new TripTableViewCellWithImage(new NSString(TripCellWithImageIdentifier));
                }

                cell.DisplayImage.SetImage(new NSUrl(trip.MainPhotoUrl));
                cell.LocationName = trip.Name;
                cell.TimeAgo      = trip.TimeAgo;
                cell.Distance     = trip.TotalDistance;

                return(cell);
            }
        }
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
			if (ViewModel.CanLoadMore && !ViewModel.IsBusy && ViewModel.Trips.Count > 0 && indexPath.Row == ViewModel.Trips.Count - 1)
			{
				ViewModel.ExecuteLoadMorePastTripsCommandAsync().ContinueWith((t) =>
				{
					InvokeOnMainThread(delegate { TableView.ReloadData(); });
				}, scheduler: System.Threading.Tasks.TaskScheduler.Current);
			}

			var trip = ViewModel.Trips[indexPath.Row];
			if (string.IsNullOrEmpty(trip.MainPhotoUrl))
			{
				var cell = tableView.DequeueReusableCell(TripCellIdentifier) as TripTableViewCell;

				if (cell == null)
				{
					cell = new TripTableViewCell(new NSString(TripCellIdentifier));
				}

				cell.LocationName = trip.Name;
				cell.TimeAgo = trip.TimeAgo;
				cell.Distance = trip.TotalDistance;

				return cell;
			}
			else
			{
				var cell = tableView.DequeueReusableCell(TripCellWithImageIdentifier) as TripTableViewCellWithImage;

				if (cell == null)
				{
					cell = new TripTableViewCellWithImage(new NSString(TripCellWithImageIdentifier));
				}

				cell.DisplayImage.SetImage(new NSUrl(trip.MainPhotoUrl));
				cell.LocationName = trip.Name;
				cell.TimeAgo = trip.TimeAgo;
				cell.Distance = trip.TotalDistance;

				return cell;
			}
        }