Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
cb6e894
change responses to dto
devsadeq May 18, 2023
61455be
create comic model
devsadeq May 18, 2023
e4f006e
move dto inside remote
devsadeq May 18, 2023
ce88f59
create service package
devsadeq May 18, 2023
a198fd4
add room and hilt dependencies
devsadeq May 18, 2023
a95bfa2
create comic entity
devsadeq May 18, 2023
3ea540b
create database
devsadeq May 18, 2023
cf5b9d9
Merge remote-tracking branch 'origin/develop' into feature/home_cache
devsadeq May 18, 2023
71e347a
create marvel application
devsadeq May 19, 2023
f70f0ec
add app hilt annotation
devsadeq May 19, 2023
c2e7443
create daos
devsadeq May 19, 2023
3b51af7
create entities
devsadeq May 19, 2023
126ccd9
create database
devsadeq May 19, 2023
c66587b
create data mappers
devsadeq May 19, 2023
79f47fc
fix import
devsadeq May 19, 2023
92089ae
inject repository impl
devsadeq May 19, 2023
9f9514a
create database hilt module
devsadeq May 19, 2023
e11d009
create network hilt module
devsadeq May 19, 2023
8ae16b6
create repository hilt module
devsadeq May 19, 2023
f1f341d
create domain mappers
devsadeq May 19, 2023
cd407c5
create models
devsadeq May 19, 2023
13fd445
create domain util
devsadeq May 19, 2023
130af83
add hilt dependencies
devsadeq May 19, 2023
0875b8e
inject marvel repository in all viewmodels
devsadeq May 19, 2023
f74870f
create entry points for all fragments
devsadeq May 19, 2023
50f4824
inject repository in event details viewmodel
devsadeq May 19, 2023
e6edbaa
remove unneeded files
devsadeq May 19, 2023
3397ba2
create image url binding adapter without using thumbnail
devsadeq May 19, 2023
492b93e
use models instated of dto in home
devsadeq May 19, 2023
71aeeae
remove to url extension fun from ui util and move it to domain util
devsadeq May 19, 2023
e6a1ea2
edit home ui and remove loading, error views
devsadeq May 19, 2023
81121ae
inject repository and clear home viewmodel
devsadeq May 19, 2023
e2168c9
inject mappers
devsadeq May 20, 2023
c693e3e
edit comic dao
devsadeq May 20, 2023
c9cbf5b
edit event dao
devsadeq May 20, 2023
4cb12d6
fix comic item type
devsadeq May 20, 2023
82a2eff
complete comics cache
devsadeq May 20, 2023
ddd7c2a
complete cache for home screen
devsadeq May 20, 2023
975a3e7
cleanup
devsadeq May 20, 2023
82e7e72
cleanup
devsadeq May 20, 2023
ed3a41f
create extract results extension function
devsadeq May 20, 2023
7265c8b
handle empty screen state
devsadeq May 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
id("org.jetbrains.kotlin.android")
id("kotlin-kapt")
id("androidx.navigation.safeargs")
id("com.google.dagger.hilt.android")
}

android {
Expand All @@ -30,7 +31,11 @@ android {
}

buildConfigField("String", "PUBLIC_KEY", localProperties.getProperty("publicKey") ?: "\"\"")
buildConfigField("String", "PRIVATE_KEY", localProperties.getProperty("privateKey") ?: "\"\"")
buildConfigField(
"String",
"PRIVATE_KEY",
localProperties.getProperty("privateKey") ?: "\"\""
)
}

