Skip to content

Instantly share code, notes, and snippets.

Ege Kuzubasioglu egek92

Block or report user

Report or block egek92

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:8f3a3f0ffdf9ff1b2ea6a8ed93b87768
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
View MainActivity.kt
override fun onStop() {
super.onStop()
unregisterReceiver(broadcastReceiver)
killService(locationListener)
}
View ComponentKoin.kt
val appComponent: List<Module> = listOf(dataBaseModule, networkModule, activityModule)
View ComponentDagger.kt
@Singleton
@Component(
modules = [
DataBaseModule::class,
NetworkModule::class,
ActivityModule::class]
)
interface AppComponent {
@Component.Builder
interface Builder {
View ModuleKoin.kt
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() }
View ModuleDagger.kt
@Module
class DataBaseModule {
@Provides
@Singleton
fun provideRoom(app: Application): AppDatabase = Room
.databaseBuilder(app, AppDatabase::class.java, BuildConfig.APPLICATION_ID)
.build()
@Provides
@Singleton
View 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
View gist:ce5f1b2bae85f0f18b202773c65003d3
@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
View ScopeKoin.kt
// 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
View koin.groovy
implementation "org.koin:koin-android:${koinVersion}"
implementation "org.koin:koin-androidx-scope:${koinVersion}" // optional
implementation "org.koin:koin-androidx-viewmodel:${koinVersion}" // optional
You can’t perform that action at this time.