Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature/store_album_cover] 앨범커버 이미지 리소스 변경 로직 #99

Merged
merged 5 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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