Skip to content

Commit

Permalink
[feat/album]: Name Change AlbumListActivity
Browse files Browse the repository at this point in the history
[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
kez-lab authored and 곽의진 committed Jul 6, 2023
1 parent 3a5ea4a commit 8027845
Show file tree
Hide file tree
Showing 46 changed files with 1,000 additions and 294 deletions.
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ android {

buildTypes {
debug {
//appDistribution upload debug
firebaseAppDistribution {
artifactType = "APK"
releaseNotesFile = "firebase/releaseNote.txt"
Expand Down
17 changes: 10 additions & 7 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@
android:name=".feature.onboarding.OnBoardingActivity"
android:exported="true"
android:theme="@style/Theme.App.Popopopo.Starting">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".feature.setting.SettingActivity"
Expand All @@ -100,7 +95,15 @@
</intent-filter>
</activity>
<activity
android:name=".feature.album.AlbumListActivity"
android:exported="false" />
android:name=".feature.album.list.AlbumListActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:name=".feature.album.detail.AlbumDetailActivity" />
</application>
</manifest>
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"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.teampophory.pophory.config.di

import com.teampophory.pophory.data.network.service.AlbumService
import com.teampophory.pophory.data.network.service.AuthService
import com.teampophory.pophory.data.repository.auth.AuthRepository
import com.teampophory.pophory.data.repository.auth.DefaultAuthRepository
Expand Down
16 changes: 5 additions & 11 deletions app/src/main/java/com/teampophory/pophory/config/di/PhotoModule.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.teampophory.pophory.config.di

import com.teampophory.pophory.data.repository.PhotoRepository
import com.teampophory.pophory.data.repository.DefaultPhotoRepository
import com.teampophory.pophory.network.PhotoNetworkDataSource
import com.teampophory.pophory.network.retrofit.album.RetrofitPhotoNetwork
import com.teampophory.pophory.network.retrofit.album.RetrofitPhotoNetworkApi
import com.teampophory.pophory.data.network.service.AlbumService
import com.teampophory.pophory.data.repository.photo.AlbumRepository
import com.teampophory.pophory.data.repository.photo.DefaultAlbumRepository
import dagger.Binds
import dagger.Module
import dagger.Provides
Expand All @@ -19,17 +17,13 @@ import javax.inject.Singleton
object PhotoModule {
@Provides
@Singleton
fun providePhotoNetworkService(retrofit: Retrofit): RetrofitPhotoNetworkApi = retrofit.create()
fun providePhotoNetworkService(retrofit: Retrofit): AlbumService = retrofit.create()

@Module
@InstallIn(SingletonComponent::class)
interface Binder {
@Binds
@Singleton
fun bindPhotoRepository(defaultPhotoRepository: DefaultPhotoRepository): PhotoRepository

@Binds
@Singleton
fun bindPhotoNwtworkDataSource(retrofitPhotoNetwork: RetrofitPhotoNetwork): PhotoNetworkDataSource
fun bindPhotoRepository(defaultPhotoRepository: DefaultAlbumRepository): AlbumRepository
}
}
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
}
}
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
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.teampophory.pophory.data.repository.fake

import com.teampophory.pophory.data.repository.PhotoRepository
import com.teampophory.pophory.network.model.PhotoListResponse
import com.teampophory.pophory.data.repository.photo.AlbumRepository
import com.teampophory.pophory.data.network.model.album.PhotoListResponse
import kotlinx.coroutines.delay

class FakePhotoRepository : PhotoRepository {
private val fakeImageUrl =
"https://images.unsplash.com/photo-1687023956422-117d5c47029d?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=3432&q=80"
class FakePhotoRepository : AlbumRepository {
private val fakeImageUrl = "https://images.unsplash.com/photo-1687023956422-117d5c47029d?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=3432&q=80"

override suspend fun getPhotos(): Result<PhotoListResponse> {
override suspend fun getPhotos(id: Int): Result<PhotoListResponse> {
delay(300)
return runCatching {
PhotoListResponse(
Expand Down Expand Up @@ -41,4 +40,9 @@ class FakePhotoRepository : PhotoRepository {
)
}
}

override suspend fun deletePhoto(photoId: Long): Result<Unit> {
delay(300)
return runCatching { }
}
}
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>
}
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) }
}

}

This file was deleted.

Loading

0 comments on commit 8027845

Please sign in to comment.