-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#299] Add nav args extension class into template-xml, change package…
… name of HomeFragmentTest
- Loading branch information
1 parent
68d74f1
commit da63420
Showing
4 changed files
with
26 additions
and
4 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
10 changes: 10 additions & 0 deletions
10
template-xml/app/src/main/java/co/nimblehq/template/xml/extension/NavArgsExt.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 co.nimblehq.template.xml.extension | ||
|
||
import androidx.annotation.MainThread | ||
import androidx.fragment.app.Fragment | ||
import androidx.navigation.NavArgs | ||
import androidx.navigation.fragment.navArgs | ||
|
||
@MainThread | ||
inline fun <reified Args : NavArgs> Fragment.provideNavArgs(): Lazy<Args> = | ||
OverridableLazy(navArgs()) |
14 changes: 14 additions & 0 deletions
14
template-xml/app/src/test/java/co/nimblehq/template/xml/test/NavArgsExt.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,14 @@ | ||
package co.nimblehq.template.xml.test | ||
|
||
import androidx.navigation.NavArgs | ||
import co.nimblehq.template.xml.extension.OverridableLazy | ||
import kotlin.reflect.KProperty1 | ||
import kotlin.reflect.jvm.isAccessible | ||
|
||
fun <Arg : NavArgs, T> T.replace( | ||
argumentDelegate: KProperty1<T, Arg>, | ||
argument: Arg | ||
) { | ||
argumentDelegate.isAccessible = true | ||
(argumentDelegate.getDelegate(this) as OverridableLazy<Arg>).implementation = lazy { argument } | ||
} |
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