Skip to content

Commit f71843a

Browse files
two bugs fixed
1 parent 610d9f1 commit f71843a

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

app/src/main/java/edu/sharif/homework1/AddToClassFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public void onDestroyView() {
9191

9292
@Override
9393
public void onItemClick(View view, int position) {
94-
Class newClass = Class.classes.get(position);
94+
Class newClass = Class.getClassByName(classesName.get(position));
9595
if(!student.getClasses().contains(newClass)){
9696
newClass.addStudent(student.getUsername(), getActivity());
9797
student.addClass(newClass, getActivity(), false);

app/src/main/java/edu/sharif/homework1/StudentPanelFragment.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,13 @@ public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
6868
} else if (!classesName.contains(searchText)) {
6969
Toast.makeText(getContext(), "Class not found", Toast.LENGTH_SHORT).show();
7070
} else {
71-
// NavHostFragment.findNavController(StudentPanelFragment.this)
72-
// .navigate(StudentPanelFragmentDirections.
73-
// actionStudentPanelFragmentToStudentClassPage());
71+
String className = searchText.split(" - ")[0];
72+
String professorUsername = searchText.split(" - ")[1];
73+
74+
NavHostFragment.findNavController(StudentPanelFragment.this)
75+
.navigate(StudentPanelFragmentDirections.
76+
actionStudentPanelFragmentToStudentClassPage(username, professorUsername,
77+
className));
7478
}
7579
});
7680

@@ -99,6 +103,7 @@ public void onItemClick(View view, int position) {
99103

100104
NavHostFragment.findNavController(StudentPanelFragment.this)
101105
.navigate(StudentPanelFragmentDirections.
102-
actionStudentPanelFragmentToStudentClassPage(username, professorUsername, className));
106+
actionStudentPanelFragmentToStudentClassPage(username, professorUsername,
107+
className));
103108
}
104109
}

0 commit comments

Comments
 (0)