Code quality
Code quality
This commit is contained in:
parent
4c88d8e3c2
commit
0644a5822f
30 changed files with 44 additions and 51 deletions
|
|
@ -27,7 +27,7 @@ inline fun <reified T : Any> Context.bindings() = bindings(T::class.java)
|
|||
*/
|
||||
inline fun <reified T : Any> Fragment.bindings() = bindings(T::class.java)
|
||||
|
||||
/** Use no-arg extension function instead: [Context.bindings] */
|
||||
/** Use no-arg extension function instead: [Context.bindings]. */
|
||||
fun <T : Any> Context.bindings(klass: Class<T>): T {
|
||||
// search dagger components in the context hierarchy
|
||||
return generateSequence(this) { (it as? ContextWrapper)?.baseContext }
|
||||
|
|
@ -40,7 +40,7 @@ fun <T : Any> Context.bindings(klass: Class<T>): T {
|
|||
?: error("Unable to find bindings for ${klass.name}")
|
||||
}
|
||||
|
||||
/** Use no-arg extension function instead: [Fragment.bindings] */
|
||||
/** Use no-arg extension function instead: [Fragment.bindings]. */
|
||||
fun <T : Any> Fragment.bindings(klass: Class<T>): T {
|
||||
// search dagger components in fragment hierarchy, then fallback to activity and application
|
||||
return generateSequence(this, Fragment::getParentFragment)
|
||||
|
|
@ -50,4 +50,4 @@ fun <T : Any> Fragment.bindings(klass: Class<T>): T {
|
|||
.filterIsInstance(klass)
|
||||
.firstOrNull()
|
||||
?: requireActivity().bindings(klass)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,4 +7,4 @@ package io.element.android.x.core.di
|
|||
interface DaggerComponentOwner {
|
||||
/** This is either a component, or a list of components. */
|
||||
val daggerComponent: Any
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ inline fun <reified VM : MavericksViewModel<S>, S : MavericksState> daggerMaveri
|
|||
* using its AssistedInject Factory. This class should be implemented by the companion object
|
||||
* of every ViewModel which uses AssistedInject via [daggerMavericksViewModelFactory].
|
||||
*
|
||||
* @param VM The ViewModel type
|
||||
* @param S The ViewState type
|
||||
* @param viewModelClass The [Class] of the ViewModel being requested for creation
|
||||
*
|
||||
* This class accesses the map of ViewModel class to [AssistedViewModelFactory]s from the nearest [DaggerComponentOwner] and
|
||||
|
|
@ -57,4 +59,4 @@ class DaggerMavericksViewModelFactory<VM : MavericksViewModel<S>, S : MavericksS
|
|||
|
||||
interface DaggerMavericksBindings {
|
||||
fun viewModelFactories(): Map<Class<out MavericksViewModel<*>>, AssistedViewModelFactory<*, *>>
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,4 +4,4 @@ plugins {
|
|||
|
||||
dependencies {
|
||||
api(libs.inject)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@ package io.element.android.x.di
|
|||
|
||||
import javax.inject.Qualifier
|
||||
|
||||
@Qualifier annotation class ApplicationContext
|
||||
@Qualifier annotation class ApplicationContext
|
||||
|
|
|
|||
|
|
@ -5,4 +5,4 @@ import kotlin.reflect.KClass
|
|||
|
||||
@Scope
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class SingleIn(val clazz: KClass<*>)
|
||||
annotation class SingleIn(val clazz: KClass<*>)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ import io.element.android.x.matrix.media.MediaFetcher
|
|||
import io.element.android.x.matrix.media.MediaKeyer
|
||||
import io.element.android.x.matrix.session.SessionStore
|
||||
import io.element.android.x.matrix.util.logError
|
||||
import java.io.File
|
||||
import java.util.concurrent.Executors
|
||||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.asCoroutineDispatcher
|
||||
|
|
@ -19,10 +22,6 @@ import org.matrix.rustcomponents.sdk.AuthenticationService
|
|||
import org.matrix.rustcomponents.sdk.Client
|
||||
import org.matrix.rustcomponents.sdk.ClientBuilder
|
||||
import timber.log.Timber
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import java.util.concurrent.Executors
|
||||
import javax.inject.Inject
|
||||
|
||||
@SingleIn(AppScope::class)
|
||||
class Matrix @Inject constructor(
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package io.element.android.x.matrix
|
||||
|
||||
import io.element.android.x.core.coroutine.CoroutineDispatchers
|
||||
import io.element.android.x.di.SingleIn
|
||||
import io.element.android.x.matrix.core.UserId
|
||||
import io.element.android.x.matrix.media.MediaResolver
|
||||
import io.element.android.x.matrix.media.RustMediaResolver
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue