mirror of
https://github.com/melihaksoy/Android-Kotlin-Modulerized-CleanArchitecture.git
synced 2026-03-21 08:59:29 +01:00
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:
20
data/network/build.gradle
Normal file
20
data/network/build.gradle
Normal 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
|
||||
}
|
||||
0
data/network/consumer-rules.pro
Normal file
0
data/network/consumer-rules.pro
Normal file
21
data/network/proguard-rules.pro
vendored
Normal file
21
data/network/proguard-rules.pro
vendored
Normal 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
|
||||
3
data/network/src/main/AndroidManifest.xml
Normal file
3
data/network/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,3 @@
|
||||
<manifest
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.melih.network" />
|
||||
28
data/network/src/main/kotlin/com/melih/network/api/Api.kt
Normal file
28
data/network/src/main/kotlin/com/melih/network/api/Api.kt
Normal 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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user