/* Add each assignment to the appropriate card */ public void GetGradeCards() { foreach (var course in Classes) { GradeCard current = new GradeCard(course); foreach (var assignment in Assignments) { if (assignment.CourseId == current.CourseId) { current.AddAssignment(assignment); } } foreach (var hour in ProfessorsHours) { if (current.ProfessorId == hour.ProfessorId) { current.ProfessorsHours.Add(hour); } if (current.ProfessorsHours.Count == 2) { break; } } Grades.Add(current); } var _tempGrades = new ObservableCollection <GradeCard>(Grades.OrderByDescending(x => x.ClassAssignments[0].AssignmentDate)); Grades.Clear(); foreach (var item in _tempGrades) { Grades.Add(item); } /* Sort the classes based off of the most recently updated assignment */ //Grades.Sort((x, y) => DateTimeOffset.Compare(x.ClassAssignments[0].UpdatedAt, y.ClassAssignments[0].UpdatedAt)); }
public void InitializeStatic() { Grades = new ObservableCollection <GradeCard>(); for (int counter = 0; counter < 15; counter++) { GradeCard current = new GradeCard() { CourseTitle = "CS 452 Software Engineering Project II", }; for (int index = 0; index < 4; index++) { Assignment currentAssignment = new Assignment() { AssignmentName = "Quiz " + index, AssignmentDate = "4/12/2017", GradeScore = "100" }; current.AddAssignment(currentAssignment); } Grades.Add(current); } }
/*********************************************************************/ /* 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); }