-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #39: Save Comic id on Characters Entity & Save Character id on …
…Comics Entity. (#46) - Created strategy to save the comics id on the Characters entity. Signed-off-by: Diego Recalde <difereto89@gmail.com>
- Loading branch information
Showing
27 changed files
with
123 additions
and
106 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
data/src/main/java/com/architect/coders/mu8/data/characters/CharactersComicsResponse.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.architect.coders.mu8.data.characters | ||
|
||
import com.architect.coders.mu8.data.response.common.MarvelItemResponse | ||
import com.architect.codes.mu8.utils.EMPTY_STRING | ||
|
||
data class CharactersComicsResponse( | ||
val available: Int = 0, | ||
val collectionURI: String = EMPTY_STRING, | ||
val items: List<MarvelItemResponse> = emptyList() | ||
) |
This file contains 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
This file contains 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
21 changes: 0 additions & 21 deletions
21
data/src/main/java/com/architect/coders/mu8/data/characters/CharactersMapper.kt
This file was deleted.
Oops, something went wrong.
This file contains 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
25 changes: 25 additions & 0 deletions
25
data/src/main/java/com/architect/coders/mu8/data/characters/CharactersResponse.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.architect.coders.mu8.data.characters | ||
|
||
import com.architect.coders.mu8.data.response.common.ThumbnailResponse | ||
import com.architect.coders.mu8.data.response.common.UrlsResponse | ||
import com.architect.coders.mu8.data.utils.replaceHttps | ||
import com.architect.codes.mu8.utils.COMICS_REGEX | ||
import com.architect.codes.mu8.utils.EMPTY_STRING | ||
|
||
data class CharactersResponse( | ||
val id: Long = 0L, | ||
val name: String = EMPTY_STRING, | ||
val description: String = EMPTY_STRING, | ||
val thumbnail: ThumbnailResponse = ThumbnailResponse(), | ||
val urls: List<UrlsResponse> = emptyList(), | ||
val comics: CharactersComicsResponse = CharactersComicsResponse() | ||
) | ||
|
||
fun CharactersResponse.toDatabaseEntity() = CharactersEntity( | ||
id, name, description, "${thumbnail.path}.${thumbnail.extension}".replaceHttps(), urls, | ||
comics.items.filter { comic -> | ||
comic.resourceURI.contains(COMICS_REGEX) | ||
}.map { comics -> | ||
comics.resourceURI.substringAfter(delimiter = COMICS_REGEX) | ||
} | ||
) |
This file contains 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
This file contains 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
This file contains 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
27 changes: 27 additions & 0 deletions
27
...rc/main/java/com/architect/coders/mu8/data/database/converter/ListStringTypeConverters.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.architect.coders.mu8.data.database.converter | ||
|
||
import androidx.room.TypeConverter | ||
import com.google.gson.Gson | ||
import com.google.gson.reflect.TypeToken | ||
|
||
class ListStringTypeConverters { | ||
|
||
private val gson = Gson() | ||
|
||
@TypeConverter | ||
fun stringToListOfStrings(data: String?): List<String> { | ||
if (data == null || data == "null") { | ||
return emptyList() | ||
} | ||
val type = object : TypeToken<List<String>>() {}.type | ||
return gson.fromJson(data, type) | ||
} | ||
|
||
@TypeConverter | ||
fun listOfStringsToString(urls: List<String>?): String { | ||
if (urls.isNullOrEmpty()) { | ||
gson.toJson(emptyList<String>()) | ||
} | ||
return gson.toJson(urls) | ||
} | ||
} |
This file contains 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
This file contains 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
18 changes: 0 additions & 18 deletions
18
data/src/main/java/com/architect/coders/mu8/data/mapper/common/UrlsMapper.kt
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
data/src/main/java/com/architect/coders/mu8/data/response/common/MarvelItemResponse.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.architect.coders.mu8.data.response.common | ||
|
||
data class MarvelItemResponse(val resourceURI: String, val name: String) |
This file contains 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
3 changes: 0 additions & 3 deletions
3
data/src/main/java/com/architect/coders/mu8/data/response/common/UrlsEntity.kt
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
data/src/main/java/com/architect/coders/mu8/data/response/common/UrlsResponse.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.architect.coders.mu8.data.response.common | ||
|
||
import com.architect.codes.mu8.common.Urls | ||
|
||
data class UrlsResponse(val type: String, val url: String) | ||
|
||
fun UrlsResponse.toDomainEntity() = Urls(type, url) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.