Skip to content

Networking and Data Layer#2

Merged
CGreenP merged 2 commits intomasterfrom
dev
Apr 4, 2025
Merged

Networking and Data Layer#2
CGreenP merged 2 commits intomasterfrom
dev

Conversation

@CGreenP
Copy link
Copy Markdown
Owner

@CGreenP CGreenP commented Apr 4, 2025

It includes setting up the network layer, defining data classes, and creating a repository to handle the data retrieval.

CGreenP added 2 commits April 4, 2025 22:00
This commit introduces the internet permission to the app manifest and updates the project's JDK level.

Changes:

-   Added the `android.permission.INTERNET` permission to the `AndroidManifest.xml` file.
-   Updated the project's JDK level to `JDK_21` in the `.idea/misc.xml` file.
This commit introduces the ability to fetch user data from a remote API using Retrofit. It includes setting up the network layer, defining data classes, and creating a repository to handle the data retrieval.

Changes:

-   Created `UserApi` interface to define the API endpoint for fetching users using `@GET("/users")`.
-   Created `RetrofitInstance` to provide a configured Retrofit instance and `UserApi`. It includes:
    -   A `provideRetrofit` function that configures Retrofit with a base URL, an `OkHttpClient` with a logging interceptor, and a `GsonConverterFactory`.
    -   A `provideUserApi` function that creates and returns an instance of the `UserApi`.
-   Added `UserRepository` to manage fetching user data. It uses a flow to emit results and handles network errors.
-   Added `User`, `Address`, `Geo`, and `Company` data classes to represent the user data structure.
-   `UserRepository` now handles API responses, emits either a list of users or an error Result, and shifts network operations to `Dispatchers.IO` using `flowOn`.
- Added dependencies `okhttp3`, `logging-interceptor`, `retrofit2`, `converter-gson`
@CGreenP CGreenP merged commit 9eb5b4e into master Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant