Search in sources :

Example 1 with TeacherViewModel

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

the class TeacherFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    teacherViewModel = new ViewModelProvider(this).get(TeacherViewModel.class);
    teacherFragmentBinding = DataBindingUtil.inflate(inflater, R.layout.teacher_fragment, container, false);
    teacherFragmentBinding.setTeacherViewModel(teacherViewModel);
    teacherFragmentBinding.setLifecycleOwner(getActivity());
    StudentManagerApplication application = (StudentManagerApplication) getActivity().getApplication();
    teacherFragmentBinding.teacherFragmentTeacherName.setText(application.getName());
    teacherFragmentBinding.teacherFramentTeacherId.setText(application.getId());
    course_list_recycleview = teacherFragmentBinding.courseListRecycleview;
    setCoureListRecycleView();
    View root = teacherFragmentBinding.getRoot();
    try {
        initCourseList();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return root;
// return inflater.inflate(R.layout.teacher_fragment, container, false);
}
Also used : IOException(java.io.IOException) StudentManagerApplication(com.shu.studentmanager.StudentManagerApplication) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TeacherViewModel(com.shu.studentmanager.viewmodel.TeacherViewModel) 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 TeacherViewModel (com.shu.studentmanager.viewmodel.TeacherViewModel)1 IOException (java.io.IOException)1