Skip to content

Commit

Permalink
[Feature/store_album_cover] 앨범커버 이미지 리소스 변경 로직 (#99)
Browse files Browse the repository at this point in the history
* [feat/loading]: add mypage, store loading

* [feat/mypage]: feat 앨범커버 번호에 따른 앨범커버 변경

* [feat/mypage]: edit util toCoverDrawable

* [feat/mypage]: refactor album cover setBackgroundResource

* [feat/mypage]: chore exported false
  • Loading branch information
librarywon authored Jul 7, 2023
1 parent bc56097 commit a4eb59f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.GridLayoutManager
import com.teampophory.pophory.R
import com.teampophory.pophory.common.fragment.hideLoading
import com.teampophory.pophory.common.fragment.showLoading
import com.teampophory.pophory.common.fragment.toast
import com.teampophory.pophory.common.view.GridSpacingItemDecoration
import com.teampophory.pophory.common.view.dp
Expand Down Expand Up @@ -56,9 +58,12 @@ class MyPageFragment : Fragment() {
initRecyclerView()
}

is MyPageInfoState.Loading -> {}
is MyPageInfoState.Loading -> {
showLoading()
}

is MyPageInfoState.SuccessMyPageInfo -> {
hideLoading()
val photoItems =
myPageInfoState.data.filterIsInstance<MyPageDisplayItem.Photo>()
val isEmpty = photoItems.isEmpty()
Expand All @@ -77,8 +82,9 @@ class MyPageFragment : Fragment() {
}
}


is MyPageInfoState.Error -> {}
is MyPageInfoState.Error -> {
hideLoading()
}
else -> {}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import androidx.fragment.app.viewModels
import androidx.viewpager2.widget.ViewPager2
import com.teampophory.pophory.R
import com.teampophory.pophory.common.fragment.colorOf
import com.teampophory.pophory.common.fragment.hideLoading
import com.teampophory.pophory.common.fragment.showLoading
import com.teampophory.pophory.common.primitive.textAppearance
import com.teampophory.pophory.common.view.viewBinding
import com.teampophory.pophory.databinding.FragmentStoreBinding
Expand Down Expand Up @@ -54,9 +56,12 @@ class StoreFragment : Fragment(), OnPageChangedListener {
setupViewPager()
}

is StoreState.Loading -> {}
is StoreState.Loading -> {
showLoading()
}

is StoreState.SuccessAlbums -> {
hideLoading()
with(binding) {
storeAdapter?.submitList(storeState.data)

Expand All @@ -65,7 +70,9 @@ class StoreFragment : Fragment(), OnPageChangedListener {
}
}

is StoreState.Error -> {}
is StoreState.Error -> {
hideLoading()
}
else -> {}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.teampophory.pophory.R
import com.teampophory.pophory.common.view.ItemDiffCallback
import com.teampophory.pophory.databinding.ItemStorePagerBinding
import com.teampophory.pophory.feature.home.store.model.AlbumItem
import com.teampophory.pophory.util.toCoverDrawable

class StoreAdapter(
private val onItemClicked: (AlbumItem) -> Unit,
Expand All @@ -29,6 +31,9 @@ class StoreAdapter(
private val onPageChangedListener: OnPageChangedListener
) : RecyclerView.ViewHolder(binding.root) {
fun bind(albumItem: AlbumItem) {

binding.ivStorePager.setBackgroundResource(albumItem.albumCover.toCoverDrawable())

itemView.setOnClickListener {
onItemClicked(albumItem)
onPageChangedListener.onPageChanged(albumItem)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package com.teampophory.pophory.util
import com.teampophory.pophory.R

fun Int.toCoverDrawable() = when (this) {
0 -> R.drawable.ic_album_cover_friends
1 -> R.drawable.ic_album_cover_love
2 -> R.drawable.ic_album_cover_myalbum
3 -> R.drawable.ic_album_cover_collectbook
1 -> R.drawable.ic_album_cover_friends
2 -> R.drawable.ic_album_cover_love
3 -> R.drawable.ic_album_cover_myalbum
4 -> R.drawable.ic_album_cover_collectbook
else -> throw IllegalArgumentException("Invalid album cover id $this")
}
1 change: 0 additions & 1 deletion app/src/main/res/layout/item_store_pager.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginHorizontal="45dp"
android:src="@drawable/ic_album_cover_friends"
android:contentDescription="pager item image"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down

0 comments on commit a4eb59f

Please sign in to comment.