Conversation
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`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It includes setting up the network layer, defining data classes, and creating a repository to handle the data retrieval.