Skip to content

Commit

Permalink
Feat: 홈 화면 swipe layout 구성 (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaemin-Yoo committed May 9, 2023
1 parent c874078 commit 9369d92
Show file tree
Hide file tree
Showing 7 changed files with 346 additions and 317 deletions.
15 changes: 13 additions & 2 deletions app/src/main/java/com/infinity/omos/adapters/BindingAdapters.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,19 @@ fun bindImageFromUrl(view: ImageView, imageUrl: String?) {
if (!imageUrl.isNullOrEmpty()) {
Glide.with(view.context)
.load(imageUrl)
.error(R.drawable.ic_record)
.fallback(R.drawable.ic_record)
.placeholder(R.color.gray_06)
.into(view)
}
}

@BindingAdapter("profileImageFromUrl")
fun bindProfileImageFromUrl(view: ImageView, imageUrl: String?) {
if (!imageUrl.isNullOrEmpty()) {
Glide.with(view.context)
.load(imageUrl)
.error(R.drawable.ic_profile)
.fallback(R.drawable.ic_profile)
.placeholder(R.drawable.ic_profile)
.into(view)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.infinity.omos.data.music.toPresentation
fun SumRecord.toPresentation(): SumRecordModel {
return SumRecordModel(
music = music.toPresentation(),
nickname = nickname,
nickname = "by. $nickname",
recordId = recordId,
recordImageUrl = recordImageUrl,
recordTitle = recordTitle,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.infinity.omos.ui.main.today

import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
Expand All @@ -11,6 +12,8 @@ import com.infinity.omos.BuildConfig
import com.infinity.omos.adapters.dj.RecommendedDjListAdapter
import com.infinity.omos.adapters.record.HorizontalRecordListAdapter
import com.infinity.omos.databinding.FragmentTodayBinding
import com.infinity.omos.ui.record.DetailRecordActivity
import com.infinity.omos.ui.write.SelectCategoryActivity
import com.infinity.omos.utils.repeatOnStarted
import dagger.hilt.android.AndroidEntryPoint
import java.util.*
Expand Down Expand Up @@ -49,7 +52,10 @@ class TodayFragment : Fragment() {
}

private fun initListener() {

binding.swipeRefresh.setOnRefreshListener {
viewModel.refresh()
binding.swipeRefresh.isRefreshing = false
}
}

private fun collectData() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ class TodayViewModel @Inject constructor(
val lovedMusicUiState = _lovedMusicUiState.asStateFlow()

init {
fetchTodayMusic()
fetchFamousRecords()
fetchRecommendedDjs()
fetchLovedMusic()
refresh()
}

private fun fetchTodayMusic() {
Expand Down Expand Up @@ -96,6 +93,13 @@ class TodayViewModel @Inject constructor(
}
}
}

fun refresh() {
fetchTodayMusic()
fetchFamousRecords()
fetchRecommendedDjs()
fetchLovedMusic()
}
}

sealed interface TodayMusicUiState {
Expand Down
623 changes: 315 additions & 308 deletions app/src/main/res/layout/fragment_today.xml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/src/main/res/layout/list_item_horizontal_record.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginBottom="4dp"
android:text="@{record.nickname}"
android:textColor="?attr/colorSecondary"
android:textSize="12sp"
app:layout_constraintBottom_toTopOf="@id/tv_record_title"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/list_item_recommended_dj.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
android:id="@+id/iv_profile"
android:layout_width="88dp"
android:layout_height="88dp"
app:imageFromUrl="@{profile.profileUrl}"
app:profileImageFromUrl="@{profile.profileUrl}"
tools:src="@color/gray_06" />

<TextView
Expand Down

0 comments on commit 9369d92

Please sign in to comment.