-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat/album]: Name Change AlbumListActivity
[feat/album_detail]: Add Album Detail [feat/album_detail]: Add Bottom Sheet [feat/album_detail]: bottomSheet 이슈 발생 [feat/album_detail]: AlbumDetailActivity 이동 추가 [feat/album_detail]: AlbumDetail Delete Dialog 추가 [feat/album_detail]: AlbumList refactor and PhotoId Int To Long [feat/album_detail]: AlbumList, Album Detail 세부내용 추가
- Loading branch information
Showing
46 changed files
with
1,000 additions
and
294 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
55 changes: 55 additions & 0 deletions
55
app/src/main/java/com/teampophory/pophory/bottomsheet/ModalBottomSheet.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,55 @@ | ||
package com.teampophory.pophory.bottomsheet | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.FrameLayout | ||
import androidx.constraintlayout.widget.ConstraintLayout | ||
import com.google.android.material.bottomsheet.BottomSheetBehavior | ||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment | ||
import com.teampophory.pophory.databinding.ModalBottomSheetContentBinding | ||
|
||
class ModalBottomSheet : BottomSheetDialogFragment() { | ||
|
||
private var _binding: ModalBottomSheetContentBinding? = null | ||
private val binding get() = _binding!! | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View { | ||
_binding = ModalBottomSheetContentBinding.inflate(inflater, container, false) | ||
return binding.root | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
initListMenuViews() | ||
} | ||
|
||
private fun initListMenuViews() { | ||
with(binding) { | ||
tvSortNewest.setOnClickListener { | ||
dismissAllowingStateLoss() | ||
} | ||
tvSortOldest.setOnClickListener { | ||
dismissAllowingStateLoss() | ||
} | ||
} | ||
} | ||
|
||
override fun onStart() { | ||
super.onStart() | ||
} | ||
|
||
override fun onDestroyView() { | ||
_binding = null | ||
super.onDestroyView() | ||
} | ||
|
||
companion object { | ||
const val TAG = "ModalBottomSheet" | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
app/src/main/java/com/teampophory/pophory/config/di/AuthModule.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
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
69 changes: 69 additions & 0 deletions
69
app/src/main/java/com/teampophory/pophory/data/network/model/album/PhotoListResponse.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,69 @@ | ||
package com.teampophory.pophory.data.network.model.album | ||
|
||
import com.teampophory.pophory.feature.album.model.OrientType | ||
import com.teampophory.pophory.feature.album.model.PhotoDetail | ||
import com.teampophory.pophory.feature.album.model.PhotoItem | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class PhotoListResponse( | ||
@SerialName("photos") val photos: List<Photo>? = null | ||
) { | ||
@Serializable | ||
data class Photo( | ||
@SerialName("id") | ||
val id: Int? = null, | ||
@SerialName("studio") | ||
val studio: String? = null, | ||
@SerialName("takenAt") | ||
val takenAt: String? = null, | ||
@SerialName("imageUrl") | ||
val imageUrl: String? = null, | ||
@SerialName("width") | ||
val width: Int? = null, | ||
@SerialName("height") | ||
val height: Int? = null | ||
) | ||
|
||
fun mapPhotosToPhotoItems(): List<PhotoItem> { | ||
val photoItems = mutableListOf<PhotoItem>() | ||
val verticalPhotoDetails = mutableListOf<PhotoDetail>() | ||
photos.orEmpty().forEach { photo -> | ||
val id = photo.id ?: return photoItems | ||
val studio = photo.studio ?: return photoItems | ||
val takenAt = photo.takenAt ?: return photoItems | ||
val imageUrl = photo.imageUrl ?: return photoItems | ||
val width = photo.width ?: return photoItems | ||
val height = photo.height ?: return photoItems | ||
when { | ||
(width > height) -> { | ||
photoItems.add( | ||
PhotoItem.HorizontalItem( | ||
PhotoDetail(id, studio, takenAt, imageUrl, width, height, OrientType.HORIZONTAL) | ||
) | ||
) | ||
} | ||
(width < height) -> { | ||
verticalPhotoDetails.add(PhotoDetail(id, studio, takenAt, imageUrl, width, height, OrientType.VERTICAL)) | ||
if (verticalPhotoDetails.size == 2) { | ||
photoItems.add(PhotoItem.VerticalItem(verticalPhotoDetails.toList())) | ||
verticalPhotoDetails.clear() | ||
} | ||
} | ||
else -> { | ||
photoItems.add( | ||
PhotoItem.HorizontalItem( | ||
PhotoDetail(id, studio, takenAt, imageUrl, width, height, OrientType.NONE) | ||
) | ||
) | ||
} | ||
} | ||
} | ||
|
||
if (verticalPhotoDetails.isNotEmpty()) { | ||
photoItems.add(PhotoItem.VerticalItem(verticalPhotoDetails)) | ||
} | ||
return photoItems | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/teampophory/pophory/data/network/service/AlbumService.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,18 @@ | ||
package com.teampophory.pophory.data.network.service | ||
|
||
import com.teampophory.pophory.data.network.model.album.PhotoListResponse | ||
import retrofit2.http.DELETE | ||
import retrofit2.http.GET | ||
import retrofit2.http.Path | ||
|
||
interface AlbumService { | ||
@GET("api/v1/albums/{albumId}/photos") | ||
suspend fun getPhotos( | ||
@Path("albumId") albumId: Int | ||
): PhotoListResponse | ||
|
||
@DELETE("/api/v1/photo/{photoId}") | ||
suspend fun deletePhoto( | ||
@Path("photoId") photoId: Long | ||
): Unit | ||
} |
14 changes: 0 additions & 14 deletions
14
app/src/main/java/com/teampophory/pophory/data/repository/DefaultPhotoRepository.kt
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
app/src/main/java/com/teampophory/pophory/data/repository/PhotoRepository.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
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/teampophory/pophory/data/repository/photo/AlbumRepository.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,9 @@ | ||
package com.teampophory.pophory.data.repository.photo | ||
|
||
import com.teampophory.pophory.data.network.model.album.PhotoListResponse | ||
|
||
interface AlbumRepository { | ||
suspend fun getPhotos(id: Int): Result<PhotoListResponse> | ||
|
||
suspend fun deletePhoto(photoId: Long): Result<Unit> | ||
} |
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/teampophory/pophory/data/repository/photo/DefaultAlbumRepository.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,18 @@ | ||
package com.teampophory.pophory.data.repository.photo | ||
|
||
import com.teampophory.pophory.data.network.model.album.PhotoListResponse | ||
import com.teampophory.pophory.data.network.service.AlbumService | ||
import javax.inject.Inject | ||
|
||
class DefaultAlbumRepository @Inject constructor( | ||
private val networkApi: AlbumService | ||
) : AlbumRepository { | ||
override suspend fun getPhotos(id:Int): Result<PhotoListResponse> { | ||
return runCatching { networkApi.getPhotos(id) } | ||
} | ||
|
||
override suspend fun deletePhoto(photoId: Long): Result<Unit> { | ||
return runCatching { networkApi.deletePhoto(photoId) } | ||
} | ||
|
||
} |
51 changes: 0 additions & 51 deletions
51
app/src/main/java/com/teampophory/pophory/feature/album/AlbumListActivity.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.