Skip to content

Instantly share code, notes, and snippets.

View egek92's full-sized avatar
🔵

Ege Kuzubasioglu egek92

🔵
View GitHub Profile
implementation "org.koin:koin-android:${koinVersion}"
implementation "org.koin:koin-androidx-scope:${koinVersion}" // optional
implementation "org.koin:koin-androidx-viewmodel:${koinVersion}" // optional
// define scope in your module
module {
scope("scope_id") { Presenter() }
}
// use scope in your activity
class SomeActivity: AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// ... other required stuff
@egek92
egek92 / gist:ce5f1b2bae85f0f18b202773c65003d3
Created July 10, 2019 10:04
ViewModelInjectionDagger.kt
@Singleton
class ViewModelFactory @Inject constructor(private val viewModels: MutableMap<Class<out ViewModel>, Provider<ViewModel>>) : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T = viewModels[modelClass]?.get() as T
}
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER)
@kotlin.annotation.Retention(AnnotationRetention.RUNTIME)
@MapKey
@Singleton
class ViewModelFactory @Inject constructor(private val viewModels: MutableMap<Class<out ViewModel>, Provider<ViewModel>>) : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T = viewModels[modelClass]?.get() as T
}
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER)
@kotlin.annotation.Retention(AnnotationRetention.RUNTIME)
@MapKey
@Module
class DataBaseModule {
@Provides
@Singleton
fun provideRoom(app: Application): AppDatabase = Room
.databaseBuilder(app, AppDatabase::class.java, BuildConfig.APPLICATION_ID)
.build()
@Provides
@Singleton
val dataBaseModule = module {
single {
Room.databaseBuilder(androidContext(), AppDatabase::class.java, BuildConfig.APPLICATION_ID)
.fallbackToDestructiveMigration()
.build()
}
single { (get() as AppDatabase).hotelsDao() }
single { (get() as AppDatabase).visitors() }
@Singleton
@Component(
modules = [
DataBaseModule::class,
NetworkModule::class,
ActivityModule::class]
)
interface AppComponent {
@Component.Builder
interface Builder {
val appComponent: List<Module> = listOf(dataBaseModule, networkModule, activityModule)
override fun onStop() {
super.onStop()
unregisterReceiver(broadcastReceiver)
killService(locationListener)
}
One can specifies a different port than the usual 8080 to make it unique and avoid any errors, in case another service is using Jenkins
java -jar jenkins.war --httpPort=9091
Next Step: Configure Jenkins
Manage Jenkins > Configure System
Mentioned the ANDROID_HOME as my Android SDK path variable in Global properties.
2. Manage Jenkins > Global Tool Configuration