diff --git a/app/src/main/java/tk/therealsuji/vtopchennai/adapters/CoursesItemAdapter.java b/app/src/main/java/tk/therealsuji/vtopchennai/adapters/CoursesItemAdapter.java index 4751cba..2528a9b 100644 --- a/app/src/main/java/tk/therealsuji/vtopchennai/adapters/CoursesItemAdapter.java +++ b/app/src/main/java/tk/therealsuji/vtopchennai/adapters/CoursesItemAdapter.java @@ -129,6 +129,7 @@ public void setCourseTitle(String courseTitle, boolean theory, boolean lab, bool ChipGroup courseTypes = this.courseItem.findViewById(R.id.chip_group_course_types); title.setText(courseTitle); + courseTypes.removeAllViews(); if (theory) { Chip chip = new Chip(this.courseItem.getContext()); @@ -159,9 +160,7 @@ public void setCourseItem(Course.AllData courseItem) { TextView faculty = this.courseItem.findViewById(R.id.text_view_faculty); TextView venue = this.courseItem.findViewById(R.id.text_view_venue); TextView attendanceText = this.courseItem.findViewById(R.id.text_view_attendance); - ChipGroup slots = this.courseItem.findViewById(R.id.chip_group_slots); - ProgressBar attendanceProgress = this.courseItem.findViewById(R.id.progress_bar_attendance); faculty.setText(Html.fromHtml(this.courseItem.getContext().getString(R.string.faculty, courseItem.faculty), Html.FROM_HTML_MODE_LEGACY)); @@ -175,6 +174,8 @@ public void setCourseItem(Course.AllData courseItem) { chipIconResource = R.drawable.ic_project; } + slots.removeAllViews(); + for (int i = 0; i < courseItem.slots.size(); ++i) { Chip slot = new Chip(this.courseItem.getContext()); slot.setChipIconResource(chipIconResource); diff --git a/app/src/main/java/tk/therealsuji/vtopchennai/adapters/MarksAdapter.java b/app/src/main/java/tk/therealsuji/vtopchennai/adapters/MarksAdapter.java index c50e18b..f3f331e 100644 --- a/app/src/main/java/tk/therealsuji/vtopchennai/adapters/MarksAdapter.java +++ b/app/src/main/java/tk/therealsuji/vtopchennai/adapters/MarksAdapter.java @@ -107,7 +107,6 @@ public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newStat } private void addChips() { - this.courseTypes.removeAllViews(); List courseTypes = new ArrayList<>(); if (this.marks.containsKey("theory")) { @@ -121,6 +120,8 @@ private void addChips() { if (this.marks.containsKey("project")) { courseTypes.add("project"); } + + this.courseTypes.removeAllViews(); for (int i = 0; i < this.marks.size(); ++i) { String courseType = courseTypes.get(i); diff --git a/app/src/main/java/tk/therealsuji/vtopchennai/adapters/MarksItemAdapter.java b/app/src/main/java/tk/therealsuji/vtopchennai/adapters/MarksItemAdapter.java index e4d80c6..b21ab7c 100644 --- a/app/src/main/java/tk/therealsuji/vtopchennai/adapters/MarksItemAdapter.java +++ b/app/src/main/java/tk/therealsuji/vtopchennai/adapters/MarksItemAdapter.java @@ -66,11 +66,13 @@ public ViewHolder(@NonNull View itemView) { } public void setMarksItem(Mark.AllData marksItem) { - LinearLayout markDetails = this.marksItem.findViewById(R.id.linear_layout_details); AppCompatTextView markTitle = this.marksItem.findViewById(R.id.text_view_title); + AppCompatTextView averageText = this.marksItem.findViewById(R.id.text_view_average); + AppCompatTextView statusText = this.marksItem.findViewById(R.id.text_view_status); AppCompatTextView scoreText = this.marksItem.findViewById(R.id.text_view_score); ProgressBar scoreProgress = this.marksItem.findViewById(R.id.progress_bar_score); AppCompatTextView markType = this.marksItem.findViewById(R.id.text_view_mark_type); + Chip courseType = this.marksItem.findViewById(R.id.chip_course_type); markTitle.setText(marksItem.title); @@ -115,21 +117,19 @@ public void onLayoutChange(View view, int i, int i1, int i2, int i3, int i4, int } if (marksItem.average != null) { - markDetails.addView(this.createTextView(this.marksItem.getContext().getString(R.string.average, marksItem.average))); + averageText.setText(Html.fromHtml(this.marksItem.getContext().getString(R.string.average, marksItem.average), Html.FROM_HTML_MODE_LEGACY)); + averageText.setVisibility(View.VISIBLE); + } else { + averageText.setVisibility(View.GONE); } if (marksItem.status != null) { - markDetails.addView(this.createTextView(this.marksItem.getContext().getString(R.string.status, marksItem.status))); + statusText.setText(Html.fromHtml(this.marksItem.getContext().getString(R.string.status, marksItem.status), Html.FROM_HTML_MODE_LEGACY)); + statusText.setVisibility(View.VISIBLE); + } else { + statusText.setVisibility(View.GONE); } - Chip courseType = new Chip(this.marksItem.getContext()); - courseType.setClickable(false); - courseType.setFocusable(false); - courseType.setLayoutParams(new LinearLayout.LayoutParams( - LinearLayout.LayoutParams.WRAP_CONTENT, - LinearLayout.LayoutParams.WRAP_CONTENT - )); - if (marksItem.courseType.equals("lab")) { courseType.setChipIconResource(R.drawable.ic_lab); courseType.setText(R.string.lab); @@ -140,16 +140,6 @@ public void onLayoutChange(View view, int i, int i1, int i2, int i3, int i4, int courseType.setChipIconResource(R.drawable.ic_theory); courseType.setText(R.string.theory); } - - markDetails.addView(courseType); - } - - AppCompatTextView createTextView(String text) { - AppCompatTextView textView = new AppCompatTextView(this.marksItem.getContext()); - textView.setText(Html.fromHtml(text, Html.FROM_HTML_MODE_LEGACY)); - textView.setTextSize(16); - - return textView; } } } diff --git a/app/src/main/res/layout/layout_item_marks.xml b/app/src/main/res/layout/layout_item_marks.xml index 3511be8..c966838 100644 --- a/app/src/main/res/layout/layout_item_marks.xml +++ b/app/src/main/res/layout/layout_item_marks.xml @@ -15,7 +15,6 @@ android:paddingBottom="20dp"> + + + + + +