From the course: Android App Development: Design Patterns for Mobile Architecture

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Dependency injection, part 3

Dependency injection, part 3 - Android Tutorial

From the course: Android App Development: Design Patterns for Mobile Architecture

Start my 1-month free trial

Dependency injection, part 3

- [Instructor] We've started using dependency injection in our SpyDetailsActivity. And now let's go to its presenter, and start injecting in there. In here, we're going to move some of these properties down that we will initialize on start up. Actually, we'll leave that up here and we will move this modelLayer down, all of these down, and we'll push this up. We'll make this modelLayer private. And we're going to initialize a few of these variables in the constructor. We'll do the spy ID, the context, and the modelLayer. And then when those are initialized, we'll just say configureData, which is a method that we're going to create right now. The void, let's get rid of this other constructor while we're at it. And we're going to be doing the same stuff in that configureWithSpy, and here we're going to say the spy is equal to the modelLayer.spyForId, and we'll hand it the spyId. And then we're also going to remove this last method and just set the imageId while we're in here. Continuing…

Contents