File tree Expand file tree Collapse file tree 14 files changed +55
-14
lines changed
app/src/main/java/com/paradoxo/materialgram Expand file tree Collapse file tree 14 files changed +55
-14
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package com.paradoxo.materialgram.data
33import com.paradoxo.materialgram.data.local.PostLocalDataSource
44import com.paradoxo.materialgram.data.network.PostService
55import com.paradoxo.materialgram.domain.model.Post
6+ import com.paradoxo.materialgram.domain.toPost
67import kotlinx.coroutines.flow.Flow
78import kotlinx.coroutines.flow.flow
89import javax.inject.Inject
@@ -24,7 +25,7 @@ class PostRepositoryImpl @Inject constructor(
2425 emit(localPosts)
2526 }
2627
27- val remotePosts = postService.getPosts()
28+ val remotePosts = postService.getPosts().map { it.toPost() }
2829 emit(localPosts + remotePosts)
2930 }
3031 }
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package com.paradoxo.materialgram.data
33import com.paradoxo.materialgram.data.local.VideoLocalDataSource
44import com.paradoxo.materialgram.data.network.VideoService
55import com.paradoxo.materialgram.domain.model.Reels
6+ import com.paradoxo.materialgram.domain.toReels
67import kotlinx.coroutines.flow.Flow
78import kotlinx.coroutines.flow.flow
89import javax.inject.Inject
@@ -24,7 +25,7 @@ class VideoRepositoryImpl @Inject constructor(
2425 emit(localVideos)
2526 }
2627
27- val remoteVideos = videoService.getVideos()
28+ val remoteVideos = videoService.getVideos().map { it.toReels() }
2829 emit(localVideos + remoteVideos)
2930 }
3031 }
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ class PostLocalDataSource {
4848 val posts = listOf (
4949 Post (
5050 basePost = basePosts[0 ],
51- medias = medias,
51+ images = medias,
5252 )
5353 )
5454}
Original file line number Diff line number Diff line change 1+ package com.paradoxo.materialgram.data.model
2+
3+ import com.paradoxo.materialgram.domain.model.BasePost
4+ import com.paradoxo.materialgram.domain.model.Media
5+
6+ data class PostResponse (
7+ val basePost : BasePost ,
8+ val medias : List <Media >,
9+ )
10+
Original file line number Diff line number Diff line change 1+ package com.paradoxo.materialgram.data.model
2+
3+ import com.paradoxo.materialgram.domain.model.BasePost
4+
5+
6+ data class VideoResponse (
7+ val video : String ,
8+ val thumbnail : String ,
9+ val basePost : BasePost ,
10+ )
11+
Original file line number Diff line number Diff line change 11package com.paradoxo.materialgram.data.network
22
3- import com.paradoxo.materialgram.domain .model.Post
3+ import com.paradoxo.materialgram.data .model.PostResponse
44import retrofit2.http.GET
55
66interface PostService {
77
8- @GET(" posts.json" )
9- suspend fun getPosts (): List <Post >
8+ @GET(" posts.json" ) // ".json" in the and because api is a mock from github pages
9+ suspend fun getPosts (): List <PostResponse >
1010}
Original file line number Diff line number Diff line change 11package com.paradoxo.materialgram.data.network
22
3- import com.paradoxo.materialgram.domain .model.Reels
3+ import com.paradoxo.materialgram.data .model.VideoResponse
44import retrofit2.http.GET
55
66interface VideoService {
77
8- @GET(" reels.json" )
9- suspend fun getVideos (): List <Reels >
8+ @GET(" reels.json" ) // ".json" in the and because api is a mock from github pages
9+ suspend fun getVideos (): List <VideoResponse >
1010}
Original file line number Diff line number Diff line change 1+ package com.paradoxo.materialgram.domain
2+
3+ import com.paradoxo.materialgram.data.model.PostResponse
4+ import com.paradoxo.materialgram.domain.model.Post
5+
6+ fun PostResponse.toPost (): Post = Post (
7+ basePost = basePost,
8+ images = medias
9+ )
Original file line number Diff line number Diff line change 1+ package com.paradoxo.materialgram.domain
2+
3+ import com.paradoxo.materialgram.data.model.VideoResponse
4+ import com.paradoxo.materialgram.domain.model.Reels
5+
6+ fun VideoResponse.toReels (): Reels = Reels (
7+ video = video,
8+ thumbnail = thumbnail,
9+ basePost = basePost
10+ )
Original file line number Diff line number Diff line change @@ -15,5 +15,4 @@ class VideoUseCaseImpl @Inject constructor(
1515 override suspend fun getVideos (): Flow <List <Reels >> {
1616 return repository.getVideos()
1717 }
18-
1918}
You can’t perform that action at this time.
0 commit comments