From e4f0fcbec1b79e7e320baf1f5e41a7d497731dc5 Mon Sep 17 00:00:00 2001 From: Hyun Woo Lee Date: Sun, 20 Feb 2022 21:39:56 +0900 Subject: [PATCH] =?UTF-8?q?[feature/#75]=20FilmRoll=20=ED=99=94=EB=A9=B4?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=82=AC=EC=A7=84=20=ED=81=B4=EB=A6=AD=20?= =?UTF-8?q?=EC=8B=9C=20=EC=82=AC=EC=A7=84=20=EB=8B=A4=EC=9D=B4=EC=96=BC?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=20=EC=A0=9C=EB=8C=80=EB=A1=9C=20=EB=9C=B0=20?= =?UTF-8?q?=EC=88=98=20=EC=9E=88=EA=B2=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../teamfillin/fillin/domain/entity/Photo.kt | 2 +- .../dialog/PhotoDialogFragment.kt | 54 ++++++++++++---- .../presentation/filmroll/CurationAdapter.kt | 7 ++- .../presentation/filmroll/FilmRollActivity.kt | 39 ++++++++---- .../presentation/filmroll/FilmRollAdapter.kt | 7 ++- .../filmroll/FilmRollPagingAdapter.kt | 7 ++- .../fillin/presentation/home/HomeActivity.kt | 2 +- .../main/res/layout/activity_film_roll.xml | 1 - .../main/res/layout/fragment_photo_dialog.xml | 63 +++++++++---------- app/src/main/res/layout/item_curation.xml | 22 +++---- .../main/res/layout/item_curation_first.xml | 2 +- app/src/main/res/layout/item_film_roll.xml | 20 +++--- core/build.gradle.kts | 1 + .../fillin/core/content/RetrofitUtil.kt | 4 +- .../teamfillin/fillin/core/intent/ArgsExt.kt | 2 +- 15 files changed, 138 insertions(+), 95 deletions(-) diff --git a/app/src/main/java/com/teamfillin/fillin/domain/entity/Photo.kt b/app/src/main/java/com/teamfillin/fillin/domain/entity/Photo.kt index 2e192e5..0291d84 100644 --- a/app/src/main/java/com/teamfillin/fillin/domain/entity/Photo.kt +++ b/app/src/main/java/com/teamfillin/fillin/domain/entity/Photo.kt @@ -17,7 +17,7 @@ data class CategoryPhoto( val photoId: Int, val imageUrl: String, val filmId: Int, - val fileName: String, + val filmName: String, val likeCount: Int, val isLiked: Boolean, val isGaro: Boolean diff --git a/app/src/main/java/com/teamfillin/fillin/presentation/dialog/PhotoDialogFragment.kt b/app/src/main/java/com/teamfillin/fillin/presentation/dialog/PhotoDialogFragment.kt index ea9414d..dfe9528 100644 --- a/app/src/main/java/com/teamfillin/fillin/presentation/dialog/PhotoDialogFragment.kt +++ b/app/src/main/java/com/teamfillin/fillin/presentation/dialog/PhotoDialogFragment.kt @@ -7,6 +7,8 @@ import android.view.ViewGroup import android.view.WindowManager import androidx.fragment.app.DialogFragment import com.bumptech.glide.Glide +import com.teamfillin.fillin.R +import com.teamfillin.fillin.core.intent.stringArgs import com.teamfillin.fillin.databinding.FragmentPhotoDialogBinding import dagger.hilt.android.AndroidEntryPoint @@ -15,29 +17,42 @@ class PhotoDialogFragment : DialogFragment() { private var _binding: FragmentPhotoDialogBinding? = null private val binding: FragmentPhotoDialogBinding get() = requireNotNull(_binding) + private val photoUrl by stringArgs() + private val profileUrl by stringArgs() + private val filmName by stringArgs() + private val userName by stringArgs() override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { _binding = FragmentPhotoDialogBinding.inflate(layoutInflater, container, false) - - binding.btnClose.setOnClickListener { - dismiss() - } - binding.heart.setOnClickListener { - binding.number.text = ( - binding.number.text.toString() - .toInt() + (if (!binding.heart.isSelected) 1 else -1) - ).toString() - binding.heart.isSelected = !binding.heart.isSelected - } return binding.root } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - val photoUrl = arguments?.getString("photoUrl") - Glide.with(requireActivity()).load(photoUrl).into(binding.ivPhoto) + super.onViewCreated(view, savedInstanceState) + // TODO by Nunu 좋아요 기능 원복 +// binding.heart.setOnClickListener { +// binding.number.text = ( +// binding.number.text.toString() +// .toInt() + (if (!binding.heart.isSelected) 1 else -1) +// ).toString() +// binding.heart.isSelected = !binding.heart.isSelected +// } + Glide.with(requireContext()) + .load(photoUrl) + .into(binding.ivPhoto) + Glide.with(requireContext()) + .load(profileUrl) + .circleCrop() + .placeholder(R.drawable.ic_basic_profile) + .into(binding.ivProfile) + with(binding) { + btnClose.setOnClickListener { dismiss() } + tvName.text = userName + tvFilmname.text = filmName + } } //휴대폰 크기 맞춰 자동 조절 다이얼로그 @@ -53,4 +68,17 @@ class PhotoDialogFragment : DialogFragment() { super.onDestroyView() _binding = null } + + companion object { + @JvmStatic + fun newInstance(photoUrl: String, profileUrl: String, filmName: String, userName: String) = + PhotoDialogFragment().apply { + arguments = Bundle().apply { + putString("photoUrl", photoUrl) + putString("profileUrl", profileUrl) + putString("filmName", filmName) + putString("userName", userName) + } + } + } } \ No newline at end of file diff --git a/app/src/main/java/com/teamfillin/fillin/presentation/filmroll/CurationAdapter.kt b/app/src/main/java/com/teamfillin/fillin/presentation/filmroll/CurationAdapter.kt index 5a0be80..f0b3e18 100644 --- a/app/src/main/java/com/teamfillin/fillin/presentation/filmroll/CurationAdapter.kt +++ b/app/src/main/java/com/teamfillin/fillin/presentation/filmroll/CurationAdapter.kt @@ -62,9 +62,10 @@ class CurationAdapter( binding.root.setOnClickListener { listener.onClick(input.data) } - binding.btnLike.setOnSingleClickListener { - binding.btnLike.isSelected = !binding.btnLike.isSelected - } + // TODO by Nunu 좋아요 기능 원복 +// binding.btnLike.setOnSingleClickListener { +// binding.btnLike.isSelected = !binding.btnLike.isSelected +// } } } } diff --git a/app/src/main/java/com/teamfillin/fillin/presentation/filmroll/FilmRollActivity.kt b/app/src/main/java/com/teamfillin/fillin/presentation/filmroll/FilmRollActivity.kt index 21d6932..4e99235 100644 --- a/app/src/main/java/com/teamfillin/fillin/presentation/filmroll/FilmRollActivity.kt +++ b/app/src/main/java/com/teamfillin/fillin/presentation/filmroll/FilmRollActivity.kt @@ -2,6 +2,7 @@ package com.teamfillin.fillin.presentation.filmroll import android.app.Activity import android.content.Intent +import android.graphics.Rect import android.os.Bundle import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.contract.ActivityResultContracts @@ -9,6 +10,7 @@ import androidx.activity.viewModels import androidx.lifecycle.flowWithLifecycle import androidx.lifecycle.lifecycleScope import androidx.paging.PagingData +import androidx.recyclerview.widget.RecyclerView import com.google.android.material.tabs.TabLayout import com.teamfillin.fillin.R import com.teamfillin.fillin.core.base.BindingActivity @@ -16,10 +18,11 @@ import com.teamfillin.fillin.core.content.receive import com.teamfillin.fillin.core.view.setOnSingleClickListener import com.teamfillin.fillin.data.service.FilmRollService import com.teamfillin.fillin.databinding.ActivityFilmRollBinding -import com.teamfillin.fillin.presentation.filmroll.add.AddPhotoActivity +import com.teamfillin.fillin.design.dp import com.teamfillin.fillin.presentation.category.FilmRollCategoryActivity import com.teamfillin.fillin.presentation.dialog.PhotoDialogFragment import com.teamfillin.fillin.presentation.filmroll.add.AddCompleteDialog +import com.teamfillin.fillin.presentation.filmroll.add.AddPhotoActivity import com.teamfillin.fillin.presentation.map.SpaceDecoration import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.collectLatest @@ -33,12 +36,9 @@ class FilmRollActivity : BindingActivity(R.layout.activ lateinit var service: FilmRollService private val viewModel by viewModels() private val filmRollPagingAdapter = FilmRollPagingAdapter { - val dialog = PhotoDialogFragment() - val bundle = Bundle().apply { putString("photoUrl", it.imageUrl) } - dialog.apply { - arguments = bundle - show(supportFragmentManager, "dialog") - } + val dialog = + PhotoDialogFragment.newInstance(it.imageUrl, it.userImageUrl, it.filmName, it.nickname) + dialog.show(supportFragmentManager, "dialog") } private lateinit var curationAdapter: CurationAdapter private val addPhotoLauncher = @@ -72,14 +72,27 @@ class FilmRollActivity : BindingActivity(R.layout.activ private fun addCurationList() { service.getCuration().receive({ curationAdapter = CurationAdapter(it.data.curation) { - val dialog = PhotoDialogFragment() - val bundle = Bundle().apply { putString("photoUrl", it.imageUrl) } - dialog.apply { - arguments = bundle - show(supportFragmentManager, "dialog") - } + val dialog = PhotoDialogFragment.newInstance( + photoUrl = it.imageUrl, + profileUrl = it.userImageUrl, + filmName = it.filmName, + userName = it.nickname + ) + dialog.show(supportFragmentManager, "dialog") } binding.rvCuration.adapter = curationAdapter + binding.rvCuration.addItemDecoration(object : RecyclerView.ItemDecoration() { + override fun getItemOffsets( + outRect: Rect, + itemPosition: Int, + parent: RecyclerView + ) { + with(outRect) { + left = if (itemPosition == 0) 16.dp else 8.dp + right = 8.dp + } + } + }) curationAdapter.submitList(it.data.photos) }, { Timber.d("Error $it") diff --git a/app/src/main/java/com/teamfillin/fillin/presentation/filmroll/FilmRollAdapter.kt b/app/src/main/java/com/teamfillin/fillin/presentation/filmroll/FilmRollAdapter.kt index 9bf46cc..5baed39 100644 --- a/app/src/main/java/com/teamfillin/fillin/presentation/filmroll/FilmRollAdapter.kt +++ b/app/src/main/java/com/teamfillin/fillin/presentation/filmroll/FilmRollAdapter.kt @@ -18,9 +18,10 @@ class FilmRollAdapter : Glide.with(binding.root) .load(film.image) .into(binding.ivItemFilmroll) - binding.btnLike.setOnSingleClickListener { - binding.btnLike.isSelected = !binding.btnLike.isSelected - } + // TODO 좋아요 기능 복원 +// binding.btnLike.setOnSingleClickListener { +// binding.btnLike.isSelected = !binding.btnLike.isSelected +// } } } diff --git a/app/src/main/java/com/teamfillin/fillin/presentation/filmroll/FilmRollPagingAdapter.kt b/app/src/main/java/com/teamfillin/fillin/presentation/filmroll/FilmRollPagingAdapter.kt index 6642464..dfa6164 100644 --- a/app/src/main/java/com/teamfillin/fillin/presentation/filmroll/FilmRollPagingAdapter.kt +++ b/app/src/main/java/com/teamfillin/fillin/presentation/filmroll/FilmRollPagingAdapter.kt @@ -33,9 +33,10 @@ class FilmRollPagingAdapter( binding.root.setOnSingleClickListener { itemClickListener.onClick(film) } - binding.btnLike.setOnSingleClickListener { - binding.btnLike.isSelected = !binding.btnLike.isSelected - } + // TODO by Nunu 좋아요 기능 복원 +// binding.btnLike.setOnSingleClickListener { +// binding.btnLike.isSelected = !binding.btnLike.isSelected +// } } } diff --git a/app/src/main/java/com/teamfillin/fillin/presentation/home/HomeActivity.kt b/app/src/main/java/com/teamfillin/fillin/presentation/home/HomeActivity.kt index 15cd8d0..7027301 100644 --- a/app/src/main/java/com/teamfillin/fillin/presentation/home/HomeActivity.kt +++ b/app/src/main/java/com/teamfillin/fillin/presentation/home/HomeActivity.kt @@ -152,7 +152,7 @@ class HomeActivity : BindingActivity(R.layout.activity_home } } markerLocationEvent() - activityNaverMap?.setOnMapClickListener { pointF, latLng -> + activityNaverMap?.setOnMapClickListener { _, _ -> val intent = Intent(this, StudioMapActivity::class.java) startActivity(intent) } diff --git a/app/src/main/res/layout/activity_film_roll.xml b/app/src/main/res/layout/activity_film_roll.xml index 54dd5b1..9530f4a 100644 --- a/app/src/main/res/layout/activity_film_roll.xml +++ b/app/src/main/res/layout/activity_film_roll.xml @@ -84,7 +84,6 @@ android:id="@+id/rv_curation" android:layout_width="match_parent" android:layout_height="120dp" - android:layout_marginStart="15dp" android:layout_marginTop="12dp" android:orientation="horizontal" android:overScrollMode="never" diff --git a/app/src/main/res/layout/fragment_photo_dialog.xml b/app/src/main/res/layout/fragment_photo_dialog.xml index ac014b0..c4a509e 100644 --- a/app/src/main/res/layout/fragment_photo_dialog.xml +++ b/app/src/main/res/layout/fragment_photo_dialog.xml @@ -1,5 +1,4 @@ - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_curation.xml b/app/src/main/res/layout/item_curation.xml index 8b4d3ec..ac88d66 100644 --- a/app/src/main/res/layout/item_curation.xml +++ b/app/src/main/res/layout/item_curation.xml @@ -8,7 +8,7 @@ + android:layout_height="match_parent"> - + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_curation_first.xml b/app/src/main/res/layout/item_curation_first.xml index e1abb2e..c295f02 100644 --- a/app/src/main/res/layout/item_curation_first.xml +++ b/app/src/main/res/layout/item_curation_first.xml @@ -8,7 +8,7 @@ diff --git a/app/src/main/res/layout/item_film_roll.xml b/app/src/main/res/layout/item_film_roll.xml index 53ca89b..77b5163 100644 --- a/app/src/main/res/layout/item_film_roll.xml +++ b/app/src/main/res/layout/item_film_roll.xml @@ -18,15 +18,15 @@ app:layout_constraintTop_toTopOf="parent" tools:src="@drawable/shape_kakao_background" /> - + + + + + + + + + + \ No newline at end of file diff --git a/core/build.gradle.kts b/core/build.gradle.kts index c445099..d86247c 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -61,6 +61,7 @@ dependencies { implementation(platform(ThirdPartyDependencies.okHttpBom)) implementation(ThirdPartyDependencies.okHttp) implementation(ThirdPartyDependencies.retrofit) + implementation(ThirdPartyDependencies.timber) // Test Dependency testImplementation(TestDependencies.jUnit) diff --git a/core/src/main/java/com/teamfillin/fillin/core/content/RetrofitUtil.kt b/core/src/main/java/com/teamfillin/fillin/core/content/RetrofitUtil.kt index 9f1ee46..4ba28e0 100644 --- a/core/src/main/java/com/teamfillin/fillin/core/content/RetrofitUtil.kt +++ b/core/src/main/java/com/teamfillin/fillin/core/content/RetrofitUtil.kt @@ -1,9 +1,9 @@ package com.teamfillin.fillin.core.content -import android.util.Log import retrofit2.Call import retrofit2.Callback import retrofit2.Response +import timber.log.Timber fun Call.receive( onSuccess: (T) -> Unit, @@ -19,7 +19,7 @@ fun Call.receive( } override fun onFailure(call: Call, t: Throwable) { - Log.d("NetworkTest", "error: $t") + Timber.d("RetrofitUtil: Error $t") } }) } \ No newline at end of file diff --git a/core/src/main/java/com/teamfillin/fillin/core/intent/ArgsExt.kt b/core/src/main/java/com/teamfillin/fillin/core/intent/ArgsExt.kt index a720c2f..7032775 100644 --- a/core/src/main/java/com/teamfillin/fillin/core/intent/ArgsExt.kt +++ b/core/src/main/java/com/teamfillin/fillin/core/intent/ArgsExt.kt @@ -16,7 +16,7 @@ fun boolArgs() = ReadOnlyProperty { thisRef, property -> thisRef.requireArguments().getBoolean(property.name) } -fun stringExtra() = ReadOnlyProperty { thisRef, property -> +fun stringArgs() = ReadOnlyProperty { thisRef, property -> thisRef.requireArguments().getString(property.name, "") }