private void BindRedditView(CachingViewHolder holder, SubredditItem item, int position) { holder.FindCachedViewById <TextView>(Resource.Id.TitleTextView).Text = item.Title.Replace("&", "&"); holder.FindCachedViewById <TextView>(Resource.Id.SubtitleTextView).Text = $"/r/{item.Url} • {item.Subscribers} Subscribers"; var addButton = holder.FindCachedViewById <View>(Resource.Id.AddButton); var addButtonVisibilityBinding = new Binding <bool, ViewStates>(item, () => item.IsFavorited, addButton, () => addButton.Visibility).ConvertSourceToTarget((flag) => flag ? ViewStates.Gone : ViewStates.Visible); holder.DeleteBinding(nameof(addButtonVisibilityBinding)); holder.SaveBinding(nameof(addButtonVisibilityBinding), addButtonVisibilityBinding); //addButton.SetCommand("Click", Vm.ToggleFavorite, item); var checkButton = holder.FindCachedViewById <View>(Resource.Id.CheckButton); var checkButtonVisibilityBinding = new Binding <bool, ViewStates>(item, () => item.IsFavorited, checkButton, () => checkButton.Visibility).ConvertSourceToTarget((flag) => !flag ? ViewStates.Gone : ViewStates.Visible); holder.DeleteBinding(nameof(checkButtonVisibilityBinding)); holder.SaveBinding(nameof(checkButtonVisibilityBinding), checkButtonVisibilityBinding); //checkButton.SetCommand("Click", Vm.ToggleFavorite, item); var toggleContainer = holder.FindCachedViewById <View>(Resource.Id.ToggleContainer); toggleContainer.SetCommand("Click", Vm.ToggleFavorite, item); }
private void BindViewHolder(CachingViewHolder Holder, Events card, int position) { _position = position; TextView _eventName = Holder.FindCachedViewById <TextView>(Resource.Id.eventSignUpTitle); TextView _eventTime = Holder.FindCachedViewById <TextView>(Resource.Id.eventSignUpDateTime); TextView _eventDescription = Holder.FindCachedViewById <TextView>(Resource.Id.eventSignUpDescription); Button _eventSignupButton = Holder.FindCachedViewById <Button>(Resource.Id.eventSignUpButton); if (card.IsSignedUp) { _eventSignupButton.Text = "Signed Up"; _eventSignupButton.Enabled = false; } _eventSignupButton.Click += (sender, clickEvent) => { card.IsSignedUp = true; _eventSignupButton.Text = "Signed Up"; _eventSignupButton.Enabled = false; Activity.RunOnUiThread(async() => await ViewModel.Signup(card)); }; Holder.DeleteBinding(_eventName); Holder.DeleteBinding(_eventTime); Holder.DeleteBinding(_eventDescription); var nameBinding = new Binding <string, string>( card, () => card.EventName, _eventName, () => _eventName.Text, BindingMode.OneWay); var timeBinding = new Binding <string, string>( card, () => card.EventTime, _eventTime, () => _eventTime.Text, BindingMode.OneWay ); var descriptionBinding = new Binding <string, string>( card, () => card.EventDescription, _eventDescription, () => _eventDescription.Text, BindingMode.OneWay ); Holder.SaveBinding(_eventName, nameBinding); Holder.SaveBinding(_eventTime, timeBinding); Holder.SaveBinding(_eventDescription, descriptionBinding); }
private void BindViewHolder(CachingViewHolder holder, GalleryItem item, int position) { var thumbnail = holder.FindCachedViewById <ImageViewAsync>(Resource.Id.Thumbnail); thumbnail.SetImageResource(global::Android.Resource.Color.Transparent); thumbnail.Post(() => { var height = item.BigThumbRatio * thumbnail.Width; var layoutParams = thumbnail.LayoutParameters; layoutParams.Height = (int)Math.Floor(height); thumbnail.LayoutParameters = layoutParams; }); holder.DeleteBinding(thumbnail); var imageBinding = new Binding <string, string>(item, () => item.BigThumbnail).WhenSourceChanges(() => { ImageService.Instance.LoadUrl(item.BigThumbnail).Into(thumbnail); }); holder.SaveBinding(thumbnail, imageBinding); var title = holder.FindCachedViewById <TextView>(Resource.Id.TitleTextView); title.Text = item.Title; var ups = holder.FindCachedViewById <TextView>(Resource.Id.UpsTextView); ups.Text = item.Ups.ToString(); var comments = holder.FindCachedViewById <TextView>(Resource.Id.CommentsTextView); comments.Text = item.CommentCount.ToString(); }
private void BindViewHolder(CachingViewHolder holder, Item item, int position) { var root = holder.FindCachedViewById <LinearLayout>(Resource.Id.LayoutRoot); if (item == _adapter.SelectedItem) { root.SetBackgroundColor(Color.Yellow); } else { root.SetBackgroundColor(Color.Transparent); } var text = holder.FindCachedViewById <TextView>(Resource.Id.ItemText); text.Text = item.Name; var check = holder.FindCachedViewById <CheckBox>(Resource.Id.ItemCheck); holder.DeleteBinding(check); var binding = new Binding <bool, bool>( item, () => item.IsToggled, check, () => check.Checked, BindingMode.TwoWay); holder.SaveBinding(check, binding); }
/*********************************************************************/ /* Child BindViewHolder */ /*********************************************************************/ private void ChildBindViewHolder(CachingViewHolder holder, Assignment assignment, int position) { TextView _assignmentName = holder.FindCachedViewById <TextView>(Resource.Id.AssignmentName); TextView _assignmentDate = holder.FindCachedViewById <TextView>(Resource.Id.AssignmentDate); TextView _assignmentGrade = holder.FindCachedViewById <TextView>(Resource.Id.AssignmentGrade); /* Delete the previous binding */ holder.DeleteBinding(_assignmentName); holder.DeleteBinding(_assignmentDate); holder.DeleteBinding(_assignmentGrade); /* Create new bindings and and save them */ var _nameBinding = new Binding <string, string> ( assignment, () => assignment.AssignmentName, _assignmentName, () => _assignmentName.Text ); var _dateBinding = new Binding <string, string> ( assignment, () => assignment.AssignmentDate, _assignmentDate, () => _assignmentDate.Text ); var _gradeBinding = new Binding <string, string> ( assignment, () => assignment.GradeScore, _assignmentGrade, () => _assignmentGrade.Text ); /* Save the binding */ holder.SaveBinding(_assignmentName, _nameBinding); holder.SaveBinding(_assignmentDate, _dateBinding); holder.SaveBinding(_assignmentGrade, _gradeBinding); }
private void BindViewHolder(CachingViewHolder holder, Offense offenseCard, int position) { TextView _titleView = holder.FindCachedViewById <TextView>(Resource.Id.infractionTitle); TextView _dateView = holder.FindCachedViewById <TextView>(Resource.Id.infractionDate); TextView _timeView = holder.FindCachedViewById <TextView>(Resource.Id.infractionTime); holder.DeleteBinding(_titleView); holder.DeleteBinding(_dateView); holder.DeleteBinding(_timeView); var _titleBinding = new Binding <string, string> ( offenseCard, () => offenseCard.OffenseTitle, _titleView, () => _titleView.Text, BindingMode.OneWay ); var _dateBinding = new Binding <string, string> ( offenseCard, () => offenseCard.OffenseDate, _dateView, () => _dateView.Text, BindingMode.OneWay ); var _timeBinding = new Binding <string, string> ( offenseCard, () => offenseCard.OffenseTime, _timeView, () => _timeView.Text, BindingMode.OneWay ); holder.SaveBinding(_titleView, _titleBinding); holder.SaveBinding(_dateView, _dateBinding); holder.SaveBinding(_timeView, _timeBinding); }
private void BindViewHolder(CachingViewHolder holder, StudentEvent studentEvent, int position) { TextView _time = holder.FindCachedViewById <TextView>(Resource.Id.studentScheduleEventTime); TextView _title = holder.FindCachedViewById <TextView>(Resource.Id.studentScheduleEventTitle); TextView _location = holder.FindCachedViewById <TextView>(Resource.Id.studentScheduleEventDescription); holder.DeleteBinding(_time); holder.DeleteBinding(_title); holder.DeleteBinding(_location); var _timeBinding = new Binding <string, string> ( studentEvent, () => studentEvent.EventTime, _time, () => _time.Text ); var _titleBinding = new Binding <string, string> ( studentEvent, () => studentEvent.Title, _title, () => _title.Text ); var _locationBinding = new Binding <string, string> ( studentEvent, () => studentEvent.Location, _location, () => _location.Text ); holder.SaveBinding(_time, _timeBinding); holder.SaveBinding(_title, _titleBinding); holder.SaveBinding(_location, _locationBinding); }
private void BindChildViewHolder(CachingViewHolder holder, ClassAttendance violation, int position) { TextView _violation = holder.FindCachedViewById <TextView>(Resource.Id.AttendancePenaltyListItem); holder.DeleteBinding(_violation); var _violationBinding = new Binding <string, string> ( violation, () => violation.Date, _violation, () => _violation.Text ); holder.SaveBinding(_violation, _violationBinding); }
private void BindViewHolder(CachingViewHolder holder, GalleryItem item, int position) { var layoutRoot = holder.ItemView; layoutRoot.Post(() => { var width = layoutRoot.Width; var layoutParams = layoutRoot.LayoutParameters; layoutParams.Height = width; layoutRoot.LayoutParameters = layoutParams; }); var thumbnailView = holder.FindCachedViewById<ImageViewAsync>(Resource.Id.Thumbnail); holder.DeleteBinding(thumbnailView); var thumbnailBinding = new Binding<string, string>(item, () => item.Thumbnail) .WhenSourceChanges(() => ImageService.Instance.LoadUrl(item.Thumbnail).Into(thumbnailView)); holder.SaveBinding(thumbnailView, thumbnailBinding); }
private void BindViewHolder(CachingViewHolder holder, GrabAndGoItem grabAndGoItem, int position) { TextView _textview = holder.FindCachedViewById <TextView>(Resource.Id.listItem); holder.DeleteBinding(_textview); var itemBinding = new Binding <string, string>( grabAndGoItem, () => grabAndGoItem.ItemName, _textview, () => _textview.Text, BindingMode.OneWay, "Closed" ); holder.SaveBinding(_textview, itemBinding); }
private void BindViewHolder(CachingViewHolder holder, FourWindsItem fourWindsItem, int position) { TextView _textview = holder.FindCachedViewById <TextView>(Resource.Id.listItem); holder.DeleteBinding(_textview); ImageView arrowIcon = holder.FindCachedViewById <ImageView>(Resource.Id.ShowGradesArrowIcon); var itemBinding = new Binding <string, string>( fourWindsItem, () => fourWindsItem.ItemName, _textview, () => _textview.Text, BindingMode.OneWay, "Closed" ); holder.SaveBinding(_textview, itemBinding); }
private void BindViewHolder(CachingViewHolder holder, GalleryItem item, int position) { var layoutRoot = holder.ItemView; layoutRoot.Post(() => { var width = layoutRoot.Width; var layoutParams = layoutRoot.LayoutParameters; layoutParams.Height = width; layoutRoot.LayoutParameters = layoutParams; }); var thumbnailView = holder.FindCachedViewById <ImageViewAsync>(Resource.Id.Thumbnail); thumbnailView.SetImageResource(global::Android.Resource.Color.Transparent); holder.DeleteBinding(thumbnailView); var thumbnailBinding = new Binding <string, string>(item, () => item.Thumbnail) .WhenSourceChanges(() => ImageService.Instance.LoadUrl(item.Thumbnail).Into(thumbnailView)); holder.SaveBinding(thumbnailView, thumbnailBinding); }
/*********************************************************************/ /* Bind ViewHolder */ /*********************************************************************/ private void BindViewHolder(CachingViewHolder holder, GradeCard gradeCard, int position) { _position = holder.AdapterPosition; LinearLayout _expandArea = holder.FindCachedViewById <LinearLayout>(Resource.Id.llExpandArea); /* Handle the closing of the previous recyclerview */ if (position == _expandedPosition) { /*DEBUG*/ //System.Diagnostics.Debug.Write("OPEN-POSITION(" + position + ")"); /*DEBUG*/ //System.Diagnostics.Debug.Write("OPEN-VH.POSITION(" + holder.AdapterPosition + ")"); holder.FindCachedViewById <ImageView>(Resource.Id.ShowGradesArrowIcon) .StartAnimation(_rotateArrow); _expandArea.Visibility = ViewStates.Visible; } else { /*DEBUG*/ //System.Diagnostics.Debug.Write("CLOSE-POSITION(" + position + ")"); /*DEBUG*/ //System.Diagnostics.Debug.Write("CLOSE-VH.POSITION(" + holder.AdapterPosition + ")"); Activity.RunOnUiThread(() => _expandArea.Visibility = ViewStates.Gone); } TextView _className = holder.FindCachedViewById <TextView>(Resource.Id.GradesCardClassName); TextView _courseGrade = holder.FindCachedViewById <TextView>(Resource.Id.CourseGrade); Button _showTeacher = holder.FindCachedViewById <Button>(Resource.Id.TeacherInfoButton); if (!_showTeacher.HasOnClickListeners) { _showTeacher.Tag = holder; _showTeacher.Click += ShowTeacherInfo; } Button _showGrades = holder.FindCachedViewById <Button>(Resource.Id.ShowGradesButton); if (!_showGrades.HasOnClickListeners) { _showGrades.Tag = holder; _showGrades.Click += ShowGrades; } /* Set up the child recyclerview for the assignments */ _assignmentsRecyclerView = holder.FindCachedViewById <RecyclerView>( Resource.Id.AssignmentsRecyclerView); /* Bind to the data */ _assignmentAdapter = gradeCard.ClassAssignments.GetRecyclerAdapter(ChildBindViewHolder, Resource.Layout.GradesAssignment); /* Set the nested recyclerview layout manager and adapter */ _assignmentsRecyclerView.SetLayoutManager(new LinearLayoutManager(Activity)); _assignmentsRecyclerView.SetAdapter(_assignmentAdapter); /* Delete the binding for memory purposes */ holder.DeleteBinding(_className); holder.DeleteBinding(_courseGrade); /* Create new binding and bind the properties to the view */ var _titleBinding = new Binding <string, string>( gradeCard, () => gradeCard.CourseTitle, _className, () => _className.Text, BindingMode.OneWay); var _gradeBinding = new Binding <string, string>( gradeCard, () => gradeCard.CourseGrade, _courseGrade, () => _courseGrade.Text, BindingMode.OneWay); /* Save the binding; remember to delete it later */ holder.SaveBinding(_className, _titleBinding); holder.SaveBinding(_courseGrade, _gradeBinding); }
private void BindViewHolder(CachingViewHolder holder, Course section, int position) { _position = holder.AdapterPosition; TextView _courseNumber = holder.FindCachedViewById <TextView>(Resource.Id.examClassNumber); TextView _courseName = holder.FindCachedViewById <TextView>(Resource.Id.examClassName); TextView _examDate = holder.FindCachedViewById <TextView>(Resource.Id.examDate); TextView _examTime = holder.FindCachedViewById <TextView>(Resource.Id.examTime); TextView _examLocation = holder.FindCachedViewById <TextView>(Resource.Id.examRoomLocation); /* Set the binding for the course code */ holder.DeleteBinding(_courseNumber); var numberBinding = new Binding <string, string>( section, () => section.FormattedCourseCode, _courseNumber, () => _courseNumber.Text, BindingMode.OneWay); holder.SaveBinding(_courseNumber, numberBinding); /* Set binding for the coursename */ holder.DeleteBinding(_courseName); var nameBinding = new Binding <string, string>( section, () => section.CourseName, _courseName, () => _courseName.Text, BindingMode.OneWay); holder.SaveBinding(_courseName, nameBinding); /* Set binding for the exam date */ holder.DeleteBinding(_examDate); var dateBinding = new Binding <string, string>( section, () => section.ExamDay, _examDate, () => _examDate.Text, BindingMode.OneWay); holder.SaveBinding(_examDate, dateBinding); /* Set binding for exam time */ holder.DeleteBinding(_examTime); var timeBinding = new Binding <string, string>( section, () => section.ExamTime, _examTime, () => _examTime.Text, BindingMode.OneWay); holder.SaveBinding(_examTime, timeBinding); /*Set the binding for the exam location*/ holder.DeleteBinding(_examLocation); var locationBinding = new Binding <string, string>( section, () => section.Location, _examLocation, () => _examLocation.Text, BindingMode.OneWay); holder.SaveBinding(_examLocation, locationBinding); }
private void BindViewHolder(CachingViewHolder holder, GalleryItem item, int position) { var thumbnail = holder.FindCachedViewById<ImageViewAsync>(Resource.Id.Thumbnail); thumbnail.Post(() => { var height = item.BigThumbRatio * thumbnail.Width; var layoutParams = thumbnail.LayoutParameters; layoutParams.Height = (int)Math.Floor(height); thumbnail.LayoutParameters = layoutParams; }); holder.DeleteBinding(thumbnail); var imageBinding = new Binding<string, string>(item, () => item.BigThumbnail).WhenSourceChanges(() => { ImageService.Instance.LoadUrl(item.BigThumbnail).Into(thumbnail); }); holder.SaveBinding(thumbnail, imageBinding); var title = holder.FindCachedViewById<TextView>(Resource.Id.TitleTextView); title.Text = item.Title; var ups = holder.FindCachedViewById<TextView>(Resource.Id.UpsTextView); ups.Text = item.Ups.ToString(); var comments = holder.FindCachedViewById<TextView>(Resource.Id.CommentsTextView); comments.Text = item.CommentCount.ToString(); }
private void BindViewHolder(CachingViewHolder holder, AttendanceCard course, int position) { TextView _classNameTextView = holder.FindCachedViewById <TextView>(Resource.Id.attendanceClassName); TextView _absenceNumber = holder.FindCachedViewById <TextView>(Resource.Id.attendanceClassUnexcusedNumber); TextView _pendingAbsenceNumber = holder.FindCachedViewById <TextView>(Resource.Id.AttendancePendingUnexcusedNumber); TextView _tardyNumber = holder.FindCachedViewById <TextView>(Resource.Id.AttendanceTardiesNumber); TextView _pendingTardyNumber = holder.FindCachedViewById <TextView>(Resource.Id.AttendancePendingTardiesNumber); /* Set up the children recyclerviews */ SetUpRecyclerViews(holder, course); /* Delete the binding */ holder.DeleteBinding(_classNameTextView); holder.DeleteBinding(_absenceNumber); holder.DeleteBinding(_pendingAbsenceNumber); holder.DeleteBinding(_tardyNumber); holder.DeleteBinding(_pendingTardyNumber); /* Create a new binding and save it */ var _classNameBinding = new Binding <string, string> ( course, () => course.CourseName, _classNameTextView, () => _classNameTextView.Text ); var _absenceNumberBinding = new Binding <string, string> ( course, () => course.Absences, _absenceNumber, () => _absenceNumber.Text ); var _pendingAbsenceNumberBinding = new Binding <string, string> ( course, () => course.PendingAbsences, _pendingAbsenceNumber, () => _pendingAbsenceNumber.Text ); var _tardyNumberBinding = new Binding <string, string> ( course, () => course.Tardies, _tardyNumber, () => _tardyNumber.Text ); var _pendingTardyNumberBinding = new Binding <string, string> ( course, () => course.PendingTardies, _pendingTardyNumber, () => _pendingTardyNumber.Text ); holder.SaveBinding(_classNameTextView, _classNameBinding); holder.SaveBinding(_absenceNumber, _absenceNumberBinding); holder.SaveBinding(_pendingAbsenceNumber, _pendingAbsenceNumberBinding); holder.SaveBinding(_tardyNumber, _tardyNumberBinding); holder.SaveBinding(_pendingTardyNumber, _pendingTardyNumberBinding); }
private void BindRedditView(CachingViewHolder holder, SubredditItem item, int position) { holder.FindCachedViewById<TextView>(Resource.Id.TitleTextView).Text = item.Title.Replace("&", "&"); holder.FindCachedViewById<TextView>(Resource.Id.SubtitleTextView).Text = $"/r/{item.Url} • {item.Subscribers} Subscribers"; var addButton = holder.FindCachedViewById<View>(Resource.Id.AddButton); var addButtonVisibilityBinding = new Binding<bool, ViewStates>(item, () => item.IsFavorited, addButton, () => addButton.Visibility).ConvertSourceToTarget((flag) => flag ? ViewStates.Gone : ViewStates.Visible); holder.DeleteBinding(nameof(addButtonVisibilityBinding)); holder.SaveBinding(nameof(addButtonVisibilityBinding), addButtonVisibilityBinding); //addButton.SetCommand("Click", Vm.ToggleFavorite, item); var checkButton = holder.FindCachedViewById<View>(Resource.Id.CheckButton); var checkButtonVisibilityBinding = new Binding<bool, ViewStates>(item, () => item.IsFavorited, checkButton, () => checkButton.Visibility).ConvertSourceToTarget((flag) => !flag ? ViewStates.Gone : ViewStates.Visible); holder.DeleteBinding(nameof(checkButtonVisibilityBinding)); holder.SaveBinding(nameof(checkButtonVisibilityBinding), checkButtonVisibilityBinding); //checkButton.SetCommand("Click", Vm.ToggleFavorite, item); var toggleContainer = holder.FindCachedViewById<View>(Resource.Id.ToggleContainer); toggleContainer.SetCommand("Click", Vm.ToggleFavorite, item); }