Compare commits
3 Commits
aab5f5e0de
...
main
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1849f72cb6 | ||
![]() |
d6a3ee2a1c | ||
![]() |
5c0a31d648 |
6
.idea/AndroidProjectSystem.xml
generated
Normal file
6
.idea/AndroidProjectSystem.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="AndroidProjectSystem">
|
||||||
|
<option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
|
||||||
|
</component>
|
||||||
|
</project>
|
26
.idea/appInsightsSettings.xml
generated
Normal file
26
.idea/appInsightsSettings.xml
generated
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="AppInsightsSettings">
|
||||||
|
<option name="tabSettings">
|
||||||
|
<map>
|
||||||
|
<entry key="Firebase Crashlytics">
|
||||||
|
<value>
|
||||||
|
<InsightsFilterSettings>
|
||||||
|
<option name="connection">
|
||||||
|
<ConnectionSetting>
|
||||||
|
<option name="appId" value="PLACEHOLDER" />
|
||||||
|
<option name="mobileSdkAppId" value="" />
|
||||||
|
<option name="projectId" value="" />
|
||||||
|
<option name="projectNumber" value="" />
|
||||||
|
</ConnectionSetting>
|
||||||
|
</option>
|
||||||
|
<option name="signal" value="SIGNAL_UNSPECIFIED" />
|
||||||
|
<option name="timeIntervalDays" value="THIRTY_DAYS" />
|
||||||
|
<option name="visibilityType" value="ALL" />
|
||||||
|
</InsightsFilterSettings>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
2
.idea/gradle.xml
generated
2
.idea/gradle.xml
generated
@@ -16,6 +16,7 @@
|
|||||||
</builds>
|
</builds>
|
||||||
</compositeBuild>
|
</compositeBuild>
|
||||||
</compositeConfiguration>
|
</compositeConfiguration>
|
||||||
|
<option name="testRunner" value="CHOOSE_PER_TEST" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
@@ -32,7 +33,6 @@
|
|||||||
<option value="$PROJECT_DIR$/feature/search" />
|
<option value="$PROJECT_DIR$/feature/search" />
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
<option name="resolveExternalAnnotations" value="false" />
|
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
2
.idea/kotlinc.xml
generated
2
.idea/kotlinc.xml
generated
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="KotlinJpsPluginSettings">
|
<component name="KotlinJpsPluginSettings">
|
||||||
<option name="version" value="1.9.24" />
|
<option name="version" value="2.1.20" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
17
.idea/runConfigurations.xml
generated
Normal file
17
.idea/runConfigurations.xml
generated
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RunConfigurationProducerService">
|
||||||
|
<option name="ignoredProducers">
|
||||||
|
<set>
|
||||||
|
<option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.PatternConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
@@ -8,7 +8,7 @@ android {
|
|||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId = "dev.adriankuta.pixabay"
|
applicationId = "dev.adriankuta.pixabay"
|
||||||
targetSdk = 34
|
targetSdk = 35
|
||||||
versionCode = 1
|
versionCode = 1
|
||||||
versionName = "1.0"
|
versionName = "1.0"
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,7 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = JavaVersion.VERSION_17.toString()
|
jvmTarget = JavaVersion.VERSION_21.toString()
|
||||||
}
|
}
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
buildConfig = true
|
buildConfig = true
|
||||||
|
@@ -43,7 +43,6 @@ fun PixabayNavGraph(
|
|||||||
) { entry ->
|
) { entry ->
|
||||||
PhotoDetailRoute(
|
PhotoDetailRoute(
|
||||||
photoId = entry.arguments?.getInt(PHOTO_ID_ARG)!!,
|
photoId = entry.arguments?.getInt(PHOTO_ID_ARG)!!,
|
||||||
onBack = { navController.popBackStack() },
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,13 +21,15 @@ plugins {
|
|||||||
group = "dev.adriankuta.convention.buildlogic"
|
group = "dev.adriankuta.convention.buildlogic"
|
||||||
|
|
||||||
java {
|
java {
|
||||||
sourceCompatibility = JavaVersion.VERSION_17
|
sourceCompatibility = JavaVersion.VERSION_21
|
||||||
targetCompatibility = JavaVersion.VERSION_17
|
targetCompatibility = JavaVersion.VERSION_21
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(libs.android.tools.build.gradle.plugin)
|
compileOnly(libs.android.gradlePlugin)
|
||||||
compileOnly(libs.kotlin.gradle.plugin)
|
compileOnly(libs.compose.gradlePlugin)
|
||||||
|
compileOnly(libs.kotlin.gradlePlugin)
|
||||||
|
compileOnly(libs.ksp.gradlePlugin)
|
||||||
}
|
}
|
||||||
|
|
||||||
gradlePlugin {
|
gradlePlugin {
|
||||||
|
@@ -7,6 +7,7 @@ import org.gradle.kotlin.dsl.getByType
|
|||||||
class ComposeConventionPlugin : Plugin<Project> {
|
class ComposeConventionPlugin : Plugin<Project> {
|
||||||
override fun apply(target: Project) {
|
override fun apply(target: Project) {
|
||||||
with(target) {
|
with(target) {
|
||||||
|
|
||||||
val extension = extensions.getByType<BaseExtension>()
|
val extension = extensions.getByType<BaseExtension>()
|
||||||
configureCompose(extension)
|
configureCompose(extension)
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ import org.gradle.api.JavaVersion
|
|||||||
@Suppress("UnstableApiUsage")
|
@Suppress("UnstableApiUsage")
|
||||||
internal fun configureAndroid(commonExtension: CommonExtension<*, *, *, *, *>) {
|
internal fun configureAndroid(commonExtension: CommonExtension<*, *, *, *, *>) {
|
||||||
commonExtension.apply {
|
commonExtension.apply {
|
||||||
compileSdk = 34
|
compileSdk = 35
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdk = 24
|
minSdk = 24
|
||||||
@@ -19,8 +19,8 @@ internal fun configureAndroid(commonExtension: CommonExtension<*, *, *, *, *>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility = JavaVersion.VERSION_17
|
sourceCompatibility = JavaVersion.VERSION_21
|
||||||
targetCompatibility = JavaVersion.VERSION_17
|
targetCompatibility = JavaVersion.VERSION_21
|
||||||
}
|
}
|
||||||
packaging {
|
packaging {
|
||||||
resources {
|
resources {
|
||||||
|
@@ -4,8 +4,12 @@ import com.android.build.gradle.BaseExtension
|
|||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.artifacts.VersionCatalog
|
import org.gradle.api.artifacts.VersionCatalog
|
||||||
import org.gradle.api.artifacts.VersionCatalogsExtension
|
import org.gradle.api.artifacts.VersionCatalogsExtension
|
||||||
|
import org.gradle.kotlin.dsl.assign
|
||||||
|
import org.gradle.kotlin.dsl.configure
|
||||||
import org.gradle.kotlin.dsl.dependencies
|
import org.gradle.kotlin.dsl.dependencies
|
||||||
import org.gradle.kotlin.dsl.getByType
|
import org.gradle.kotlin.dsl.getByType
|
||||||
|
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension
|
||||||
|
import kotlin.with
|
||||||
|
|
||||||
@Suppress("UnstableApiUsage")
|
@Suppress("UnstableApiUsage")
|
||||||
internal fun Project.configureCompose(commonExtension: BaseExtension) {
|
internal fun Project.configureCompose(commonExtension: BaseExtension) {
|
||||||
@@ -14,8 +18,15 @@ internal fun Project.configureCompose(commonExtension: BaseExtension) {
|
|||||||
compose = true
|
compose = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
with(pluginManager) {
|
||||||
|
apply("org.jetbrains.kotlin.plugin.compose")
|
||||||
|
}
|
||||||
|
|
||||||
val libs: VersionCatalog = extensions.getByType<VersionCatalogsExtension>().named("libs")
|
val libs: VersionCatalog = extensions.getByType<VersionCatalogsExtension>().named("libs")
|
||||||
|
|
||||||
|
/*extensions.configure<ComposeCompilerGradlePluginExtension> {
|
||||||
|
}*/
|
||||||
|
|
||||||
composeOptions {
|
composeOptions {
|
||||||
kotlinCompilerExtensionVersion =
|
kotlinCompilerExtensionVersion =
|
||||||
libs.findVersion("composeCompiler").get().toString()
|
libs.findVersion("composeCompiler").get().toString()
|
||||||
|
@@ -4,4 +4,5 @@ plugins {
|
|||||||
alias(libs.plugins.kotlin.android) apply false
|
alias(libs.plugins.kotlin.android) apply false
|
||||||
alias(libs.plugins.hilt) apply false
|
alias(libs.plugins.hilt) apply false
|
||||||
alias(libs.plugins.ksp) apply false
|
alias(libs.plugins.ksp) apply false
|
||||||
|
alias(libs.plugins.compose.compiler) apply false
|
||||||
}
|
}
|
@@ -23,16 +23,19 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(libs.retrofit)
|
|
||||||
|
|
||||||
implementation(platform(libs.okhttp.bom))
|
|
||||||
implementation(libs.okhttp)
|
|
||||||
implementation(libs.logging.interceptor)
|
|
||||||
|
|
||||||
implementation(libs.androidx.paging.compose)
|
implementation(libs.androidx.paging.compose)
|
||||||
|
|
||||||
implementation(libs.kotlinx.serialization.json)
|
implementation(libs.kotlinx.serialization.json)
|
||||||
implementation(libs.retrofit2.kotlinx.serialization.converter)
|
|
||||||
|
//Ktor
|
||||||
|
implementation(libs.ktor.client.android)
|
||||||
|
implementation(libs.ktor.client.resources)
|
||||||
|
implementation(libs.ktor.client.content.negotiation)
|
||||||
|
implementation(libs.ktor.client.logging)
|
||||||
|
implementation(libs.ktor.serialization.kotlinx.json)
|
||||||
|
|
||||||
|
//Logging
|
||||||
|
implementation(libs.slf4j.android)
|
||||||
|
|
||||||
implementation(libs.androidx.room.runtime)
|
implementation(libs.androidx.room.runtime)
|
||||||
ksp(libs.androidx.room.compiler)
|
ksp(libs.androidx.room.compiler)
|
||||||
|
@@ -1,52 +1,60 @@
|
|||||||
package dev.adriankuta.pixabay.data.di
|
package dev.adriankuta.pixabay.data.di
|
||||||
|
|
||||||
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
|
import dagger.Binds
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import dagger.hilt.InstallIn
|
import dagger.hilt.InstallIn
|
||||||
import dagger.hilt.components.SingletonComponent
|
import dagger.hilt.components.SingletonComponent
|
||||||
import dev.adriankuta.pixabay.data.BuildConfig
|
import dev.adriankuta.pixabay.data.BuildConfig
|
||||||
|
import dev.adriankuta.pixabay.data.network.KtorPixabayService
|
||||||
import dev.adriankuta.pixabay.data.network.PixabayService
|
import dev.adriankuta.pixabay.data.network.PixabayService
|
||||||
|
import io.ktor.client.HttpClient
|
||||||
|
import io.ktor.client.engine.android.Android
|
||||||
|
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
|
||||||
|
import io.ktor.client.plugins.defaultRequest
|
||||||
|
import io.ktor.client.plugins.logging.Logging
|
||||||
|
import io.ktor.client.plugins.resources.Resources
|
||||||
|
import io.ktor.http.URLProtocol
|
||||||
|
import io.ktor.serialization.kotlinx.json.json
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import okhttp3.MediaType.Companion.toMediaType
|
|
||||||
import okhttp3.OkHttpClient
|
|
||||||
import okhttp3.logging.HttpLoggingInterceptor
|
|
||||||
import retrofit2.Retrofit
|
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@InstallIn(SingletonComponent::class)
|
@InstallIn(SingletonComponent::class)
|
||||||
@Module
|
@Module
|
||||||
internal class NetworkModule {
|
internal abstract class NetworkModule {
|
||||||
@Singleton
|
|
||||||
@Provides
|
|
||||||
fun provideHttpLoggingInterceptor(): HttpLoggingInterceptor {
|
|
||||||
val logging = HttpLoggingInterceptor()
|
|
||||||
logging.level =
|
|
||||||
if (BuildConfig.DEBUG) HttpLoggingInterceptor.Level.BODY else HttpLoggingInterceptor.Level.NONE
|
|
||||||
return logging
|
|
||||||
}
|
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Provides
|
@Binds
|
||||||
fun provideOkHttpClient(
|
abstract fun provideKtorApi(ktorPixabayService: KtorPixabayService): PixabayService
|
||||||
httpLoggingInterceptor: HttpLoggingInterceptor
|
|
||||||
): OkHttpClient {
|
companion object {
|
||||||
return OkHttpClient.Builder()
|
@Singleton
|
||||||
.addInterceptor(httpLoggingInterceptor)
|
@Provides
|
||||||
.build()
|
fun provideKtorClient(): HttpClient {
|
||||||
}
|
val httpClient = HttpClient(Android) {
|
||||||
|
install(ContentNegotiation) {
|
||||||
|
json(
|
||||||
|
Json {
|
||||||
|
ignoreUnknownKeys = true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
install(Resources)
|
||||||
|
install(Logging)
|
||||||
|
defaultRequest {
|
||||||
|
url {
|
||||||
|
protocol = URLProtocol.HTTP
|
||||||
|
host = "pixabay.com"
|
||||||
|
parameters.append("key", BuildConfig.PIXABAY_API_KEY)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
engine {
|
||||||
|
connectTimeout = 100_000
|
||||||
|
socketTimeout = 100_000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return httpClient
|
||||||
|
}
|
||||||
|
|
||||||
@Singleton
|
|
||||||
@Provides
|
|
||||||
fun providePixabayApi(
|
|
||||||
okHttpClient: OkHttpClient
|
|
||||||
): PixabayService {
|
|
||||||
val networkJson = Json { ignoreUnknownKeys = true }
|
|
||||||
return Retrofit.Builder()
|
|
||||||
.client(okHttpClient)
|
|
||||||
.baseUrl("https://pixabay.com/")
|
|
||||||
.addConverterFactory(networkJson.asConverterFactory("application/json".toMediaType()))
|
|
||||||
.build()
|
|
||||||
.create(PixabayService::class.java)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -0,0 +1,12 @@
|
|||||||
|
package dev.adriankuta.pixabay.data.dto.request
|
||||||
|
|
||||||
|
import io.ktor.resources.Resource
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
|
||||||
|
@Resource("/api")
|
||||||
|
internal class PixabayImages(
|
||||||
|
@SerialName("q")
|
||||||
|
val query: String,
|
||||||
|
val page: Int,
|
||||||
|
val pageSize: Int
|
||||||
|
)
|
@@ -0,0 +1,8 @@
|
|||||||
|
package dev.adriankuta.pixabay.data.dto.request
|
||||||
|
|
||||||
|
import io.ktor.resources.Resource
|
||||||
|
|
||||||
|
@Resource("/api")
|
||||||
|
internal class PixabayImagesById(
|
||||||
|
val id: String,
|
||||||
|
)
|
@@ -1,5 +1,6 @@
|
|||||||
package dev.adriankuta.pixabay.data.dto.response
|
package dev.adriankuta.pixabay.data.dto.response
|
||||||
|
|
||||||
|
import io.ktor.resources.Resource
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
@@ -0,0 +1,26 @@
|
|||||||
|
package dev.adriankuta.pixabay.data.network
|
||||||
|
|
||||||
|
import dev.adriankuta.pixabay.data.dto.request.PixabayImages
|
||||||
|
import dev.adriankuta.pixabay.data.dto.request.PixabayImagesById
|
||||||
|
import dev.adriankuta.pixabay.data.dto.response.SearchPixabayImagesResponse
|
||||||
|
import io.ktor.client.HttpClient
|
||||||
|
import io.ktor.client.call.body
|
||||||
|
import io.ktor.client.plugins.resources.get
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
internal class KtorPixabayService @Inject constructor(
|
||||||
|
private val client: HttpClient,
|
||||||
|
) : PixabayService {
|
||||||
|
|
||||||
|
override suspend fun searchImages(
|
||||||
|
query: String,
|
||||||
|
page: Int,
|
||||||
|
pageSize: Int
|
||||||
|
): SearchPixabayImagesResponse {
|
||||||
|
return client.get(PixabayImages(query, page, pageSize)).body()
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun searchImageById(id: String): SearchPixabayImagesResponse {
|
||||||
|
return client.get(PixabayImagesById(id)).body()
|
||||||
|
}
|
||||||
|
}
|
@@ -1,23 +1,16 @@
|
|||||||
package dev.adriankuta.pixabay.data.network
|
package dev.adriankuta.pixabay.data.network
|
||||||
|
|
||||||
import dev.adriankuta.pixabay.data.BuildConfig
|
|
||||||
import dev.adriankuta.pixabay.data.dto.response.SearchPixabayImagesResponse
|
import dev.adriankuta.pixabay.data.dto.response.SearchPixabayImagesResponse
|
||||||
import retrofit2.http.GET
|
|
||||||
import retrofit2.http.Query
|
|
||||||
|
|
||||||
internal interface PixabayService {
|
internal interface PixabayService {
|
||||||
|
|
||||||
@GET("api")
|
|
||||||
suspend fun searchImages(
|
suspend fun searchImages(
|
||||||
@Query("q") query: String,
|
query: String,
|
||||||
@Query("page") page: Int,
|
page: Int,
|
||||||
@Query("per_page") pageSize: Int,
|
pageSize: Int
|
||||||
@Query("key") key: String = BuildConfig.PIXABAY_API_KEY
|
|
||||||
): SearchPixabayImagesResponse
|
): SearchPixabayImagesResponse
|
||||||
|
|
||||||
@GET("api")
|
|
||||||
suspend fun searchImageById(
|
suspend fun searchImageById(
|
||||||
@Query("id") query: String,
|
id: String,
|
||||||
@Query("key") key: String = BuildConfig.PIXABAY_API_KEY
|
|
||||||
): SearchPixabayImagesResponse
|
): SearchPixabayImagesResponse
|
||||||
}
|
}
|
@@ -5,7 +5,6 @@ import androidx.paging.PagingState
|
|||||||
import dev.adriankuta.pixabay.data.model.PixabayImage
|
import dev.adriankuta.pixabay.data.model.PixabayImage
|
||||||
import dev.adriankuta.pixabay.data.network.PixabayService
|
import dev.adriankuta.pixabay.data.network.PixabayService
|
||||||
import dev.adriankuta.pixabay.data.repository.PixabayImageRepository.Companion.NETWORK_PAGE_SIZE
|
import dev.adriankuta.pixabay.data.repository.PixabayImageRepository.Companion.NETWORK_PAGE_SIZE
|
||||||
import retrofit2.HttpException
|
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
private const val STARTING_PAGE_INDEX = 1
|
private const val STARTING_PAGE_INDEX = 1
|
||||||
@@ -34,8 +33,6 @@ internal class PixabayPagingSource(
|
|||||||
)
|
)
|
||||||
} catch (exception: IOException) {
|
} catch (exception: IOException) {
|
||||||
return LoadResult.Error(exception)
|
return LoadResult.Error(exception)
|
||||||
} catch (exception: HttpException) {
|
|
||||||
return LoadResult.Error(exception)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -7,12 +7,10 @@ import androidx.paging.LoadType
|
|||||||
import androidx.paging.PagingState
|
import androidx.paging.PagingState
|
||||||
import androidx.paging.RemoteMediator
|
import androidx.paging.RemoteMediator
|
||||||
import androidx.room.withTransaction
|
import androidx.room.withTransaction
|
||||||
import dev.adriankuta.pixabay.data.model.PixabayImage
|
|
||||||
import dev.adriankuta.pixabay.data.network.PixabayService
|
import dev.adriankuta.pixabay.data.network.PixabayService
|
||||||
import dev.adriankuta.pixabay.data.room.AppDatabase
|
import dev.adriankuta.pixabay.data.room.AppDatabase
|
||||||
import dev.adriankuta.pixabay.data.room.entity.PixabayImageEntity
|
import dev.adriankuta.pixabay.data.room.entity.PixabayImageEntity
|
||||||
import dev.adriankuta.pixabay.data.room.entity.RemoteKeys
|
import dev.adriankuta.pixabay.data.room.entity.RemoteKeys
|
||||||
import retrofit2.HttpException
|
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
private const val STARTING_PAGE_INDEX = 1
|
private const val STARTING_PAGE_INDEX = 1
|
||||||
@@ -78,8 +76,6 @@ internal class PixabayRemoteMediator(
|
|||||||
return MediatorResult.Success(endOfPaginationReached = endOfPaginationReached)
|
return MediatorResult.Success(endOfPaginationReached = endOfPaginationReached)
|
||||||
} catch (exception: IOException) {
|
} catch (exception: IOException) {
|
||||||
return MediatorResult.Error(exception)
|
return MediatorResult.Error(exception)
|
||||||
} catch (exception: HttpException) {
|
|
||||||
return MediatorResult.Error(exception)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,6 +16,7 @@ import kotlinx.coroutines.flow.Flow
|
|||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Named
|
||||||
|
|
||||||
internal class PixabayImageRepository @Inject constructor(
|
internal class PixabayImageRepository @Inject constructor(
|
||||||
private val database: AppDatabase,
|
private val database: AppDatabase,
|
||||||
@@ -75,6 +76,6 @@ internal class PixabayImageRepository @Inject constructor(
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val NETWORK_PAGE_SIZE = 30
|
const val NETWORK_PAGE_SIZE = 30
|
||||||
const val USE_CACHE_PAGER = true
|
const val USE_CACHE_PAGER = false
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -39,7 +39,6 @@ import dev.adriankuta.pixabay.feature.details.di.PhotoDetailsViewModelFactory
|
|||||||
@Composable
|
@Composable
|
||||||
fun PhotoDetailRoute(
|
fun PhotoDetailRoute(
|
||||||
photoId: Int,
|
photoId: Int,
|
||||||
onBack: () -> Unit,
|
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
viewModel: PhotoDetailViewModel = hiltViewModel(
|
viewModel: PhotoDetailViewModel = hiltViewModel(
|
||||||
creationCallback = { factory: PhotoDetailsViewModelFactory ->
|
creationCallback = { factory: PhotoDetailsViewModelFactory ->
|
||||||
|
@@ -1,73 +1,82 @@
|
|||||||
[versions]
|
[versions]
|
||||||
androidxNavigation = "2.7.7"
|
androidxNavigation = "2.8.9"
|
||||||
androidGradlePlugin = "8.1.4"
|
androidGradlePlugin = "8.1.4"
|
||||||
agp = "8.6.0-beta02"
|
agp = "8.6.1"
|
||||||
coilCompose = "2.6.0"
|
coilCompose = "2.7.0"
|
||||||
composeCompiler = "1.5.14"
|
composeCompiler = "1.5.15"
|
||||||
kotlin = "1.9.24"
|
kotlin = "2.1.20"
|
||||||
kotlinSerialization = "2.0.0"
|
kotlinSerialization = "2.0.0"
|
||||||
coreKtx = "1.13.1"
|
coreKtx = "1.16.0"
|
||||||
androidxHilt = "1.2.0"
|
androidxHilt = "1.2.0"
|
||||||
junit = "4.13.2"
|
junit = "4.13.2"
|
||||||
junitVersion = "1.2.1"
|
junitVersion = "1.2.1"
|
||||||
espressoCore = "3.6.1"
|
espressoCore = "3.6.1"
|
||||||
androidxLifecycle = "2.8.3"
|
androidxLifecycle = "2.8.7"
|
||||||
activityCompose = "1.9.0"
|
activityCompose = "1.10.1"
|
||||||
composeBom = "2024.06.00"
|
composeBom = "2025.04.01"
|
||||||
kotlinxSerializationJson = "1.6.0"
|
kotlinxSerializationJson = "1.8.0"
|
||||||
|
ktor = "2.3.12"
|
||||||
okhttpBom = "4.12.0"
|
okhttpBom = "4.12.0"
|
||||||
pagingCompose = "3.3.0"
|
pagingCompose = "3.3.6"
|
||||||
retrofit2KotlinxSerializationConverter = "1.0.0"
|
room = "2.7.1"
|
||||||
room = "2.6.1"
|
slf4jAndroid = "1.7.36"
|
||||||
timber = "5.0.1"
|
timber = "5.0.1"
|
||||||
hilt = "2.51.1"
|
hilt = "2.54"
|
||||||
retrofit = "2.11.0"
|
ksp = "2.1.20-2.0.0"
|
||||||
ksp = "1.9.24-1.0.20"
|
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
android-tools-build-gradle-plugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" }
|
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
|
||||||
androidx-compiler = { module = "androidx.compose.compiler:compiler", version.ref = "composeCompiler" }
|
androidx-compiler = { module = "androidx.compose.compiler:compiler", version.ref = "composeCompiler" }
|
||||||
|
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
|
||||||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||||
androidx-hilt-navigation-compose = { group = "androidx.hilt", name = "hilt-navigation-compose", version.ref = "androidxHilt" }
|
|
||||||
androidx-paging-compose = { group = "androidx.paging", name = "paging-compose", version.ref = "pagingCompose" }
|
|
||||||
androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" }
|
|
||||||
androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "room" }
|
|
||||||
androidx-room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "room" }
|
|
||||||
androidx-room-paging = { group = "androidx.room", name = "room-paging", version.ref = "room" }
|
|
||||||
coil-compose = { module = "io.coil-kt:coil-compose", version.ref = "coilCompose" }
|
|
||||||
kotlin-gradle-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
|
|
||||||
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
|
||||||
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
|
|
||||||
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
|
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
|
||||||
|
androidx-hilt-navigation-compose = { group = "androidx.hilt", name = "hilt-navigation-compose", version.ref = "androidxHilt" }
|
||||||
|
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
|
||||||
androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "androidxLifecycle" }
|
androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "androidxLifecycle" }
|
||||||
androidx-lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "androidxLifecycle" }
|
androidx-lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "androidxLifecycle" }
|
||||||
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
|
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
|
||||||
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
|
|
||||||
androidx-navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "androidxNavigation" }
|
androidx-navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "androidxNavigation" }
|
||||||
|
androidx-paging-compose = { group = "androidx.paging", name = "paging-compose", version.ref = "pagingCompose" }
|
||||||
|
androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" }
|
||||||
|
androidx-room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "room" }
|
||||||
|
androidx-room-paging = { group = "androidx.room", name = "room-paging", version.ref = "room" }
|
||||||
|
androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "room" }
|
||||||
androidx-ui = { group = "androidx.compose.ui", name = "ui" }
|
androidx-ui = { group = "androidx.compose.ui", name = "ui" }
|
||||||
androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
|
androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
|
||||||
|
androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
|
||||||
|
androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
|
||||||
androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
|
androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
|
||||||
androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
|
androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
|
||||||
androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
|
coil-compose = { module = "io.coil-kt:coil-compose", version.ref = "coilCompose" }
|
||||||
androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
|
hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" }
|
||||||
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
|
hilt-compiler = { group = "com.google.dagger", name = "hilt-compiler", version.ref = "hilt" }
|
||||||
|
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||||
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerializationJson" }
|
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerializationJson" }
|
||||||
|
ktor-client-android = { group = "io.ktor", name = "ktor-client-android", version.ref = "ktor" }
|
||||||
|
ktor-client-content-negotiation = { group = "io.ktor", name = "ktor-client-content-negotiation", version.ref = "ktor" }
|
||||||
|
ktor-client-logging = { group = "io.ktor", name = "ktor-client-logging", version.ref = "ktor" }
|
||||||
|
ktor-client-resources = { group = "io.ktor", name = "ktor-client-resources", version.ref = "ktor" }
|
||||||
|
ktor-serialization-kotlinx-json = { group = "io.ktor", name = "ktor-serialization-kotlinx-json", version.ref = "ktor" }
|
||||||
logging-interceptor = { module = "com.squareup.okhttp3:logging-interceptor" }
|
logging-interceptor = { module = "com.squareup.okhttp3:logging-interceptor" }
|
||||||
okhttp = { module = "com.squareup.okhttp3:okhttp" }
|
okhttp = { module = "com.squareup.okhttp3:okhttp" }
|
||||||
okhttp-bom = { module = "com.squareup.okhttp3:okhttp-bom", version.ref = "okhttpBom" }
|
okhttp-bom = { module = "com.squareup.okhttp3:okhttp-bom", version.ref = "okhttpBom" }
|
||||||
retrofit2-kotlinx-serialization-converter = { module = "com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter", version.ref = "retrofit2KotlinxSerializationConverter" }
|
slf4j-android = { module = "org.slf4j:slf4j-android", version.ref = "slf4jAndroid" }
|
||||||
timber = { module = "com.jakewharton.timber:timber", version.ref = "timber" }
|
timber = { module = "com.jakewharton.timber:timber", version.ref = "timber" }
|
||||||
hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" }
|
|
||||||
hilt-compiler = { group = "com.google.dagger", name = "hilt-compiler", version.ref = "hilt" }
|
#Build plugins
|
||||||
retrofit = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofit" }
|
android-gradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" }
|
||||||
|
compose-gradlePlugin = { module = "org.jetbrains.kotlin:compose-compiler-gradle-plugin", version.ref = "kotlin" }
|
||||||
|
kotlin-gradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
|
||||||
|
ksp-gradlePlugin = { group = "com.google.devtools.ksp", name = "com.google.devtools.ksp.gradle.plugin", version.ref = "ksp" }
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||||
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
||||||
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
|
|
||||||
convention-android-application = { id = "convention.android.application", version = "unspecified" }
|
convention-android-application = { id = "convention.android.application", version = "unspecified" }
|
||||||
convention-android-library = { id = "convention.android.library", version = "unspecified" }
|
convention-android-library = { id = "convention.android.library", version = "unspecified" }
|
||||||
convention-compose = { id = "convention.compose", version = "unspecified" }
|
convention-compose = { id = "convention.compose", version = "unspecified" }
|
||||||
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
|
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
|
||||||
|
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||||
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlinSerialization" }
|
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlinSerialization" }
|
||||||
|
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user