Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/cash app #119

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 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 Down Expand Up @@ -62,6 +63,7 @@ android {

dependencies {
val lifecycleVersion = "2.6.1"
val roomVersion = "2.5.1"

implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.appcompat:appcompat:1.6.1")
Expand Down Expand Up @@ -111,4 +113,13 @@ dependencies {

// Lottie Animation
implementation("com.airbnb.android:lottie:6.0.0")
//rome db
implementation("androidx.room:room-runtime:$roomVersion")
annotationProcessor("androidx.room:room-compiler:$roomVersion")
kapt("androidx.room:room-compiler:$roomVersion")

//dagger hilt
implementation("com.google.dagger:hilt-android:2.44")
kapt("com.google.dagger:hilt-android-compiler:2.44")

}
11 changes: 11 additions & 0 deletions app/src/main/java/com/red_velvet/marvel/data/entity/CharsEntity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.red_velvet.marvel.data.entity

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

@Entity("CHARS_TABLE")
data class CharsEntity(
@PrimaryKey val id :Int,
val title :String,
val img :String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.red_velvet.marvel.data.entity

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

@Entity("COMICS_TABLE")
data class ComicsEntity(
@PrimaryKey val id :Int,
val title :String,
val img :String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.red_velvet.marvel.data.entity

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

@Entity("Events_TABLE")
data class EventsEntity(
@PrimaryKey val id :Int,
val title :String,
val img :String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.red_velvet.marvel.data.entity

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

@Entity("EVENTS_SEARCH_TABLE")
data class EventsSearch(
@PrimaryKey val id :Int,
val title :String,
val img :String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.red_velvet.marvel.data.entity

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

@Entity("SERIES_SEARCH_TABLE")
data class SeriesSearch(
@PrimaryKey val id :Int,
val title :String,
val img :String,
)
44 changes: 44 additions & 0 deletions app/src/main/java/com/red_velvet/marvel/data/local/MovieDao.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.red_velvet.marvel.data.local

import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.red_velvet.marvel.data.entity.CharsEntity
import com.red_velvet.marvel.data.entity.ComicsEntity
import com.red_velvet.marvel.data.entity.EventsEntity
import com.red_velvet.marvel.data.entity.EventsSearch
import com.red_velvet.marvel.data.entity.SeriesSearch
import io.reactivex.rxjava3.core.Completable
import io.reactivex.rxjava3.core.Observable

interface MovieDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertChars(charsEntity: List<CharsEntity>): Completable

@Query("SELECT * FROM CHARS_TABLE")
fun getAllChars() : Observable<List<CharsEntity>>

@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertComics(comicsEntity: List<ComicsEntity>):Completable

@Query("SELECT * FROM COMICS_TABLE")
fun getAllComics() : Observable<List<ComicsEntity>>

@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertEvents(eventsEntity: List<EventsEntity>): Completable

@Query("SELECT * FROM EVENTS_TABLE")
fun getAllEvents() : Observable<List<EventsEntity>>

@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertEventsSearch(eventsSearch: EventsSearch): Completable

@Query("SELECT * FROM EVENTS_SEARCH_TABLE")
fun getAllEventsSearch() : Observable<List<EventsSearch>>

@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertSeries(seriesSearch: SeriesSearch): Completable

@Query("SELECT * FROM SERIES_SEARCH_TABLE")
fun getAllSeries() : Observable<List<SeriesSearch>>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.red_velvet.marvel.data.local
import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import com.red_velvet.marvel.data.entity.ComicsEntity
import com.red_velvet.marvel.data.entity.EventsEntity
import com.red_velvet.marvel.data.entity.EventsSearch
import com.red_velvet.marvel.data.entity.SeriesSearch
import javax.inject.Inject
import javax.inject.Singleton


@Database(entities = [
SeriesSearch::class,
EventsEntity::class,
EventsSearch::class,
Char::class
, ComicsEntity::class] , version = 1)
abstract class MovieDataBase : RoomDatabase() {

abstract fun movieDao(): MovieDao

companion object {

@Volatile
private var instance: MovieDataBase? = null

@Singleton
@Inject
fun getInstance(context: Context): MovieDataBase {
return instance ?: synchronized(this) {
Room.databaseBuilder(context, MovieDataBase::class.java, DATABASE_NAME).build()
.also { instance = it }
}
}

const val DATABASE_NAME = "marvel"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.red_velvet.marvel.data.model
import com.google.gson.annotations.SerializedName
import com.red_velvet.marvel.data.model.*

data class Character(
data class CharacterDto(
@SerializedName("comics")
val comics: ResourceCollection? = ResourceCollection(),
@SerializedName("description")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.red_velvet.marvel.data.model

import com.google.gson.annotations.SerializedName

data class Comic(
data class ComicDto(
@SerializedName("characters")
val characters: ResourceCollection? = ResourceCollection(),
@SerializedName("collectedIssues")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.red_velvet.marvel.data.model

import com.google.gson.annotations.SerializedName

data class Event(
data class EventDto(
@SerializedName("id")
val id: Int? = 0,
@SerializedName("title")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.red_velvet.marvel.data.remote

import com.red_velvet.marvel.data.model.BaseResponse
import com.red_velvet.marvel.data.model.Character
import com.red_velvet.marvel.data.model.Comic
import com.red_velvet.marvel.data.model.CharacterDto
import com.red_velvet.marvel.data.model.ComicDto
import com.red_velvet.marvel.data.model.Creator
import com.red_velvet.marvel.data.model.Event
import com.red_velvet.marvel.data.model.EventDto
import com.red_velvet.marvel.data.model.Series
import com.red_velvet.marvel.data.model.Story
import io.reactivex.rxjava3.core.Single
Expand All @@ -19,19 +19,19 @@ interface MarvelService {
fun getAllComics(
@Query("titleStartsWith") titleStartsWith: String? = null,
@Query("dateDescriptor") dateDescriptor: String? = null,
): Single<Response<BaseResponse<List<Comic>>>>
): Single<Response<BaseResponse<List<ComicDto>>>>

@GET("comics/{comicId}")
fun getComicDetailById(
@Path("comicId") comicId: Int
): Single<Response<BaseResponse<List<Comic>>>>
): Single<Response<BaseResponse<List<ComicDto>>>>

@GET("characters/{characterId}/comics")
fun getComicsByCharacterId(
@Path("characterId") characterId: Int,
@Query("titleStartsWith") titleStartsWith: String? = null,
@Query("dateDescriptor") dateDescriptor: String? = null
): Single<Response<BaseResponse<List<Comic>>>>
): Single<Response<BaseResponse<List<ComicDto>>>>

@GET("comics/{comicId}/creators")
fun getCreatorByComicId(
Expand All @@ -52,17 +52,17 @@ interface MarvelService {
@GET("events")
fun getAllEvents(
@Query("nameStartsWith") nameStartsWith: String? = null
): Single<Response<BaseResponse<List<Event>>>>
): Single<Response<BaseResponse<List<EventDto>>>>

@GET("comics/{comicId}/characters")
fun getCharactersByComicId(
@Path("comicId") comicId: Int? = null,
): Single<Response<BaseResponse<List<Character>>>>
): Single<Response<BaseResponse<List<CharacterDto>>>>

@GET("events/{eventId}/characters")
fun getCharactersByEventId(
@Path("eventId") eventId: Int,
): Single<Response<BaseResponse<List<Character>>>>
): Single<Response<BaseResponse<List<CharacterDto>>>>

@GET("events/{eventId}/creators")
fun getCreatorsByEventId(
Expand All @@ -85,17 +85,17 @@ interface MarvelService {
@GET("stories/{storyId}/comics")
fun getComicsByStoryId(
@Path("storyId") storyId: Int
): Single<Response<BaseResponse<List<Comic>>>>
): Single<Response<BaseResponse<List<ComicDto>>>>

@GET("characters")
fun getAllCharacters(
@Query("nameStartsWith") nameStartsWith: String? = null
): Single<Response<BaseResponse<List<Character>>>>
): Single<Response<BaseResponse<List<CharacterDto>>>>

@GET("characters/{characterId}")
fun getCharacterById(
@Path("characterId") characterId: Int
): Single<Response<BaseResponse<List<Character>>>>
): Single<Response<BaseResponse<List<CharacterDto>>>>

@GET("characters/{characterId}/series")
fun getSeriesByCharacterId(
Expand All @@ -110,5 +110,5 @@ interface MarvelService {
@GET("events/{eventId}")
fun getEventById(
@Path("eventId") eventId: Int
): Single<Response<BaseResponse<List<Event>>>>
): Single<Response<BaseResponse<List<EventDto>>>>
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
package com.red_velvet.marvel.data.repository


import com.red_velvet.marvel.data.model.Character
import com.red_velvet.marvel.data.model.Comic
import com.red_velvet.marvel.data.entity.CharsEntity
import com.red_velvet.marvel.data.entity.ComicsEntity
import com.red_velvet.marvel.data.entity.EventsEntity
import com.red_velvet.marvel.data.entity.EventsSearch
import com.red_velvet.marvel.data.entity.SeriesSearch
import com.red_velvet.marvel.data.model.CharacterDto
import com.red_velvet.marvel.data.model.ComicDto
import com.red_velvet.marvel.data.model.Creator
import com.red_velvet.marvel.data.model.Event
import com.red_velvet.marvel.data.model.EventDto
import com.red_velvet.marvel.data.model.Series
import com.red_velvet.marvel.data.model.Story
import com.red_velvet.marvel.domain.models.Chars
import com.red_velvet.marvel.domain.models.Comic
import com.red_velvet.marvel.domain.models.Event
import com.red_velvet.marvel.ui.utils.State
import io.reactivex.rxjava3.core.Observable

interface MarvelRepository {


fun getAllComics(
titleStartsWith: String? = null,
dateDescriptor: String? = null,
): Observable<State<List<Comic>>>
): Observable<State<List<ComicDto>>>

fun getComicById(comicId: Int): Observable<State<List<Comic>>>
fun getComicById(comicId: Int): Observable<State<List<ComicDto>>>

fun getComicsByCharacterId(characterId: Int): Observable<State<List<Comic>>>
fun getComicsByCharacterId(characterId: Int): Observable<State<List<ComicDto>>>

fun getAllSeries(
titleStartsWith: String? = null,
Expand All @@ -30,9 +39,9 @@ interface MarvelRepository {

fun getSeriesById(seriesId: Int): Observable<State<List<Series>>>

fun getAllEvents(query: String? = null): Observable<State<List<Event>>>
fun getAllEvents(query: String? = null): Observable<State<List<EventDto>>>

fun getCharactersByEventId(eventId: Int): Observable<State<List<Character>>>
fun getCharactersByEventId(eventId: Int): Observable<State<List<CharacterDto>>>

fun getCreatorsByEventId(eventId: Int): Observable<State<List<Creator>>>

Expand All @@ -42,18 +51,29 @@ interface MarvelRepository {

fun getCreatorsByStoryId(storyId: Int): Observable<State<List<Creator>>>

fun getComicsByStoryId(storyId: Int): Observable<State<List<Comic>>>
fun getComicsByStoryId(storyId: Int): Observable<State<List<ComicDto>>>

fun getCharactersByComicId(comicId: Int): Observable<State<List<Character>>>
fun getCharactersByComicId(comicId: Int): Observable<State<List<CharacterDto>>>

fun getEventById(eventId: Int): Observable<State<List<Event>>>
fun getEventById(eventId: Int): Observable<State<List<EventDto>>>

fun getAllCharacters(nameStartsWith: String? = null): Observable<State<List<Character>>>
fun getAllCharacters(nameStartsWith: String? = null): Observable<State<List<CharacterDto>>>

fun getCharacterById(characterId: Int): Observable<State<List<Character>>>
fun getCharacterById(characterId: Int): Observable<State<List<CharacterDto>>>

fun getCreatorsBySeriesId(seriesId: Int): Observable<State<List<Creator>>>

fun getSeriesByCharacterId(characterId: Int): Observable<State<List<Series>>>

fun refreshComics()
fun refreshCharacters()
fun refreshEvents()
fun refreshEventsSearch()

fun getEventsSearch(): Observable<List<EventsSearch>>

fun getAllComics(): Observable<List<Comic>>
fun getAllEvents(): Observable<List<Event>>
fun getAllCharacters(): Observable<List<Chars>>
}

Loading