mirror of
https://github.com/AdrianKuta/KahootQuiz.git
synced 2025-11-02 18:03:40 +01:00
feat: Implement data layer and basic quiz fetching logic
This commit introduces the data layer, including the `QuizRepository` and its implementation, and integrates it with the domain layer's `GetQuizUseCase`. It also sets up Hilt for dependency injection in the app module and makes preliminary UI changes to display fetched quiz data.
Key changes include:
- **Data Layer (`model:data` module):**
- Added `QuizRepositoryImpl` which implements `QuizRepository` from the domain layer.
- Implemented `getQuiz()` in `QuizRepositoryImpl` to fetch quiz data from `QuizApi` and map it to the domain `Quiz` model using `QuizMapper`.
- Created `QuizMapper` to convert `QuizResponseDto` to the domain `Quiz` model.
- Added `RepositoryModule` for Hilt to provide `QuizRepository` bindings.
- **Domain Layer (`domain` module):**
- Created `Quiz` domain model.
- Defined `QuizRepository` interface.
- Implemented `GetQuizUseCase` to interact with `QuizRepository`.
- **App Module (`app` module):**
- Added `MyApplication` class annotated with `@HiltAndroidApp`.
- Updated `AndroidManifest.xml` to use `MyApplication` and add internet permission.
- In `MainActivity`:
- Injected `GetQuizUseCase`.
- Used `LaunchedEffect` to call the use case and update a mutable state `quizId`.
- Modified the `Greeting` composable to display the fetched `quizId`.
- Added dependency on the `domain` module in `app/build.gradle.kts`.
- **Network Layer (`core:network` module):**
- Moved DTOs from `core.network.model` package to `core.network.models`.
- Made `NetworkModule` internal.
- Removed unused `QuizService` interface and `QuizServiceImpl` class.
- **Testing (`core:network` test):**
- Updated import path for `QuizResponseDto` in `QuizResponseDtoParsingTest`.
This commit is contained in:
@@ -1,4 +0,0 @@
|
||||
package dev.adriankuta.kahootquiz.core.network
|
||||
|
||||
interface QuizService {
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package dev.adriankuta.kahootquiz.core.network
|
||||
|
||||
internal class QuizServiceImpl: QuizService {
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import javax.inject.Singleton
|
||||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
object NetworkModule {
|
||||
internal object NetworkModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.adriankuta.kahootquiz.core.network.model
|
||||
package dev.adriankuta.kahootquiz.core.network.models
|
||||
|
||||
// Commonly reused DTOs
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.adriankuta.kahootquiz.core.network.model
|
||||
package dev.adriankuta.kahootquiz.core.network.models
|
||||
|
||||
// Content tags DTOs
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.adriankuta.kahootquiz.core.network.model
|
||||
package dev.adriankuta.kahootquiz.core.network.models
|
||||
|
||||
// Cover metadata and related DTOs
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.adriankuta.kahootquiz.core.network.model
|
||||
package dev.adriankuta.kahootquiz.core.network.models
|
||||
|
||||
// Metadata section DTOs
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.adriankuta.kahootquiz.core.network.model
|
||||
package dev.adriankuta.kahootquiz.core.network.models
|
||||
|
||||
// Question and choice related DTOs
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.adriankuta.kahootquiz.core.network.model
|
||||
package dev.adriankuta.kahootquiz.core.network.models
|
||||
|
||||
// This file used to contain all DTOs in one place.
|
||||
// The DTOs have been split into separate files for maintainability:
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.adriankuta.kahootquiz.core.network.model
|
||||
package dev.adriankuta.kahootquiz.core.network.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.adriankuta.kahootquiz.core.network.retrofit
|
||||
|
||||
import dev.adriankuta.kahootquiz.core.network.model.QuizResponseDto
|
||||
import dev.adriankuta.kahootquiz.core.network.models.QuizResponseDto
|
||||
import retrofit2.http.GET
|
||||
|
||||
interface QuizApi {
|
||||
|
||||
@@ -2,7 +2,7 @@ package dev.adriankuta.kahootquiz.core.network
|
||||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import com.google.gson.Gson
|
||||
import dev.adriankuta.kahootquiz.core.network.model.QuizResponseDto
|
||||
import dev.adriankuta.kahootquiz.core.network.models.QuizResponseDto
|
||||
import org.junit.Test
|
||||
import java.io.InputStreamReader
|
||||
|
||||
|
||||
Reference in New Issue
Block a user