Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Android Dependency Injection With Dagger 2 - II
Rating: 4.3 out of 5(4 ratings)
30 students

Android Dependency Injection With Dagger 2 - II

Master Dagger 2 Android Dependency Injection With MVVM architecture complete app
Created byRichard Dewan
Last updated 12/2021
English

What you'll learn

  • Dependency Injection
  • Dagger 2
  • MVVM
  • Kotlin Coroutines
  • Retrofit
  • Room

Course content

1 section34 lectures3h 22m total length
  • Download Project File0:01
  • Base Project walk through6:37

    Explore the base dagger 2 project setup with two fragments, navigation, a network helper, and module-level dependencies to connect to an API and prepare a room database for later lessons.

  • Base URL0:02
  • Configure base URL and endpoints6:11

    Define a data package with local and remote data caches, create an endpoints class for api calls such as get tax and get all tax, and configure the base URL.

  • Retrofit3:35

    Create and configure a retrofit instance to build a networking service interface, including a converter factory, and return the network service for API calls.

  • Request and Response data class file4:28

    Define request and response data classes for API calls, and generate them from postman payloads. Prepare to send data to the endpoint and receive responses in the network service.

  • NetworkService9:03

    Configure the network service and implement suspend functions to fetch all taxes and to fetch a tax by id using defined endpoints, headers, and Retrofit tooling.

  • Network resource file5:28

    Define a Kotlin network resource file and a network status enum to model success, error, and unknown states with generic data. Add companion object factories to create states with codes.

  • Main Repository3:32

    Create the main repository in the data package to wrap the network service, exposing API calls such as get tax and get tax by id, for future local GP work.

  • Task Entity4:09

    Learn to create an Android entity with a table name and columns like id, title, body, status, user id, and notes using an auto incremented primary key.

  • Database service and DAO5:11

    Continue building the dao and database service by defining a tax entity with suspend insert and query methods, and configure on-conflict handling with dagger integration.

  • Add task repository4:41

    Create a shared repository using a network and database service, implement get and insert operations for the tax entity, including insert many, and send updates to the remote API.

  • Configure MainViewModel - Part I7:54

    Configure the main view model by wiring the home view model to a main repository, manage loading state, and implement success and failure data flows to call the API.

  • Configure MainViewModel - Part II9:56

    Refine the main view model to fetch taxes from API, map tax responses to tax entities, and persist them via the repository with loading states and success and failure handling.

  • Configure AddViewModel10:38

    Configure the add tax flow by wiring the tax repository to the API, creating a tax request with id, title, body, and status, and handling loading and local insertion.

  • ViewModelProviderFactory5:58

    Create a generic view model provider factory to supply constructor parameters for Android view models owned by the framework, with class checks and proper creation logic.

  • Application module and component12:09

    Create and configure an application module and an application component, define singleton provider functions for the application, network service, and database service, and implement injection across the app.

  • Application class inject dependencies6:21

    Configure a dagger application component and application module to provide singleton network and database services, inject dependencies into the to-do app, and set up the repository as a shared dependency.

  • Repository class constructor injection4:01

    Implement constructor injection for repository and main repository with Dagger 2, annotate constructors with @Inject, and share a singleton instance across the application using modules and components.

  • Activity module and component3:40

    Explore building an activity module and component with Dagger 2, wiring the activity, singleton dependencies, and the application component for clean dependency injection.

  • Activity and Fragment Scope3:09

    Define and apply activity and fragment scopes in Dagger 2, create scope annotations with retention policy source, wire activity components, and prepare for fragment integration.

  • Fragment Componet and Module9:44

    Create a fragment module and component with provider methods for context, layout manager, and the home view model, and wire the main repository via the application component.

  • Inject dependencies in home fragment9:18

    Inject dependencies in the home fragment using dagger 2 by wiring the application component, fragment component, and fragment module, and verify on fragment creation by launching the fragment.

  • Inject dependencies in add fragment8:40

    Learn to inject dependencies into a fragment with Dagger 2, wiring the application and fragment components, a view model factory, and repository to power the add fragment.

  • Bug Fix5:04

    Fix a bug by fetching the max id from the database and handling nulls in the data store, validating the get all docs flow to the home view model.

  • Task list layout5:39

    Build a task list layout in Android by creating a list item with title, body, and status, using a constraint layout, and preparing a recycler adapter in the fragment.

  • Task Adaptor5:04

    Create a recycler view adapter for tax entities, including a view holder, layout inflation, and data binding, then update and notify data changes within the home fragment.

  • Implement task adaptor5:37

    Implement the task adapter and set up a RecyclerView with a linear layout manager in a fragment using Dagger 2 for dependency injection; display API data from the local DB.

  • Get task list from local db6:39

    Implement a local db query to fetch the tax list, wire it via the repository and home view model, and observe results in the home fragment with a loading indicator.

  • Display data to recycler view4:23

    Learn how to display data in a recycler view by wiring dependency injection in a fragment, including injecting the layout manager and the view model, and managing a progress indicator.

  • Add task to api9:39

    Enable task creation in the attacks fragment by populating fields, wiring the add task action to the api via dependency injection, and showing snackbar feedback on success or error.

  • Bug fix7:07

    Debug and fix a bug in Android app by identifying a missing user id in the request, addressing 500 error, and validating successful data insertion, while leveraging Dagger and Kotlin.

  • Snackbar6:51

    Implement and customize a snackbar in Android with Dagger 2 - II, setting background and text colors, actions, and string resources, then run the app to verify the changes.

  • Thank You1:44

    I congratulate you on completing all lectures in this final lecture and invite you to explore my other Android courses on Udemy, with coupon codes and financial aid options.

Requirements

  • Basic of Android Development
  • Android Dependency Injection With Dagger - I OR Basic knowledge of Dagger 2

Description

In this course we will learn android dependency injection using Kotlin and MVVM. We will build a complete app using Kotlin, Coroutines, Room, Retrofit, Dagger and MVVM. This course is fully practical no talking just doing. If you have already completed Android Dependency Injection With Dagger - I, this course is for you. 

This course is for anyone who is interested in learning Android Dependency Injection With Dagger. By the end of the course you will have a good understanding about dependency injection and Dagger 2.

Who this course is for:

  • Any one intrested to learn adroid dependency injection with dagger
  • Android developer