diff --git a/app/src/main/java/br/org/cesar/discordtime/stickysessions/app/StickySessionApplication.java b/app/src/main/java/br/org/cesar/discordtime/stickysessions/app/StickySessionApplication.java deleted file mode 100644 index f275b70e..00000000 --- a/app/src/main/java/br/org/cesar/discordtime/stickysessions/app/StickySessionApplication.java +++ /dev/null @@ -1,84 +0,0 @@ -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; - -public class StickySessionApplication extends Application { - - protected DaggerLoginComponent.Builder mLoginComponentBuilder; - protected DaggerLobbyComponent.Builder mLobbyComponentBuilder; - protected DaggerSessionComponent.Builder mSessionComponentBuilder; - protected DaggerListSessionComponent.Builder mSessionListBuilder; - protected DaggerMeetingComponent.Builder mMeetingComponentBuilder; - - @Override - public void onCreate() { - super.onCreate(); - configureLoginInjectorBuilder(); - configureMainInjectorBuilder(); - configureSessionInjectorBuilder(); - configureSessionListInjectorBuilder(); - configureMeetingInjectorBuilder(); - - Fabric.with(this, new Crashlytics()); - } - - protected void configureLoginInjectorBuilder() { - mLoginComponentBuilder = DaggerLoginComponent.builder(); - } - - protected void configureMainInjectorBuilder() { - mLobbyComponentBuilder = DaggerLobbyComponent.builder() - .contextModule(new ContextModule(getApplicationContext())); - } - - protected void configureSessionInjectorBuilder() { - mSessionComponentBuilder = DaggerSessionComponent.builder() - .contextModule(new ContextModule(getApplicationContext())); - } - - protected void configureSessionListInjectorBuilder() { - mSessionListBuilder = DaggerListSessionComponent.builder() - .contextModule(new ContextModule(getApplicationContext())); - } - - protected void configureMeetingInjectorBuilder() { - mMeetingComponentBuilder = DaggerMeetingComponent.builder() - .contextModule(new ContextModule(getApplicationContext())); - } - - public void inject(LoginActivity activity) { - mLoginComponentBuilder.build().inject(activity); - } - - public void inject(LobbyActivity activity) { - mLobbyComponentBuilder.build().inject(activity); - } - - public void inject(SessionActivity activity) { - mSessionComponentBuilder.build().inject(activity); - } - - public void inject(ListSessionsActivity activity) { - mSessionListBuilder.build().inject(activity); - } - - public void inject(MeetingActivity activity) { - mMeetingComponentBuilder.build().inject(activity); - } - -} diff --git a/app/src/main/java/br/org/cesar/discordtime/stickysessions/app/StickySessionApplication.kt b/app/src/main/java/br/org/cesar/discordtime/stickysessions/app/StickySessionApplication.kt new file mode 100644 index 00000000..0606cc78 --- /dev/null +++ b/app/src/main/java/br/org/cesar/discordtime/stickysessions/app/StickySessionApplication.kt @@ -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() + + 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) + } + +} diff --git a/app/src/main/java/br/org/cesar/discordtime/stickysessions/data/remote/interceptor/HttpNetworkInterceptor.java b/app/src/main/java/br/org/cesar/discordtime/stickysessions/data/remote/interceptor/HttpNetworkInterceptor.java deleted file mode 100644 index f05bd89c..00000000 --- a/app/src/main/java/br/org/cesar/discordtime/stickysessions/data/remote/interceptor/HttpNetworkInterceptor.java +++ /dev/null @@ -1,38 +0,0 @@ -package br.org.cesar.discordtime.stickysessions.data.remote.interceptor; - -import java.io.IOException; - -import br.org.cesar.discordtime.stickysessions.data.remote.wrapper.INetworkWrapper; -import okhttp3.Interceptor; -import okhttp3.Request; -import okhttp3.Response; - -public class HttpNetworkInterceptor implements Interceptor { - - private boolean local; - private INetworkWrapper mNetworkWrapper; - - public HttpNetworkInterceptor(INetworkWrapper NetworkWrapper) { - mNetworkWrapper = NetworkWrapper; - local = false; - } - - public void setLocal(boolean local){ - this.local = local; - } - - @Override - public Response intercept(Chain chain) throws IOException { - Request request = chain.request(); - if(!local && !mNetworkWrapper.isConnected()){ - new NoNetworkException(); - } - return chain.proceed(request); - } - - private class NoNetworkException { - public NoNetworkException(){ - throw new RuntimeException("Please check Network Connection"); - } - } -} diff --git a/app/src/main/java/br/org/cesar/discordtime/stickysessions/data/remote/interceptor/HttpNetworkInterceptor.kt b/app/src/main/java/br/org/cesar/discordtime/stickysessions/data/remote/interceptor/HttpNetworkInterceptor.kt new file mode 100644 index 00000000..4dd3e58f --- /dev/null +++ b/app/src/main/java/br/org/cesar/discordtime/stickysessions/data/remote/interceptor/HttpNetworkInterceptor.kt @@ -0,0 +1,36 @@ +package br.org.cesar.discordtime.stickysessions.data.remote.interceptor + +import java.io.IOException + +import br.org.cesar.discordtime.stickysessions.data.remote.wrapper.INetworkWrapper +import okhttp3.Interceptor +import okhttp3.Request +import okhttp3.Response + +class HttpNetworkInterceptor(private val mNetworkWrapper: INetworkWrapper) : Interceptor { + + private var local: Boolean = false + + init { + local = false + } + + fun setLocal(local: Boolean) { + this.local = local + } + + @Throws(IOException::class) + override fun intercept(chain: Interceptor.Chain): Response { + val request = chain.request() + if (!local && !mNetworkWrapper.isConnected) { + NoNetworkException() + } + return chain.proceed(request) + } + + private inner class NoNetworkException { + init { + throw RuntimeException("Please check Network Connection") + } + } +} diff --git a/app/src/main/java/br/org/cesar/discordtime/stickysessions/data/repository/mapper/Mapper.java b/app/src/main/java/br/org/cesar/discordtime/stickysessions/data/repository/mapper/Mapper.java deleted file mode 100644 index 106bcce6..00000000 --- a/app/src/main/java/br/org/cesar/discordtime/stickysessions/data/repository/mapper/Mapper.java +++ /dev/null @@ -1,7 +0,0 @@ -package br.org.cesar.discordtime.stickysessions.data.repository.mapper; - -public interface Mapper { - - public B mapFromDomain(A domainType); - public A mapToDomain(B dataType); -} diff --git a/app/src/main/java/br/org/cesar/discordtime/stickysessions/data/repository/mapper/Mapper.kt b/app/src/main/java/br/org/cesar/discordtime/stickysessions/data/repository/mapper/Mapper.kt new file mode 100644 index 00000000..b00c4411 --- /dev/null +++ b/app/src/main/java/br/org/cesar/discordtime/stickysessions/data/repository/mapper/Mapper.kt @@ -0,0 +1,7 @@ +package br.org.cesar.discordtime.stickysessions.data.repository.mapper + +interface Mapper { + + fun mapFromDomain(domainType: A): B + fun mapToDomain(dataType: B): A +}