Search in sources :

Example 1 with StudentViewModel

use of com.shu.studentmanager.viewmodel.StudentViewModel in project student-manager by SYYANI.

the class StudentFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    studentViewModel = new ViewModelProvider(this).get(StudentViewModel.class);
    studentFragmentBinding = DataBindingUtil.inflate(inflater, R.layout.student_fragment, container, false);
    studentFragmentBinding.setStudentViewModel(studentViewModel);
    studentFragmentBinding.setLifecycleOwner(getActivity());
    StudentManagerApplication application = (StudentManagerApplication) getActivity().getApplication();
    studentFragmentBinding.studentFragmentStudentId.setText(application.getId());
    studentFragmentBinding.studentFragmentStudentName.setText(application.getName());
    student_course_list_recyclerview = studentFragmentBinding.studentFragmentCourseListRecycleview;
    setStudentCoureListRecycleView();
    View root = studentFragmentBinding.getRoot();
    try {
        initStudentCourseList();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return root;
// return inflater.inflate(R.layout.student_fragment, container, false);
}
Also used : IOException(java.io.IOException) StudentManagerApplication(com.shu.studentmanager.StudentManagerApplication) StudentViewModel(com.shu.studentmanager.viewmodel.StudentViewModel) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) ViewModelProvider(androidx.lifecycle.ViewModelProvider)

Aggregations

View (android.view.View)1 ViewModelProvider (androidx.lifecycle.ViewModelProvider)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 StudentManagerApplication (com.shu.studentmanager.StudentManagerApplication)1 StudentViewModel (com.shu.studentmanager.viewmodel.StudentViewModel)1 IOException (java.io.IOException)1