Skip to content
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

Converting Java to Kotlin #196

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package br.org.cesar.discordtime.stickysessions.app

import android.app.Application

import com.crashlytics.android.Crashlytics

import br.org.cesar.discordtime.stickysessions.injectors.components.DaggerListSessionComponent
import br.org.cesar.discordtime.stickysessions.injectors.components.DaggerLobbyComponent
import br.org.cesar.discordtime.stickysessions.injectors.components.DaggerLoginComponent
import br.org.cesar.discordtime.stickysessions.injectors.components.DaggerMeetingComponent
import br.org.cesar.discordtime.stickysessions.injectors.components.DaggerSessionComponent
import br.org.cesar.discordtime.stickysessions.injectors.modules.ContextModule
import br.org.cesar.discordtime.stickysessions.ui.list.ListSessionsActivity
import br.org.cesar.discordtime.stickysessions.ui.lobby.LobbyActivity
import br.org.cesar.discordtime.stickysessions.ui.login.LoginActivity
import br.org.cesar.discordtime.stickysessions.ui.meeting.MeetingActivity
import br.org.cesar.discordtime.stickysessions.ui.session.SessionActivity
import io.fabric.sdk.android.Fabric

open class StickySessionApplication : Application() {

protected var mLoginComponentBuilder: DaggerLoginComponent.Builder
protected var mLobbyComponentBuilder: DaggerLobbyComponent.Builder
protected var mSessionComponentBuilder: DaggerSessionComponent.Builder
protected var mSessionListBuilder: DaggerListSessionComponent.Builder
protected var mMeetingComponentBuilder: DaggerMeetingComponent.Builder

override fun onCreate() {
super.onCreate()
configureLoginInjectorBuilder()
configureMainInjectorBuilder()
configureSessionInjectorBuilder()
configureSessionListInjectorBuilder()
configureMeetingInjectorBuilder()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think better to use Lazy initialization in each build? each build is just instanced in the first use instead of loading all.

e.g:
protected var mLoginComponentBuilder: DaggerLoginComponent.Builder by lazy {
DaggerLoginComponent.builder()
}


Fabric.with(this, Crashlytics())
}

protected fun configureLoginInjectorBuilder() {
mLoginComponentBuilder = DaggerLoginComponent.builder()
}

protected open fun configureMainInjectorBuilder() {
mLobbyComponentBuilder = DaggerLobbyComponent.builder()
.contextModule(ContextModule(applicationContext))
}

protected open fun configureSessionInjectorBuilder() {
mSessionComponentBuilder = DaggerSessionComponent.builder()
.contextModule(ContextModule(applicationContext))
}

protected open fun configureSessionListInjectorBuilder() {
mSessionListBuilder = DaggerListSessionComponent.builder()
.contextModule(ContextModule(applicationContext))
}

protected fun configureMeetingInjectorBuilder() {
mMeetingComponentBuilder = DaggerMeetingComponent.builder()
.contextModule(ContextModule(applicationContext))
}

fun inject(activity: LoginActivity) {
mLoginComponentBuilder.build().inject(activity)
}

fun inject(activity: LobbyActivity) {
mLobbyComponentBuilder.build().inject(activity)
}

fun inject(activity: SessionActivity) {
mSessionComponentBuilder.build().inject(activity)
}

fun inject(activity: ListSessionsActivity) {
mSessionListBuilder.build().inject(activity)
}

fun inject(activity: MeetingActivity) {
mMeetingComponentBuilder.build().inject(activity)
}

}