-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial integration of ContributesSubcomponent API
- Loading branch information
1 parent
ae93ca9
commit e4fff0c
Showing
12 changed files
with
106 additions
and
120 deletions.
There are no files selected for viewing
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
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
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: 22 additions & 6 deletions
28
whetstone/src/main/java/com/deliveryhero/whetstone/component/FragmentComponent.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 |
---|---|---|
@@ -1,18 +1,34 @@ | ||
package com.deliveryhero.whetstone.component | ||
|
||
import com.deliveryhero.whetstone.SingleIn | ||
import androidx.fragment.app.Fragment | ||
import javax.inject.Provider | ||
import com.deliveryhero.whetstone.scope.ActivityScope | ||
import com.deliveryhero.whetstone.scope.FragmentScope | ||
import com.squareup.anvil.annotations.ContributesSubcomponent | ||
import com.squareup.anvil.annotations.ContributesTo | ||
|
||
/** | ||
* A Dagger component that has the lifetime of the [androidx.fragment.app.Fragment]. | ||
*/ | ||
@ContributesSubcomponent( | ||
scope = FragmentScope::class, | ||
parentScope = ActivityScope::class | ||
) | ||
@SingleIn(FragmentScope::class) | ||
public interface FragmentComponent { | ||
public fun getFragmentMap(): Map<Class<*>, Provider<Fragment>> | ||
} | ||
|
||
/** | ||
* Interface for creating an [FragmentComponent]. | ||
*/ | ||
public interface FragmentComponentFactory { | ||
public fun create(): FragmentComponent | ||
/** | ||
* Interface for creating an [FragmentComponent]. | ||
*/ | ||
@ContributesSubcomponent.Factory | ||
public interface Factory { | ||
public fun create(): FragmentComponent | ||
} | ||
|
||
@ContributesTo(ActivityScope::class) | ||
public interface ParentComponent { | ||
public fun createFragmentFactory(): Factory | ||
} | ||
} |
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
Oops, something went wrong.