buildTypes {
Expand All @@ -49,7 +54,7 @@ android {
kotlinOptions {
jvmTarget = "17"
}
dataBinding{
dataBinding {
enable = true
}
viewBinding {
Expand All @@ -58,6 +63,9 @@ android {
buildFeatures {
buildConfig = true
}
kapt {
correctErrorTypes = true
}
}

dependencies {
Expand All @@ -80,6 +88,7 @@ dependencies {

// LiveData
implementation("androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion")
implementation("androidx.lifecycle:lifecycle-reactivestreams-ktx:$lifecycleVersion")

// Retrofit
implementation("com.squareup.retrofit2:retrofit:2.9.0")
Expand All @@ -105,10 +114,22 @@ dependencies {
implementation("com.github.bumptech.glide:glide:4.15.1")

//navigation
val nav_version = "2.5.1"
implementation("androidx.navigation:navigation-fragment-ktx:$nav_version")
implementation("androidx.navigation:navigation-ui-ktx:$nav_version")
val navVersion = "2.5.1"
implementation("androidx.navigation:navigation-fragment-ktx:$navVersion")
implementation("androidx.navigation:navigation-ui-ktx:$navVersion")

// Lottie Animation
implementation("com.airbnb.android:lottie:6.0.0")

// Room Database
val roomVersion = "2.5.1"
implementation("androidx.room:room-runtime:$roomVersion")
kapt("androidx.room:room-compiler:$roomVersion")
implementation("androidx.room:room-ktx:$roomVersion")
implementation("androidx.room:room-rxjava3:$roomVersion")

// Dagger Hilt
val hiltVersion = "2.44"
implementation("com.google.dagger:hilt-android:$hiltVersion")
kapt("com.google.dagger:hilt-android-compiler:$hiltVersion")
}
7 changes: 4 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@
<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".MarvelApplication"
android:allowBackup="true"
android:usesCleartextTraffic="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Marvel"
tools:targetApi="31" >
android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity
android:name=".ui.MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.Marvel" >
android:theme="@style/Theme.Marvel">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/com/red_velvet/marvel/MarvelApplication.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.red_velvet.marvel

import android.app.Application
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class MarvelApplication : Application()
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.red_velvet.marvel.data.local.database

import androidx.room.Database
import androidx.room.RoomDatabase
import com.red_velvet.marvel.data.local.database.dao.CharacterDao
import com.red_velvet.marvel.data.local.database.dao.ComicDao
import com.red_velvet.marvel.data.local.database.dao.EventDao
import com.red_velvet.marvel.data.local.database.entity.CharacterEntity
import com.red_velvet.marvel.data.local.database.entity.ComicEntity
import com.red_velvet.marvel.data.local.database.entity.EventEntity

@Database(
entities = [ComicEntity::class, EventEntity::class, CharacterEntity::class],
version = 1,
)
abstract class MarvelDatabase : RoomDatabase() {
abstract fun comicDao(): ComicDao
abstract fun eventDao(): EventDao
abstract fun characterDao(): CharacterDao
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.red_velvet.marvel.data.local.database.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.red_velvet.marvel.data.local.database.entity.CharacterEntity
import io.reactivex.rxjava3.core.Observable

@Dao
interface CharacterDao {

@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(character: CharacterEntity)

@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertAll(characters: List<CharacterEntity>)

@Query("SELECT * FROM CHARACTER_TABLE")
fun getAll(): Observable<List<CharacterEntity>>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.red_velvet.marvel.data.local.database.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.red_velvet.marvel.data.local.database.entity.ComicEntity
import io.reactivex.rxjava3.core.Completable
import io.reactivex.rxjava3.core.Observable

@Dao
interface ComicDao {

@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(comic: ComicEntity)

@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertAll(comics: List<ComicEntity>)

@Query("SELECT * FROM COMIC_TABLE")
fun getAll(): Observable<List<ComicEntity>>

@Delete
fun delete(comic: ComicEntity): Completable

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.red_velvet.marvel.data.local.database.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.red_velvet.marvel.data.local.database.entity.EventEntity
import io.reactivex.rxjava3.core.Observable

@Dao
interface EventDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(event: EventEntity)

@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertAll(events: List<EventEntity>)

@Query("SELECT * FROM EVENT_TABLE")
fun getAll(): Observable<List<EventEntity>>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.red_velvet.marvel.data.local.database.entity

import androidx.room.Entity
import androidx.room.PrimaryKey

@Entity(tableName = "CHARACTER_TABLE")
data class CharacterEntity(
@PrimaryKey val id: Int,
val name: String,
val imageUrl: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.red_velvet.marvel.data.local.database.entity

import androidx.room.Entity
import androidx.room.PrimaryKey

@Entity(tableName = "COMIC_TABLE")
data class ComicEntity(
@PrimaryKey val id: Int,
val title: String,
val imageUrl: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.red_velvet.marvel.data.local.database.entity

import androidx.room.Entity
import androidx.room.PrimaryKey

@Entity(tableName = "EVENT_TABLE")
data class EventEntity(
@PrimaryKey val id: Int,
val title: String,
val imageUrl: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.red_velvet.marvel.data.local.mapper

import com.red_velvet.marvel.data.local.database.entity.CharacterEntity
import com.red_velvet.marvel.data.remote.dto.CharacterDto
import com.red_velvet.marvel.domain.mapper.Mapper
import com.red_velvet.marvel.domain.util.toUrl

class CharacterEntityMapper : Mapper<CharacterDto, CharacterEntity> {
override fun map(input: CharacterDto): CharacterEntity {
return CharacterEntity(
id = input.id ?: 0,
name = input.name ?: "",
imageUrl = input.thumbnail?.toUrl() ?: ""
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.red_velvet.marvel.data.local.mapper

import com.red_velvet.marvel.data.local.database.entity.ComicEntity
import com.red_velvet.marvel.data.remote.dto.ComicDto
import com.red_velvet.marvel.domain.mapper.Mapper
import com.red_velvet.marvel.domain.util.toUrl

class ComicEntityMapper : Mapper<ComicDto, ComicEntity> {
override fun map(input: ComicDto): ComicEntity {
return ComicEntity(
id = input.id ?: 0,
title = input.title ?: "",
imageUrl = input.thumbnail?.toUrl() ?: "",
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.red_velvet.marvel.data.local.mapper

import com.red_velvet.marvel.data.local.database.entity.EventEntity
import com.red_velvet.marvel.data.remote.dto.EventDto
import com.red_velvet.marvel.domain.mapper.Mapper
import com.red_velvet.marvel.domain.util.toUrl

class EventEntityMapper : Mapper<EventDto, EventEntity> {
override fun map(input: EventDto): EventEntity {
return EventEntity(
id = input.id ?: 0,
title = input.title ?: "",
imageUrl = input.thumbnail?.toUrl() ?: "",
)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.red_velvet.marvel.data.model
package com.red_velvet.marvel.data.remote.dto


import com.google.gson.annotations.SerializedName
Expand All @@ -13,7 +13,7 @@ data class BaseResponse<T>(
@SerializedName("copyright")
val copyright: String? = "",
@SerializedName("data")
val body: DataContainer<T>? = null,
val body: DataContainerDto<T>? = null,
@SerializedName("etag")
val etag: String? = "",
@SerializedName("status")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.red_velvet.marvel.data.model
package com.red_velvet.marvel.data.remote.dto

import com.google.gson.annotations.SerializedName
import com.red_velvet.marvel.data.model.*
import com.red_velvet.marvel.data.remote.dto.*

data class Character(
data class CharacterDto(
@SerializedName("comics")
val comics: ResourceCollection? = ResourceCollection(),
val comics: ResourceCollectionDto? = ResourceCollectionDto(),
@SerializedName("description")
val description: String?,
@SerializedName("events")
val events: ResourceCollection? = ResourceCollection(),
val events: ResourceCollectionDto? = ResourceCollectionDto(),
@SerializedName("id")
val id: Int?,
@SerializedName("modified")
Expand All @@ -19,11 +19,11 @@ data class Character(
@SerializedName("resourceURI")
val resourceURI: String?,
@SerializedName("series")
val series: ResourceCollection? = ResourceCollection(),
val series: ResourceCollectionDto? = ResourceCollectionDto(),
@SerializedName("stories")
val stories: ResourceCollection? = ResourceCollection(),
val stories: ResourceCollectionDto? = ResourceCollectionDto(),
@SerializedName("thumbnail")
val thumbnail: Thumbnail?,
val thumbnail: ThumbnailDto?,
@SerializedName("urls")
val urls: List<Url?>
val urls: List<UrlDto?>
)
Loading