WIP: feature/abstractions (#45)

* Abstraction layer backup

* Removed DataEntity, was unnecessary for now

* Separated network, persistence, entities and interaction, closes #29

* Renamed binding

* Removed build files, example tests

Removed build files, example tests

* Fixed build files were not being ignored all around app

* Updated CI ymls

* Small changes

* Fixed legacy repository package names

* Fixed CQ findings

* Updated Fastlane

* Packaging changes and version upgrades

* Removed core from interactors

* Version bumps

* Added new module graph
This commit is contained in:
Melih Aksoy
2019-10-30 17:27:53 +01:00
committed by GitHub
parent 83e39400a9
commit 88022629e1
103 changed files with 1098 additions and 921 deletions

20
data/network/build.gradle Normal file
View File

@@ -0,0 +1,20 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply from: "$rootProject.projectDir/scripts/module.gradle"
apply from: "$rootProject.projectDir/scripts/default_dependencies.gradle"
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':data:definitions')
implementation libraries.okHttpLogger
implementation libraries.moshiKotlin
implementation libraries.coroutines
implementation libraries.retrofit
testImplementation testLibraries.coroutinesCore
testImplementation testLibraries.coroutinesTest
}

View File

21
data/network/proguard-rules.pro vendored Normal file
View File

@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@@ -0,0 +1,3 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.melih.network" />

View File

@@ -0,0 +1,28 @@
package com.melih.network
import com.melih.definitions.entities.LaunchEntity
import com.melih.definitions.entities.LaunchesEntity
import retrofit2.Response
import retrofit2.http.GET
import retrofit2.http.Path
import retrofit2.http.Query
/**
* Retrofit interface for networking
*/
internal interface Api {
//region Get
@GET("launch/next/{count}")
suspend fun getNextLaunches(
@Path("count") count: Int,
@Query("offset") offset: Int
): Response<LaunchesEntity>
@GET("launch/{id}")
suspend fun getLaunchById(
@Path("id") id: Long
): Response<LaunchEntity>
//endregion
}

View File

@@ -0,0 +1,57 @@
package com.melih.network
import com.melih.definitions.entities.LaunchEntity
import com.melih.definitions.entities.LaunchesEntity
import com.squareup.moshi.Moshi
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Response
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory
import java.util.concurrent.TimeUnit
import javax.inject.Inject
internal const val TIMEOUT_DURATION = 7L
class ApiImpl @Inject constructor() : Api {
//region Properties
private val service by lazy {
val moshi = Moshi.Builder()
.add(KotlinJsonAdapterFactory())
.build()
Retrofit.Builder()
.client(
OkHttpClient.Builder()
.connectTimeout(TIMEOUT_DURATION, TimeUnit.SECONDS)
.readTimeout(TIMEOUT_DURATION, TimeUnit.SECONDS)
.addInterceptor(
HttpLoggingInterceptor().apply {
level = HttpLoggingInterceptor.Level.BODY
}
).build()
)
.addConverterFactory(MoshiConverterFactory.create(moshi))
.baseUrl("https://launchlibrary.net/1.4/")
.build()
.create(Api::class.java)
}
//endregion
//region Functions
override suspend fun getNextLaunches(
count: Int,
offset: Int
): Response<LaunchesEntity> =
service.getNextLaunches(count, offset)
override suspend fun getLaunchById(
id: Long
): Response<LaunchEntity> =
service.getLaunchById(id)
//endregion
}