-
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.
Merge pull request #107 from TeamPhotoSurfer/feat/detail_image
[feat] detail_image / 시연으로 인한 중간 pull request (#90)
- Loading branch information
Showing
26 changed files
with
786 additions
and
9 deletions.
There are no files selected for viewing
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
13 changes: 13 additions & 0 deletions
13
data/src/main/java/com/photosurfer/android/data/remote/datasource/RemoteImageDataSource.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,13 @@ | ||
package com.photosurfer.android.data.remote.datasource | ||
|
||
import com.photosurfer.android.data.remote.calladapter.NetworkState | ||
import com.photosurfer.android.data.remote.model.response.BaseResponse | ||
import com.photosurfer.android.data.remote.model.response.DetailImageResponse | ||
import com.photosurfer.android.data.remote.model.response.NoDataResponse | ||
|
||
interface RemoteImageDataSource { | ||
|
||
suspend fun getDetailImageInfo(photoId: Int): NetworkState<BaseResponse<DetailImageResponse>> | ||
|
||
suspend fun deleteImage(options: Map<String, Int>): NetworkState<NoDataResponse> | ||
} |
21 changes: 21 additions & 0 deletions
21
...src/main/java/com/photosurfer/android/data/remote/datasource/RemoteImageDataSourceImpl.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,21 @@ | ||
package com.photosurfer.android.data.remote.datasource | ||
|
||
import com.photosurfer.android.data.remote.calladapter.NetworkState | ||
import com.photosurfer.android.data.remote.model.response.BaseResponse | ||
import com.photosurfer.android.data.remote.model.response.DetailImageResponse | ||
import com.photosurfer.android.data.remote.model.response.NoDataResponse | ||
import com.photosurfer.android.data.remote.service.DeleteImageService | ||
import com.photosurfer.android.data.remote.service.DetailImageService | ||
import javax.inject.Inject | ||
|
||
class RemoteImageDataSourceImpl @Inject constructor( | ||
private val detailImageService: DetailImageService, | ||
private val deleteImageService: DeleteImageService | ||
) : RemoteImageDataSource { | ||
|
||
override suspend fun getDetailImageInfo(photoId: Int): NetworkState<BaseResponse<DetailImageResponse>> = | ||
detailImageService.getDetailImageInfo(photoId) | ||
|
||
override suspend fun deleteImage(options: Map<String, Int>): NetworkState<NoDataResponse> = | ||
deleteImageService.deleteImage(options) | ||
} |
15 changes: 15 additions & 0 deletions
15
data/src/main/java/com/photosurfer/android/data/remote/mapper/ImageMapper.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,15 @@ | ||
package com.photosurfer.android.data.remote.mapper | ||
|
||
import com.photosurfer.android.data.remote.model.response.DetailImageResponse | ||
import com.photosurfer.android.domain.entity.DetailImageInfo | ||
import javax.inject.Inject | ||
|
||
class ImageMapper @Inject constructor() { | ||
|
||
fun toDetailImageInfo(detailImageResponse: DetailImageResponse): DetailImageInfo = | ||
DetailImageInfo( | ||
photoId = detailImageResponse.id, | ||
imageUrl = detailImageResponse.imageUrl, | ||
tagList = detailImageResponse.tags | ||
) | ||
} |
15 changes: 15 additions & 0 deletions
15
data/src/main/java/com/photosurfer/android/data/remote/model/response/DetailImageResponse.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,15 @@ | ||
package com.photosurfer.android.data.remote.model.response | ||
|
||
import com.google.gson.annotations.SerializedName | ||
import com.photosurfer.android.domain.entity.TagInfo | ||
|
||
data class DetailImageResponse( | ||
@SerializedName("id") | ||
val id: Int, | ||
@SerializedName("imageUrl") | ||
val imageUrl: String, | ||
@SerializedName("push") | ||
val push: Int, | ||
@SerializedName("tags") | ||
val tags: List<TagInfo> | ||
) |
13 changes: 13 additions & 0 deletions
13
data/src/main/java/com/photosurfer/android/data/remote/model/response/NoDataResponse.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,13 @@ | ||
package com.photosurfer.android.data.remote.model.response | ||
|
||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class NoDataResponse( | ||
@SerializedName("message") | ||
val message: String, | ||
@SerializedName("status") | ||
val status: Int, | ||
@SerializedName("success") | ||
val success: Boolean | ||
) |
14 changes: 14 additions & 0 deletions
14
data/src/main/java/com/photosurfer/android/data/remote/service/DeleteImageService.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,14 @@ | ||
package com.photosurfer.android.data.remote.service | ||
|
||
import com.photosurfer.android.data.remote.calladapter.NetworkState | ||
import com.photosurfer.android.data.remote.model.response.BaseResponse | ||
import com.photosurfer.android.data.remote.model.response.NoDataResponse | ||
import retrofit2.http.PUT | ||
import retrofit2.http.QueryMap | ||
|
||
interface DeleteImageService { | ||
@PUT("photo") | ||
suspend fun deleteImage( | ||
@QueryMap options: Map<String, Int> | ||
): NetworkState<NoDataResponse> | ||
} |
14 changes: 14 additions & 0 deletions
14
data/src/main/java/com/photosurfer/android/data/remote/service/DetailImageService.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,14 @@ | ||
package com.photosurfer.android.data.remote.service | ||
|
||
import com.photosurfer.android.data.remote.calladapter.NetworkState | ||
import com.photosurfer.android.data.remote.model.response.BaseResponse | ||
import com.photosurfer.android.data.remote.model.response.DetailImageResponse | ||
import retrofit2.http.GET | ||
import retrofit2.http.Path | ||
|
||
interface DetailImageService { | ||
@GET("photo/detail/{photoId}") | ||
suspend fun getDetailImageInfo( | ||
@Path("photoId") photoId: Int | ||
): NetworkState<BaseResponse<DetailImageResponse>> | ||
} |
67 changes: 67 additions & 0 deletions
67
data/src/main/java/com/photosurfer/android/data/repository/ImageRepositoryImpl.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,67 @@ | ||
package com.photosurfer.android.data.repository | ||
|
||
import com.photosurfer.android.core.exception.RetrofitFailureStateException | ||
import com.photosurfer.android.data.remote.calladapter.NetworkState | ||
import com.photosurfer.android.data.remote.datasource.RemoteImageDataSource | ||
import com.photosurfer.android.data.remote.mapper.ImageMapper | ||
import com.photosurfer.android.data.remote.model.request.ChooseTagRequest | ||
import com.photosurfer.android.domain.entity.DetailImageInfo | ||
import com.photosurfer.android.domain.repository.ImageRepository | ||
import timber.log.Timber | ||
import javax.inject.Inject | ||
|
||
class ImageRepositoryImpl @Inject constructor( | ||
private val remoteImageDataSource: RemoteImageDataSource, | ||
private val imageMapper: ImageMapper | ||
) : ImageRepository { | ||
|
||
override suspend fun getDetailImageInfo(photoId: Int): Result<DetailImageInfo> { | ||
when ( | ||
val response = remoteImageDataSource.getDetailImageInfo(photoId) | ||
) { | ||
is NetworkState.Success -> return Result.success( | ||
imageMapper.toDetailImageInfo(response.body.data) | ||
) | ||
is NetworkState.Failure -> return Result.failure( | ||
RetrofitFailureStateException( | ||
response.error, | ||
response.code | ||
) | ||
) | ||
is NetworkState.NetworkError -> Timber.d( | ||
response.error, | ||
"${this.javaClass.name}_getDetailImageInfo" | ||
) | ||
is NetworkState.UnknownError -> Timber.d( | ||
response.t, | ||
"${this.javaClass.name}_getDetailImageInfo" | ||
) | ||
} | ||
return Result.failure(IllegalStateException("NetworkError or UnKnownError please check timber")) | ||
} | ||
|
||
override suspend fun deleteImage(options: Map<String, Int>): Result<String> { | ||
when ( | ||
val response = remoteImageDataSource.deleteImage(options) | ||
) { | ||
is NetworkState.Success -> return Result.success( | ||
response.body.message | ||
) | ||
is NetworkState.Failure -> return Result.failure( | ||
RetrofitFailureStateException( | ||
response.error, | ||
response.code | ||
) | ||
) | ||
is NetworkState.NetworkError -> Timber.d( | ||
response.error, | ||
"${this.javaClass.name}_deleteImage" | ||
) | ||
is NetworkState.UnknownError -> Timber.d( | ||
response.t, | ||
"${this.javaClass.name}_deleteImage" | ||
) | ||
} | ||
return Result.failure(IllegalStateException("NetworkError or UnKnownError please check timber")) | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
domain/src/main/java/com/photosurfer/android/domain/entity/DetailImageInfo.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.photosurfer.android.domain.entity | ||
|
||
data class DetailImageInfo( | ||
val photoId: Int, | ||
val imageUrl: String, | ||
val tagList: List<TagInfo> | ||
) |
10 changes: 10 additions & 0 deletions
10
domain/src/main/java/com/photosurfer/android/domain/repository/ImageRepository.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.photosurfer.android.domain.repository | ||
|
||
import com.photosurfer.android.domain.entity.DetailImageInfo | ||
|
||
interface ImageRepository { | ||
|
||
suspend fun getDetailImageInfo(photoId: Int): Result<DetailImageInfo> | ||
|
||
suspend fun deleteImage(options: Map<String, Int>): Result<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
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 @@ | ||
<manifest> | ||
<application></application> | ||
</manifest> |
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.