Professional Documents
Culture Documents
AAD 2 Interview
AAD 2 Interview
goals :
Create Course Scheduler App, Allow students to easily access important course information,
such as instructor information and note.
featurs :
Database Setup: Define a local database table and DAO (data access object) based on the
schema in course.json and use QueryUtils to create a raw query.
RecyclerView and CourseAdapter: Initialize RecyclerView with CourseAdapter and delete the
course when the list is swiped.
Dark Mode Theme: Update the dark mode theme based on the value in ListPreference.
Daily Reminder: Schedule and cancel daily reminders for every 6:00 AM using AlarmManager.
Show today's schedules in an inbox style notification and open HomeActivity when the
notification is tapped.
Solution : is to use a testing framework like Espresso to automate UI interactions and verify app
behavior.
Workflow
The ListPreference's OnPreferenceChangeListener is triggered, passing the new dark mode value
to the updateTheme() method.
To apply the new theme, the current activity is recreated using requireActivity().recreate().
Under the hood:
recreate(): The recreate() method destroys and recreates the current activity, applying the new
theme in the process..
Workflow :
If the reminder is enabled, the setDailyReminder() method is called to schedule the daily
reminder using AlarmManager.
If the reminder is disabled, the cancelAlarm() method is called to cancel the daily reminder.
Components:
Repository: The Repository is a class that provides access to the data. In this case, the Repository
is used to get the today's schedule.
PendingIntent: A PendingIntent is an object that represents a future intent that can be executed
by the system.
Technical Explanation:
Scheduling the daily reminder: The setDailyReminder() method creates a PendingIntent that
points to the DailyReminder class. It then sets a repeating alarm using AlarmManager. The
repeating alarm will fire every day at 6:00 AM.
Receiving the alarm broadcast: When the alarm broadcast is received, the DailyReminder class
onReceive() method is called. This method gets the today's schedule from the Repository and
shows a notification with the schedule.
To get a course: The getCourse() method returns a LiveData object that emits the specified
course whenever it changes. This is used to display the details of a course in the DetailActivity.
Observing Course LiveData: The DetailActivity observes the course LiveData from the viewModel
using viewModel.course.observe(this) { showCourseDetail(it) }. This ensures that the UI is
updated whenever the course data changes.
Updating UI with Course Data: The showCourseDetail() method receives the Course object and
updates the UI elements accordingly. It sets the course name, time, lecturer, and note using the
corresponding TextView elements.
Deleting Course: When the user selects the "Delete" option from the menu, the
onOptionsItemSelected() method calls viewModel.delete(). The DetailViewModel handles the
deletion logic and updates the repository accordingly.
Simple to use: LiveData has a simple API that is easy to learn and use.