JigokunoOusama
Lurker
Hello Everyone,
I am attempting to write a course scheduling app as an assignment. I am writing in Java and using a Room database. It's intended as a build-your-own schedule tool.
Basically, I have Terms, Courses, and Assessments. A term has its own courses, a course has its own assessments. All objects are created ad hoc based on the user's needs, so there are no established lists of objects aside from sample data I have provided in the database.
I am using a recycler view to display the courses in a Term details activity, but I haven't been able to figure out how to specifically display courses by Term instead of the full list of Courses. As of now, both sample Terms are displaying the full list of courses in their respective recycler views.
What would be a good way to go about filtering my course list by Term id?
This is how I am populating my Term's course list recycler view, and I know this is incorrect for what I am trying to do, but I am getting confused by the DOA, Repository, CourseViewModel, Database cycle. I have attempted to solve the problem from multiple levels and keep getting into Catch-22 type situations.
Sincerely,
Andrew
I am attempting to write a course scheduling app as an assignment. I am writing in Java and using a Room database. It's intended as a build-your-own schedule tool.
Basically, I have Terms, Courses, and Assessments. A term has its own courses, a course has its own assessments. All objects are created ad hoc based on the user's needs, so there are no established lists of objects aside from sample data I have provided in the database.
I am using a recycler view to display the courses in a Term details activity, but I haven't been able to figure out how to specifically display courses by Term instead of the full list of Courses. As of now, both sample Terms are displaying the full list of courses in their respective recycler views.
What would be a good way to go about filtering my course list by Term id?
This is how I am populating my Term's course list recycler view, and I know this is incorrect for what I am trying to do, but I am getting confused by the DOA, Repository, CourseViewModel, Database cycle. I have attempted to solve the problem from multiple levels and keep getting into Catch-22 type situations.
Java:
courseRecyclerView = findViewById(R.id.course_recycler);
adapter = new CourseListAdapter(TermDetailsActivity.this);
courseRecyclerView.setLayoutManager(new LinearLayoutManager(TermDetailsActivity.this));
courseRecyclerView.setAdapter(adapter);
adapter.setCourses(allCourseList);
mCourseViewModel = ViewModelProviders.of(TermDetailsActivity.this).get(CourseViewModel.class); mCourseViewModel.getAllCourses().observe(TermDetailsActivity.this, new Observer<List<Course>>() {
@Override
public void onChanged(@Nullable final List<Course> courses) {
adapter.setCourses(courses);
});
Sincerely,
Andrew