-
Notifications
You must be signed in to change notification settings - Fork 6
Add Koin instead of dagger-hilt as DI #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.package"> | ||
|
||
<application android:extractNativeLibs="true" /> | ||
</manifest> | ||
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.rootstrap.android.tests.utils | ||
|
||
import android.content.SharedPreferences | ||
import com.rootstrap.android.util.Prefs | ||
import io.mockk.every | ||
import io.mockk.mockk | ||
import io.mockk.spyk | ||
import org.junit.Assert | ||
import org.junit.Test | ||
import java.util.UUID | ||
|
||
class PrefsTest { | ||
|
||
@Test | ||
fun savingSecureDataPrefs() { | ||
val uid = UUID.randomUUID().toString() | ||
val preferences = mockk<SharedPreferences>() | ||
val prefs = spyk(Prefs(preferences), recordPrivateCalls = true) | ||
every { preferences.edit().putString("uid", uid).apply() } returns Unit | ||
every { preferences.getString("uid", "")!! } returns uid | ||
every { prefs ["getPref"]() } returns preferences | ||
|
||
prefs.uid = uid | ||
|
||
Assert.assertEquals(prefs.uid, uid) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.rootstrap.android.di | ||
|
||
import android.content.Context | ||
import android.content.SharedPreferences | ||
import com.rootstrap.android.network.managers.session.SessionManager | ||
import com.rootstrap.android.network.managers.session.SessionManagerImpl | ||
import com.rootstrap.android.network.managers.user.UserManager | ||
import com.rootstrap.android.network.managers.user.UserManagerImpl | ||
import com.rootstrap.android.network.managers.user.UserManagerRetrofitBuilder | ||
import com.rootstrap.android.network.services.AuthenticationInterceptor | ||
import com.rootstrap.android.network.services.ResponseInterceptor | ||
import com.rootstrap.android.ui.activity.main.ProfileActivityViewModel | ||
import com.rootstrap.android.ui.activity.main.SignInActivityViewModel | ||
import com.rootstrap.android.ui.activity.main.SignUpActivityViewModel | ||
import com.rootstrap.android.util.Prefs | ||
import org.koin.android.ext.koin.androidApplication | ||
import org.koin.core.module.Module | ||
import org.koin.androidx.viewmodel.dsl.viewModel | ||
import org.koin.dsl.module | ||
|
||
val myModule: Module = module { | ||
|
||
single { AuthenticationInterceptor(get()) } | ||
single { ResponseInterceptor(get(), get()) } | ||
single { UserManagerRetrofitBuilder(get(), get()) } | ||
single<UserManager> { UserManagerImpl(get()) } | ||
single<SharedPreferences> { androidApplication().getSharedPreferences("userPreferences", Context.MODE_PRIVATE) } | ||
factory { Prefs(get()) } | ||
single<SessionManager> { SessionManagerImpl(get()) } | ||
viewModel { SignInActivityViewModel(get(), get()) } | ||
viewModel { ProfileActivityViewModel(get(), get()) } | ||
viewModel { SignUpActivityViewModel(get(), get()) } | ||
// viewModel { BottomBarViewModel(androidApplication()) } | ||
// single { provideIotDao(androidContext()) } | ||
Comment on lines
+33
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what do you think of removing these commented lines if they are no longer needed? |
||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add a new line here