public override View GetView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = inflater.Inflate(Resource.Layout.search_results_item, null); } Itinerary itinerary = GetItineraryAtPosition(position); DateTime startDate = itinerary.GetStartDate(); DateTime now = DateTime.Now; CancelView btnDelete = convertView.FindViewById <CancelView> (Resource.Id.search_result_item_btn_cancel); string dayDisplay = ""; string timeDisplay = startDate.ToLocalTime().ToString("h:mm tt"); string durationDisplay = itinerary.GetDuration_min() + " min"; string titleDisplay = itinerary.GetFirstAgencyName(); string subtitleDisplay = ""; btnDelete.Visibility = ViewStates.Gone; if (itinerary.legs.Count > 0) { Leg leg = itinerary.legs.ElementAt(itinerary.legs.Count - 1); subtitleDisplay = leg.agencyName; } if (now.Day == startDate.Day) { dayDisplay = "Today"; } else if (now.Day + 1 == startDate.Day) { dayDisplay = "Tomorrow"; } else { dayDisplay = startDate.ToString("M/dd/yy"); } TextView tvDay = convertView.FindViewById <TextView> (Resource.Id.search_result_item_tv_day); TextView tvTime = convertView.FindViewById <TextView> (Resource.Id.search_result_item_tv_time); TextView tvDuration = convertView.FindViewById <TextView> (Resource.Id.search_result_item_tv_duration); TextView tvTitle = convertView.FindViewById <TextView> (Resource.Id.search_result_item_tv_title); TextView tvSubtitle = convertView.FindViewById <TextView> (Resource.Id.search_result_item_tv_subtitle); tvDay.Text = dayDisplay; tvTime.Text = timeDisplay; tvDuration.Text = durationDisplay; tvTitle.Text = titleDisplay; tvSubtitle.Text = subtitleDisplay; return(convertView); }
public override View GetView(int position, View convertView, ViewGroup parent) { convertView = base.GetView(position, convertView, parent); Trip trip = GetTripAtPosition(position); DateTime now = DateTime.Now; DateTime startDate = trip.TripStartDate; View item = convertView.FindViewById <View> (Resource.Id.search_result_item_ll_details); CancelView btnCancel = convertView.FindViewById <CancelView> (Resource.Id.search_result_item_btn_cancel); //btnCancel.Visibility = cancelable ? ViewStates.Visible : ViewStates.Gone; //btnCancel.Enabled = now.Day != startDate.Day; //if (now.Day == startDate.Day) { // btnCancel.SetBackgroundColor (Color.DarkGray); //} //btnCancel.SetOnClickListener (new OnCancelClickListener (trip, tripSelector)); item.SetOnClickListener(new OnSelectClickListener(trip, tripSelector)); return(convertView); }
public override View GetView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = inflater.Inflate(Resource.Layout.search_results_item, null); } Trip trip = GetTripAtPosition(position); DateTime startDate = trip.TripStartDate; DateTime now = DateTime.Now; string dayDisplay = ""; string timeDisplay = startDate.ToLocalTime().ToString("h:mm tt"); string durationDisplay = trip.Duration_min() + " min"; string titleDisplay = trip.Destination; string subtitleDisplay = ""; try { subtitleDisplay = trip.GetFirstStepString(); }catch { } /*int walkMode = 1; * if (trip.Steps.Count > 0) { * Step step = trip.Steps.ElementAt (0); * if (step.ModeId==walkMode) { * subtitleDisplay = "Walk"; * } else { * subtitleDisplay = step.FromProviderId + " " + step.FromName; * } * }*/ if (now.Day == startDate.Day) { dayDisplay = "Today"; } else if (now.Day + 1 == startDate.Day) { dayDisplay = "Tomorrow"; } else { dayDisplay = startDate.ToString("M/dd/yy"); } CancelView btnCancel = convertView.FindViewById <CancelView> (Resource.Id.search_result_item_btn_cancel); //btnCancel.Visibility = cancelable ? ViewStates.Visible : ViewStates.Gone; btnCancel.Visibility = ViewStates.Gone; btnCancel.Enabled = false; TextView tvDay = convertView.FindViewById <TextView> (Resource.Id.search_result_item_tv_day); TextView tvTime = convertView.FindViewById <TextView> (Resource.Id.search_result_item_tv_time); TextView tvDuration = convertView.FindViewById <TextView> (Resource.Id.search_result_item_tv_duration); TextView tvTitle = convertView.FindViewById <TextView> (Resource.Id.search_result_item_tv_title); TextView tvSubtitle = convertView.FindViewById <TextView> (Resource.Id.search_result_item_tv_subtitle); tvDay.Text = dayDisplay; tvTime.Text = timeDisplay; tvDuration.Text = durationDisplay; tvTitle.Text = titleDisplay; tvSubtitle.Text = subtitleDisplay; return(convertView); }