Skip to content

Commit

Permalink
Fix reflection error
Browse files Browse the repository at this point in the history
  • Loading branch information
HectorNarvaez committed May 30, 2023
1 parent da0c722 commit 382ccbb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ object Libs {
val coroutineTesting by lazy { "org.jetbrains.kotlinx:kotlinx-coroutines-test:${Versions.coroutines}" }

// Auth
val omhAuthLibrary by lazy { "com.openmobilehub.android:auth-api:${Versions.omhAuth}" }
val omhAuthLibrary by lazy { "com.openmobilehub.android:auth-api-non-gms:${Versions.omhAuth}" }
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ object Versions {
const val mockk = "1.13.4"

// Auth
const val omhAuth = "1.0.1"
const val omhAuth = "1.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@ package com.omh.android.storage.api

import com.omh.android.auth.api.OmhAuthClient
import kotlin.reflect.KClass
import kotlin.reflect.full.createInstance

object OmhStorageProvider {

private const val NGMS_ADDRESS = "com.omh.android.storage.api.drive.nongms.OmhStorageFactoryImpl"

@SuppressWarnings("SwallowedException")
@SuppressWarnings("ThrowingExceptionsWithoutMessageOrCause")
fun provideStorageClient(authClient: OmhAuthClient): OmhStorageClient {
val clazz: KClass<out Any> = Class.forName(NGMS_ADDRESS).kotlin
val omhStorageFactory = clazz.objectInstance as OmhStorageFactory
return omhStorageFactory.getStorageClient(authClient)
val clazz: Class<*> = Class.forName(NGMS_ADDRESS)
val kClass: KClass<*> = clazz.kotlin
val instance: Any = kClass.createInstance()

val storageFactory = instance as? OmhStorageFactory ?: throw NullPointerException()

return storageFactory.getStorageClient(authClient)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class ActivitySplash : AppCompatActivity() {
@Inject
lateinit var omhAuthClient: OmhAuthClient

// @Inject lateinit var omhStorageClient: OmhStorageClient
@Inject
lateinit var omhStorageClient: OmhStorageClient

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down

0 comments on commit 382ccbb

Please sign in to comment.