Example using Kotlin, Model-View-ViewModel, AndroidX, Constraint Layout, Coroutines, Fused Location, LiveData, Navigation, View Binding, Bottom Navigation, Koin, Room, WorkManager, Retrofit and Unit Tests with Mockk
What is:
- Kotlin New supported language, very readable, very concise, interoperable, null safety, more info here
- MVVM Model-View-ViewModel, solid architectural pattern, using android's View Models clearly separates view, business logic and data sources
- AndroidX Compatibility and recommended code solutions, more info here
- Constraint Layout allows a layout to adjust to different screen sizes and avoids view annidation, more info here
- Coroutines safe threading, managed by view models, more info here
- Fused Location receive location updates from available sources, more info here
- LiveData observable data source, respond to changes and events, lifecycle aware, more info here
- Navigation provides easy to use "endpoints" as fragments and safe arguments to start them, more info here
- View Binding easy and safe interaction with views, more info here
- Bottom Navigation Bottom Navigation bar using Material Components, more info here
- Koin Dependency injection, define once, use anywhere, more info here
- Room Data persistance over SQLite, more info here
- WorkManager safe async deferable tasks, more info here
- Retrofit type safe HTTP calls, more info here
- Unit Tests ensure correct code logic and error handling, more info here
- Mockk allows the creation of "mock" instances of objects to ease unit testing, more info here
- Shared Preferences allows storage of simple data, more info here
- Recycler View a more efficient List View, more info here
- Sharesheet share simple data with other apps, more info here
- Firebase Instance Id When using Firebase, server can send a notification to a specific user with this id, more info here
- Clean Architecture ensure modularization, scalability and testability, more info here
Learn the basics with this simple App:
- Create and store User with Room
- Pattern with Regex to match alphabetic user names
- Create Notification after creating User
- View users in a Recycler View with a Click Listener to delete the user from Room
- Download an image file from a valid url with Retrofit, monitor the download % and then save the file in a predefined folder to share with Intent Action Send
- Pick one image and copy file to app designated folder and share it
- Use Fused Location Client to get the user location and update server using a retrying worker
- Share location with Intent Action Send
- Get the Firebase Instance Id device token and send it to your server using a retrying worker
- Coroutine Worker as well as Coroutines implemented in the Local and Remote Data Sources
- Demos on 2d graphics
- Plotting a line chart and a pie chart
- View Binding and Navigation from Android Jetpack
- Unit Tests for the View Models and the Workers using KoinTest and Mockk
- Some neat utils
- Clean Architecture
Git Cheatsheet
Pull from master
- git fetch
- git pull origin master
Create new branch
- git checkout -b branch_name
- git push -u origin branch_name
Commit and push
- git add .
- git commit -m "message"
- git push origin branch_name
Uncommit
- git reset --soft "HEAD^"
Amend last commit and push
- git add .
- git commit --amend
- git push -f
Rebase from master and push to branch, if there are no conflicts, skip steps 2 and 3
- git rebase master
- {solve conflicts} git add .
- git rebase --continue
- git push -f
Squash commits into 1 commit, N is number of commits
- git rebase -i HEAD~N
- {squash commits}
- git push -f