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
1 parent
d340530
commit d72bffa
Showing
6 changed files
with
52 additions
and
138 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
20 changes: 8 additions & 12 deletions
20
app/src/main/java/com/better/alarm/configuration/Inject.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,33 +1,29 @@ | ||
package com.better.alarm.configuration | ||
|
||
import com.better.alarm.logger.LoggerFactory | ||
import org.koin.core.context.KoinContextHandler | ||
import org.koin.core.context.GlobalContext | ||
import org.koin.core.parameter.ParametersDefinition | ||
import org.koin.core.qualifier.Qualifier | ||
|
||
/** | ||
* globalInject lazily given dependency for Android koincomponent | ||
* globalInject lazily given dependency | ||
* @param qualifier - bean qualifier / optional | ||
* @param scope | ||
* @param parameters - injection parameters | ||
*/ | ||
inline fun <reified T : Any> globalInject( | ||
qualifier: Qualifier? = null, | ||
noinline parameters: ParametersDefinition? = null | ||
) = lazy { KoinContextHandler.get().get<T>(qualifier, parameters) } | ||
) = lazy { GlobalContext.get().get<T>(qualifier, parameters) } | ||
|
||
inline fun <reified T : Any> globalGet( | ||
qualifier: Qualifier? = null, | ||
noinline parameters: ParametersDefinition? = null | ||
) = KoinContextHandler.get().get<T>(qualifier, parameters) | ||
) = GlobalContext.get().get<T>(qualifier, parameters) | ||
|
||
fun globalLogger(tag: String) = lazy { KoinContextHandler.get().get<LoggerFactory>().createLogger(tag) } | ||
fun globalLogger(tag: String) = lazy { GlobalContext.get().get<LoggerFactory>().createLogger(tag) } | ||
|
||
/** | ||
* globalInject lazily given dependency for Android koincomponent | ||
* @param qualifier - bean qualifier / optional | ||
* @param scope | ||
* @param parameters - injection parameters | ||
* globalInject lazily given dependency | ||
* @param clazz | ||
*/ | ||
@Deprecated("Java", ReplaceWith("globalInject()")) | ||
fun <T : Any> globalInject(clazz: Class<T>) = lazy { KoinContextHandler.get().get<T>(clazz = clazz.kotlin) } | ||
fun <T : Any> globalInject(clazz: Class<T>) = lazy { GlobalContext.get().get(clazz = clazz.kotlin) } |
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