forked from gpeal/Anvil-Sample
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gabriel Peal
committed
May 22, 2022
1 parent
77ac8c0
commit 229855f
Showing
8 changed files
with
52 additions
and
13 deletions.
There are no files selected for viewing
7 changes: 5 additions & 2 deletions
7
...lsample/feature/weatherui/MainActivity.kt → ...l/droidconanvilsample/app/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...eatherui/src/main/java/com/gpeal/droidconanvilsample/feature/weatherui/WeatherBindings.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.gpeal.droidconanvilsample.feature.weatherui | ||
|
||
import com.gpeal.droidconanvilsample.lib.daggerscopes.WeatherScope | ||
import com.squareup.anvil.annotations.ContributesTo | ||
|
||
@ContributesTo(WeatherScope::class) | ||
interface WeatherBindings { | ||
fun inject(fragment: WeatherFragmentSimple) | ||
fun inject(vm: WeatherViewModel) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...main/java/com/gpeal/droidconanvilsample/feature/weatherui/WeatherFragmentWithViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.gpeal.droidconanvilsample.feature.weatherui | ||
|
||
import android.app.Application | ||
import android.content.Context | ||
import androidx.fragment.app.Fragment | ||
import androidx.fragment.app.viewModels | ||
import androidx.lifecycle.AndroidViewModel | ||
import androidx.lifecycle.ViewModel | ||
import com.gpeal.droidconanvilsample.lib.daggerscopes.utils.DaggerComponentOwner | ||
import com.gpeal.droidconanvilsample.lib.daggerscopes.utils.bindings | ||
import com.gpeal.droidconanvilsample.lib.weatherdata.WeatherRepository | ||
import javax.inject.Inject | ||
|
||
class WeatherViewModel(application: Application) : AndroidViewModel(application), DaggerComponentOwner { | ||
|
||
override val daggerComponent = application.bindings<WeatherComponent.ParentBindings>().weatherComponentBuilder().create() | ||
|
||
@Inject | ||
lateinit var weatherRepository: WeatherRepository | ||
|
||
init { | ||
bindings<WeatherBindings>().inject(this) | ||
} | ||
} | ||
|
||
class WeatherFragmentWithViewModel : Fragment(R.layout.weather_fragment) { | ||
private val viewModel: WeatherViewModel by viewModels() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters