Based off this LinkedInLearning course Building an Android App With Architecture Components
Concepts:
- Publisher-Subscriber Model
- Model-View-Viewmodel (MVVM)
- Repository Pattern
View Tag v1.0.0-Setup
-
Add a Vector Asset based on Android's preexisting Add, Edit, Delete, and Check icons 0. To allow custom assets, - go to build.gradle(app) - set this 'vectorDrawables.useSupportLibrary = true' under 'defaultConfig' i. Right Click the app directory and choose 'Create New Vector Asset* ii. Select 'Clip Art' and search for the 'Add button' iii. I made it #FFFFF or white and renamed it as the ic_add.xml iv. it will be in the drawable directory v. Repeat steps 1 to 4 with the remaining buttons
-
Add LifeCycle and Room dependencies. This will include support for:
- LiveData
- ViewModel
Visit Tag v2.0.0-AddUI
See changes here
-
Add a RecyclerView under DataBinding
- Optional. Use ButterKnife. In "File > Project Structure > Dependencies > App", click the add button to include latest versions of i. jakewharton:butterknife ii. jakewharton:butterknife-compiler (added as annotationProcessor)
-
Create a custom note item view. See note_list_item.xml
-
Create a data transfer object with proper Getters, Setters, and Constructors. See NoteEntity.java as an example
- To test it, we need to create Sample Data. You can log them in console to see if they work. See 'SampleData.java'
-
Create a Notes Adapter that determines UI for each note in the recyclerview
-
Add an Editor Activity, I used a Scrolling Activity to be later used for editing notes
- DataBinding for nested views
- Additional Helpful notes from StackOverflow
Visit Tag v3.0.0-DataLayer
See changes here
-
Add an Entity, DAO, and Database via Room implementation
- Since SQLite doesn't support Date as type, you need to create a type converter. See DateConverter.java
-
Add database tests via Android JUnit 4
Visit Tag v4.0.0-businessLogic for substeps 1 to 3. See changes here
Visit Tag v5.0.0-addEditFeature for substeps 4 and 5. See changes here
Visit Tag v5.1.0-deleteNoteFeature for substep 6. See changes here
-
Add a ViewModel
-
Add a Repository which help will direct where data comes from.
- MainViewModel will use AppRepository
- MainActivity uses MainViewModel
- I heard you can view SQL Lite data with 'DB Browser for SQLite', but I wasn't able to get it working
-
Via this relationship, Activity -> ViewModel -> Repository
- it can add sample data
- delete all notes
-
Using Bundle and each note item's FAB btn to configure saving each Edit note.
-
Use above configuration with Bundle and Fab button to add a note.
-
To delete a note, it's a similar process except you use DAO's deleteNote method
Visit Tag v5.2.0-onSavedInstanceState. See changes here
- Use a boolean flag based on 'onSaveInstanceState' so it won't override current note edits. See 'EditorActivity.java'
- added recyclerview divider lines. Visit Tag v5.2.1-dividerLines. See changes here
- moved some directories. Visit Tag v5.2.2-moveDirectories. See changes here
- Added a Splash Screen. See changes here
Visit Tag v6.0.0-migrateDb. See changes here
- For upgrading / updating your Database, use Migrations
- After migrating, update your Add / Edit Note feature to save all the new params in note
- I updated the constraints so that 'note text' can be empty, because some users don't care about the details
- Android Developers: Migrating DB Versions
- Understanding migrations with Room by Florina Muntenescu
- StackOverflow: Adding multiple columns to SQLite table
- StackOverflow: Dealing with nonNull issues
- StackOverflow: Migration couldn't handle AND Setting Default values
- Switch Tutorial with Android Studio
- StackOverflow: Adding Multiple Views to ScrollView
Visit Tag v7.1.0-fixUnitClickDefect. See changes here
- I used 'Mutable LiveData' to update the UI for incrementing and decrementing those values.
- There are some rules to keep in mind when implementing these features
- The goal is always more than the current number of units
- The goal has to be at least one or higher.
- The number of units has to be at least zero or higher.
Visit Tag v7.2.0-filter. See changes here
- Use the SavedInstanceState to remember previous filter for every device configuration change
- The AppRepository and DAO determines how the filtering is done
- With filter, delete notes based off completion status and add Alert Dialog
- Had to create more icons based off filters and error dialog
- ic_delete_error.xml
- ic_filter_deleteall.xml
- ic_filter_todo.xml
- Alert Dialog Example
- Stack Overflow: How to display Alert Dialog
- Stack Overflow: How to prevent Dialog leaked windows
Visit Tag v7.3.0-notifications. See changes here
- Added preference listeners to trigger notifications
- Added capability to customize notification message
- Editing Setting Preferences
- Android Notification Documentation
- Calling non-static method in static method in Java
- Converting PNGs to Drawables
- Add the WorkManager dependency
- Create a OneTimeWorkRequest to
- trigger the Periodic Requests an
- send a Notification at the exact user-set time
- Use a WorkManager
- To pass parameters for Worker
- WorkManager is too complicated to add custom parameters or set a specific time for notifications
- Create a Timer
- Using a Timer and TimerTask
- How to create a