https://github.com/okellosam21/chatwise-assignment
This Android application is a simple product catalog viewer developed as part of the ChatWise assignment. The app allows users to browse a list of products and view detailed information about each produc
https://github.com/okellosam21/chatwise-assignment
coil kotlin-android retrofit2 xml
Last synced: over 1 year ago
JSON representation
This Android application is a simple product catalog viewer developed as part of the ChatWise assignment. The app allows users to browse a list of products and view detailed information about each produc
- Host: GitHub
- URL: https://github.com/okellosam21/chatwise-assignment
- Owner: OkelloSam21
- Created: 2024-08-06T09:18:09.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-07T12:34:33.000Z (almost 2 years ago)
- Last Synced: 2025-01-13T22:17:09.764Z (over 1 year ago)
- Topics: coil, kotlin-android, retrofit2, xml
- Language: Kotlin
- Homepage:
- Size: 128 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Chatwise Assignment
This project is an Android application that displays a list of products and their details. It uses Retrofit for network requests, Gson for JSON serialization/deserialization, and Coil for image loading.
## Features
- Fetches a list of products from a remote API.
- Displays the list of products in a `RecyclerView`.
- Shows product details in a separate activity when a product is clicked.
## Technologies Used
- Kotlin
- Retrofit
- Gson
- Coil
- AndroidX Libraries
- Coroutines
## Project Structure
```
app/
├── src/
│ ├── main/
│ │ ├── java/com/samuelokello/chatwiseassignment/
│ │ │ ├── data/
│ │ │ │ └── remote/
│ │ │ │ └── ApiService.kt
│ │ │ ├── domain/
│ │ │ │ └── ProductRepository.kt
│ │ │ ├── ui/
│ │ │ │ ├── ProductAdapter.kt
│ │ │ │ ├── ProductDetailActivity.kt
│ │ │ │ └── ProductListActivity.kt
│ │ │ └── Product.kt
│ │ ├── res/
│ │ │ ├── layout/
│ │ │ │ ├── activity_product_detail.xml
│ │ │ │ ├── activity_product_list.xml
│ │ │ │ └── product_item.xml
│ │ │ └── values/
│ │ │ └── strings.xml
│ └── build.gradle
└── build.gradle
```
## Getting Started
### Prerequisites
- Android Studio
- Kotlin 1.5+
- Gradle 7.0+
### Installation
1. Clone the repository:
```sh
git clone https://github.com/OkelloSam21/chatwise-assignment.git
```
2. Open the project in Android Studio.
3. Sync the project with Gradle files.
### Running the App
1. Connect an Android device or start an emulator.
2. Click on the "Run" button in Android Studio.
## Code Overview
### `ApiService`
Defines the API endpoints using Retrofit.
```kotlin
interface ApiService {
@GET("products")
suspend fun getProducts(): ProductResponse
}
```
### `ProductRepository`
Handles data operations and provides a clean API for data access to the rest of the application.
```kotlin
class ProductRepository {
private val apiService: ApiService = // initialize Retrofit service
suspend fun getProducts(): List {
return apiService.getProducts().products
}
}
```
### `ProductListActivity`
Displays a list of products using a `RecyclerView`.
```kotlin
class ProductListActivity : AppCompatActivity() {
// Implementation details
}
```
### `ProductDetailActivity`
Displays the details of a selected product.
```kotlin
class ProductDetailActivity : AppCompatActivity() {
// Implementation details
}
```
### `ProductAdapter`
Adapter for the `RecyclerView` in `ProductListActivity`.
```kotlin
class ProductAdapter(
private var products: List,
private val onItemClick: (Product) -> Unit
) : RecyclerView.Adapter() {
// Implementation details
}
```
## Screenshots



This project is licensed under the MIT License. See the `LICENSE` file for details.