parent
40335fb7ff
commit
848f0b44f6
|
@ -55,4 +55,11 @@ class AudioContentPlaylistListAdapter(
|
|||
}
|
||||
|
||||
override fun getItemCount() = items.count()
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
fun updateItems(items: List<GetPlaylistsItem>) {
|
||||
this.items.clear()
|
||||
this.items.addAll(items)
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,15 +2,20 @@ package kr.co.vividnext.sodalive.audio_content.playlist
|
|||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.graphics.Rect
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.appcompat.app.AppCompatActivity.RESULT_OK
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kr.co.vividnext.sodalive.audio_content.playlist.create.AudioContentPlaylistCreateActivity
|
||||
import kr.co.vividnext.sodalive.audio_content.playlist.detail.AudioContentPlaylistDetailActivity
|
||||
import kr.co.vividnext.sodalive.base.BaseFragment
|
||||
import kr.co.vividnext.sodalive.common.Constants
|
||||
import kr.co.vividnext.sodalive.common.LoadingDialog
|
||||
import kr.co.vividnext.sodalive.databinding.FragmentAudioContentPlaylistListBinding
|
||||
import kr.co.vividnext.sodalive.extensions.dpToPx
|
||||
import org.koin.android.ext.android.inject
|
||||
|
||||
class AudioContentPlaylistListFragment : BaseFragment<FragmentAudioContentPlaylistListBinding>(
|
||||
|
@ -22,12 +27,19 @@ class AudioContentPlaylistListFragment : BaseFragment<FragmentAudioContentPlayli
|
|||
private lateinit var loadingDialog: LoadingDialog
|
||||
private lateinit var adapter: AudioContentPlaylistListAdapter
|
||||
|
||||
private val createPlaylistResult = registerForActivityResult(
|
||||
ActivityResultContracts.StartActivityForResult()
|
||||
) { result ->
|
||||
if (result.resultCode == RESULT_OK) {
|
||||
viewModel.getPlaylistList()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
setupView()
|
||||
bindData()
|
||||
|
||||
viewModel.getPlaylistList()
|
||||
}
|
||||
|
||||
|
@ -51,10 +63,47 @@ class AudioContentPlaylistListFragment : BaseFragment<FragmentAudioContentPlayli
|
|||
LinearLayoutManager.VERTICAL,
|
||||
false
|
||||
)
|
||||
|
||||
recyclerView.addItemDecoration(object : RecyclerView.ItemDecoration() {
|
||||
override fun getItemOffsets(
|
||||
outRect: Rect,
|
||||
view: View,
|
||||
parent: RecyclerView,
|
||||
state: RecyclerView.State
|
||||
) {
|
||||
super.getItemOffsets(outRect, view, parent, state)
|
||||
|
||||
outRect.left = 0
|
||||
outRect.right = 0
|
||||
|
||||
when (parent.getChildAdapterPosition(view)) {
|
||||
0 -> {
|
||||
outRect.top = 0
|
||||
outRect.bottom = 5f.dpToPx().toInt()
|
||||
}
|
||||
|
||||
adapter.itemCount - 1 -> {
|
||||
outRect.top = 5f.dpToPx().toInt()
|
||||
outRect.bottom = 0
|
||||
}
|
||||
|
||||
else -> {
|
||||
outRect.top = 5f.dpToPx().toInt()
|
||||
outRect.bottom = 5f.dpToPx().toInt()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
recyclerView.adapter = adapter
|
||||
|
||||
binding.tvCreatePlaylist.setOnClickListener {
|
||||
startActivity(Intent(requireContext(), AudioContentPlaylistCreateActivity::class.java))
|
||||
createPlaylistResult.launch(
|
||||
Intent(
|
||||
requireContext(),
|
||||
AudioContentPlaylistCreateActivity::class.java
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,7 +135,7 @@ class AudioContentPlaylistListFragment : BaseFragment<FragmentAudioContentPlayli
|
|||
binding.tvTotalCount.visibility = View.VISIBLE
|
||||
binding.rvPlaylistList.visibility = View.VISIBLE
|
||||
|
||||
adapter.items.addAll(it)
|
||||
adapter.updateItems(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package kr.co.vividnext.sodalive.audio_content.playlist
|
||||
|
||||
import kr.co.vividnext.sodalive.audio_content.playlist.create.CreatePlaylistRequest
|
||||
|
||||
class AudioContentPlaylistRepository(private val api: PlaylistApi) {
|
||||
fun getPlaylistList(token: String) = api.getPlaylistList(authHeader = token)
|
||||
|
||||
fun getPlaylistDetail(
|
||||
playlistId: Long,
|
||||
token: String
|
||||
|
@ -9,4 +12,9 @@ class AudioContentPlaylistRepository(private val api: PlaylistApi) {
|
|||
id = playlistId,
|
||||
authHeader = token
|
||||
)
|
||||
|
||||
fun createPlaylist(
|
||||
request: CreatePlaylistRequest,
|
||||
token: String
|
||||
) = api.createPlaylist(request, token)
|
||||
}
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package kr.co.vividnext.sodalive.audio_content.playlist
|
||||
|
||||
import io.reactivex.rxjava3.core.Single
|
||||
import kr.co.vividnext.sodalive.audio_content.playlist.create.CreatePlaylistRequest
|
||||
import kr.co.vividnext.sodalive.audio_content.playlist.detail.GetPlaylistDetailResponse
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import retrofit2.http.Body
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Header
|
||||
import retrofit2.http.POST
|
||||
import retrofit2.http.Path
|
||||
|
||||
interface PlaylistApi {
|
||||
|
@ -18,4 +21,10 @@ interface PlaylistApi {
|
|||
@Path("id") id: Long,
|
||||
@Header("Authorization") authHeader: String
|
||||
): Single<ApiResponse<GetPlaylistDetailResponse>>
|
||||
|
||||
@POST("/audio-content/playlist")
|
||||
fun createPlaylist(
|
||||
@Body request: CreatePlaylistRequest,
|
||||
@Header("Authorization") authHeader: String
|
||||
): Single<ApiResponse<Any>>
|
||||
}
|
||||
|
|
|
@ -1,22 +1,51 @@
|
|||
package kr.co.vividnext.sodalive.audio_content.playlist.create
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Service
|
||||
import android.graphics.Rect
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.jakewharton.rxbinding4.widget.textChanges
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import kr.co.vividnext.sodalive.audio_content.playlist.create.add_content.PlaylistAddContentDialogFragment
|
||||
import kr.co.vividnext.sodalive.base.BaseActivity
|
||||
import kr.co.vividnext.sodalive.common.LoadingDialog
|
||||
import kr.co.vividnext.sodalive.databinding.ActivityAudioContentPlaylistCreateBinding
|
||||
import kr.co.vividnext.sodalive.extensions.dpToPx
|
||||
import org.koin.android.ext.android.inject
|
||||
|
||||
class AudioContentPlaylistCreateActivity : BaseActivity<ActivityAudioContentPlaylistCreateBinding>(
|
||||
ActivityAudioContentPlaylistCreateBinding::inflate
|
||||
) {
|
||||
|
||||
private val viewModel: AudioContentPlaylistCreateViewModel by inject()
|
||||
|
||||
private lateinit var imm: InputMethodManager
|
||||
private lateinit var loadingDialog: LoadingDialog
|
||||
private lateinit var adapter: AudioContentPlaylistCreateContentAdapter
|
||||
|
||||
private val addContentDialogFragment: PlaylistAddContentDialogFragment by lazy {
|
||||
PlaylistAddContentDialogFragment()
|
||||
PlaylistAddContentDialogFragment(viewModel.contentList) { item, isChecked ->
|
||||
when {
|
||||
isChecked -> {
|
||||
viewModel.addContentId(item)
|
||||
return@PlaylistAddContentDialogFragment true
|
||||
}
|
||||
|
||||
!isChecked -> {
|
||||
viewModel.removeContentId(item)
|
||||
return@PlaylistAddContentDialogFragment true
|
||||
}
|
||||
|
||||
else -> {
|
||||
return@PlaylistAddContentDialogFragment false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
@ -25,6 +54,8 @@ class AudioContentPlaylistCreateActivity : BaseActivity<ActivityAudioContentPlay
|
|||
imm = getSystemService(
|
||||
Service.INPUT_METHOD_SERVICE
|
||||
) as InputMethodManager
|
||||
|
||||
bindData()
|
||||
}
|
||||
|
||||
override fun setupView() {
|
||||
|
@ -37,5 +68,119 @@ class AudioContentPlaylistCreateActivity : BaseActivity<ActivityAudioContentPlay
|
|||
if (addContentDialogFragment.isAdded) return@setOnClickListener
|
||||
addContentDialogFragment.show(supportFragmentManager, addContentDialogFragment.tag)
|
||||
}
|
||||
|
||||
binding.tvSave.setOnClickListener {
|
||||
viewModel.savePlaylist {
|
||||
setResult(RESULT_OK)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
adapter = AudioContentPlaylistCreateContentAdapter()
|
||||
|
||||
val recyclerView = binding.rvPlaylistContent
|
||||
recyclerView.layoutManager = LinearLayoutManager(
|
||||
this,
|
||||
LinearLayoutManager.VERTICAL,
|
||||
false
|
||||
)
|
||||
recyclerView.addItemDecoration(object : RecyclerView.ItemDecoration() {
|
||||
override fun getItemOffsets(
|
||||
outRect: Rect,
|
||||
view: View,
|
||||
parent: RecyclerView,
|
||||
state: RecyclerView.State
|
||||
) {
|
||||
super.getItemOffsets(outRect, view, parent, state)
|
||||
|
||||
outRect.left = 13.3f.dpToPx().toInt()
|
||||
outRect.right = 13.3f.dpToPx().toInt()
|
||||
|
||||
when (parent.getChildAdapterPosition(view)) {
|
||||
0 -> {
|
||||
outRect.top = 13.3f.dpToPx().toInt()
|
||||
outRect.bottom = 6.7f.dpToPx().toInt()
|
||||
}
|
||||
|
||||
adapter.itemCount - 1 -> {
|
||||
outRect.top = 6.7f.dpToPx().toInt()
|
||||
outRect.bottom = 13.3f.dpToPx().toInt()
|
||||
}
|
||||
|
||||
else -> {
|
||||
outRect.top = 6.7f.dpToPx().toInt()
|
||||
outRect.bottom = 6.7f.dpToPx().toInt()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
recyclerView.adapter = adapter
|
||||
}
|
||||
|
||||
private fun bindData() {
|
||||
viewModel.toastLiveData.observe(this) {
|
||||
it?.let { showToast(it) }
|
||||
}
|
||||
|
||||
viewModel.isLoading.observe(this) {
|
||||
if (it) {
|
||||
loadingDialog.show(screenWidth, "")
|
||||
} else {
|
||||
loadingDialog.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.contentListLiveData.observe(this) {
|
||||
adapter.updateItems(it)
|
||||
}
|
||||
|
||||
compositeDisposable.add(
|
||||
binding.etTitle.textChanges()
|
||||
.map { it.toString() }
|
||||
.distinctUntilChanged()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
if (it.length > 30) {
|
||||
val truncated = it.take(30)
|
||||
binding.etTitle.setText(truncated)
|
||||
binding.etTitle.setSelection(truncated.length)
|
||||
setTitle(truncated)
|
||||
} else {
|
||||
setTitle(it)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
compositeDisposable.add(
|
||||
binding.etDesc.textChanges()
|
||||
.map { it.toString() }
|
||||
.distinctUntilChanged()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
if (it.length > 40) {
|
||||
val truncated = it.take(40)
|
||||
binding.etDesc.setText(truncated)
|
||||
binding.etDesc.setSelection(truncated.length)
|
||||
setDesc(truncated)
|
||||
} else {
|
||||
setDesc(it)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun setTitle(title: String) {
|
||||
binding.tvTitleLength.text = "${title.length}/30"
|
||||
viewModel.title = title
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun setDesc(desc: String) {
|
||||
binding.tvDescLength.text = "${desc.length}/40"
|
||||
viewModel.desc = desc
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
package kr.co.vividnext.sodalive.audio_content.playlist.create
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import coil.load
|
||||
import coil.transform.RoundedCornersTransformation
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.audio_content.order.GetAudioContentOrderListItem
|
||||
import kr.co.vividnext.sodalive.databinding.ItemPlaylistCreateContentBinding
|
||||
import kr.co.vividnext.sodalive.extensions.dpToPx
|
||||
|
||||
class AudioContentPlaylistCreateContentAdapter :
|
||||
RecyclerView.Adapter<AudioContentPlaylistCreateContentAdapter.ViewHolder>() {
|
||||
private val items = mutableListOf<GetAudioContentOrderListItem>()
|
||||
|
||||
inner class ViewHolder(
|
||||
private val binding: ItemPlaylistCreateContentBinding
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
fun bind(item: GetAudioContentOrderListItem) {
|
||||
binding.ivCover.load(item.coverImageUrl) {
|
||||
crossfade(true)
|
||||
placeholder(R.drawable.bg_placeholder)
|
||||
transformations(RoundedCornersTransformation(5.3f.dpToPx()))
|
||||
}
|
||||
|
||||
binding.tvTitle.text = item.title
|
||||
binding.tvTheme.text = item.themeStr
|
||||
binding.tvDuration.text = item.duration
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = ViewHolder(
|
||||
ItemPlaylistCreateContentBinding.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
parent,
|
||||
false
|
||||
)
|
||||
)
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
holder.bind(items[position])
|
||||
}
|
||||
|
||||
override fun getItemCount() = items.size
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
fun updateItems(items: List<GetAudioContentOrderListItem>) {
|
||||
this.items.clear()
|
||||
this.items.addAll(items)
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package kr.co.vividnext.sodalive.audio_content.playlist.create
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import kr.co.vividnext.sodalive.audio_content.order.GetAudioContentOrderListItem
|
||||
import kr.co.vividnext.sodalive.audio_content.playlist.AudioContentPlaylistRepository
|
||||
import kr.co.vividnext.sodalive.base.BaseViewModel
|
||||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
|
||||
class AudioContentPlaylistCreateViewModel(
|
||||
private val repository: AudioContentPlaylistRepository
|
||||
) : BaseViewModel() {
|
||||
private val _toastLiveData = MutableLiveData<String?>()
|
||||
val toastLiveData: LiveData<String?>
|
||||
get() = _toastLiveData
|
||||
|
||||
private val _contentListLiveData = MutableLiveData<List<GetAudioContentOrderListItem>>()
|
||||
val contentListLiveData: LiveData<List<GetAudioContentOrderListItem>>
|
||||
get() = _contentListLiveData
|
||||
|
||||
private var _isLoading = MutableLiveData(false)
|
||||
val isLoading: LiveData<Boolean>
|
||||
get() = _isLoading
|
||||
|
||||
val contentList = mutableListOf<GetAudioContentOrderListItem>()
|
||||
|
||||
var title: String = ""
|
||||
var desc: String = ""
|
||||
|
||||
fun addContentId(item: GetAudioContentOrderListItem) {
|
||||
contentList.add(item)
|
||||
_contentListLiveData.value = contentList
|
||||
}
|
||||
|
||||
fun removeContentId(item: GetAudioContentOrderListItem) {
|
||||
contentList.remove(item)
|
||||
_contentListLiveData.value = contentList
|
||||
}
|
||||
|
||||
fun savePlaylist(onSuccess: () -> Unit) {
|
||||
if (validate()) {
|
||||
_isLoading.value = true
|
||||
val contentIdAndOrderList = contentList.mapIndexed { index, item ->
|
||||
PlaylistContentIdAndOrder(item.contentId, index + 1)
|
||||
}
|
||||
|
||||
compositeDisposable.add(
|
||||
repository.createPlaylist(
|
||||
request = CreatePlaylistRequest(
|
||||
title = title,
|
||||
desc = desc,
|
||||
contentIdAndOrderList = contentIdAndOrderList
|
||||
),
|
||||
token = "Bearer ${SharedPreferenceManager.token}"
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
{
|
||||
_isLoading.value = false
|
||||
if (it.success) {
|
||||
onSuccess()
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
_toastLiveData.value = it.message
|
||||
} else {
|
||||
_toastLiveData.value = "알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
_isLoading.value = false
|
||||
if (it.message != null) {
|
||||
_toastLiveData.value = it.message
|
||||
} else {
|
||||
_toastLiveData.value = "알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun validate(): Boolean {
|
||||
if (title.isBlank() || title.length < 3) {
|
||||
_toastLiveData.value = "제목을 3자 이상 입력하세요"
|
||||
return false
|
||||
}
|
||||
|
||||
if (contentList.isEmpty()) {
|
||||
_toastLiveData.value = "콘텐츠를 1개 이상 추가하세요"
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package kr.co.vividnext.sodalive.audio_content.playlist.create
|
||||
|
||||
import androidx.annotation.Keep
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
@Keep
|
||||
data class CreatePlaylistRequest(
|
||||
@SerializedName("title") val title: String,
|
||||
@SerializedName("desc") val desc: String? = null,
|
||||
@SerializedName("contentIdAndOrderList")
|
||||
val contentIdAndOrderList: List<PlaylistContentIdAndOrder>
|
||||
)
|
|
@ -0,0 +1,10 @@
|
|||
package kr.co.vividnext.sodalive.audio_content.playlist.create
|
||||
|
||||
import androidx.annotation.Keep
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
@Keep
|
||||
data class PlaylistContentIdAndOrder(
|
||||
@SerializedName("contentId") val contentId: Long,
|
||||
@SerializedName("order") val order: Int
|
||||
)
|
|
@ -9,11 +9,15 @@ import com.bumptech.glide.Glide
|
|||
import com.bumptech.glide.load.resource.bitmap.CenterCrop
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.audio_content.order.GetAudioContentOrderListItem
|
||||
import kr.co.vividnext.sodalive.databinding.ItemPlaylistAddContentBinding
|
||||
import kr.co.vividnext.sodalive.extensions.dpToPx
|
||||
|
||||
class PlaylistAddContentAdapter : RecyclerView.Adapter<PlaylistAddContentAdapter.ViewHolder>() {
|
||||
class PlaylistAddContentAdapter(
|
||||
private val selectedContentIdList: Set<Long>,
|
||||
private val onItemClick: (GetAudioContentOrderListItem, Boolean) -> Boolean
|
||||
) : RecyclerView.Adapter<PlaylistAddContentAdapter.ViewHolder>() {
|
||||
|
||||
var items = mutableListOf<GetAudioContentOrderListItem>()
|
||||
|
||||
|
@ -21,7 +25,18 @@ class PlaylistAddContentAdapter : RecyclerView.Adapter<PlaylistAddContentAdapter
|
|||
private val context: Context,
|
||||
private val binding: ItemPlaylistAddContentBinding
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
|
||||
private var isChecked = false
|
||||
|
||||
fun bind(item: GetAudioContentOrderListItem) {
|
||||
if (selectedContentIdList.contains(item.contentId)) {
|
||||
binding.ivAdd.setImageResource(R.drawable.ic_check_blue)
|
||||
isChecked = true
|
||||
} else {
|
||||
binding.ivAdd.setImageResource(R.drawable.ic_playlist_add)
|
||||
isChecked = false
|
||||
}
|
||||
|
||||
Glide
|
||||
.with(context)
|
||||
.load(item.coverImageUrl)
|
||||
|
@ -36,6 +51,22 @@ class PlaylistAddContentAdapter : RecyclerView.Adapter<PlaylistAddContentAdapter
|
|||
binding.tvTitle.text = item.title
|
||||
binding.tvTheme.text = item.themeStr
|
||||
binding.tvDuration.text = item.duration
|
||||
|
||||
binding.ivAdd.setOnClickListener {
|
||||
isChecked = !isChecked
|
||||
|
||||
if (onItemClick(item, isChecked)) {
|
||||
binding.ivAdd.setImageResource(
|
||||
if (isChecked) {
|
||||
R.drawable.ic_check_blue
|
||||
} else {
|
||||
R.drawable.ic_playlist_add
|
||||
}
|
||||
)
|
||||
} else {
|
||||
isChecked = !isChecked
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package kr.co.vividnext.sodalive.audio_content.playlist.create.add_content
|
|||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Dialog
|
||||
import android.content.DialogInterface
|
||||
import android.graphics.Rect
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
|
@ -15,13 +16,17 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior
|
|||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import kr.co.vividnext.sodalive.audio_content.order.AudioContentOrderListViewModel
|
||||
import kr.co.vividnext.sodalive.audio_content.order.GetAudioContentOrderListItem
|
||||
import kr.co.vividnext.sodalive.audio_content.playlist.create.AudioContentPlaylistCreateActivity
|
||||
import kr.co.vividnext.sodalive.common.LoadingDialog
|
||||
import kr.co.vividnext.sodalive.databinding.FragmentPlaylistAddContentBinding
|
||||
import kr.co.vividnext.sodalive.extensions.dpToPx
|
||||
import org.koin.android.ext.android.inject
|
||||
|
||||
class PlaylistAddContentDialogFragment : BottomSheetDialogFragment() {
|
||||
class PlaylistAddContentDialogFragment(
|
||||
private val selectedContentIdList: List<GetAudioContentOrderListItem>,
|
||||
private val onItemClick: (GetAudioContentOrderListItem, Boolean) -> Boolean
|
||||
) : BottomSheetDialogFragment() {
|
||||
|
||||
private lateinit var binding: FragmentPlaylistAddContentBinding
|
||||
private lateinit var adapter: PlaylistAddContentAdapter
|
||||
|
@ -70,11 +75,19 @@ class PlaylistAddContentDialogFragment : BottomSheetDialogFragment() {
|
|||
viewModel.getAudioContentOrderList { dismiss() }
|
||||
}
|
||||
|
||||
override fun onDismiss(dialog: DialogInterface) {
|
||||
viewModel.page = 1
|
||||
super.onDismiss(dialog)
|
||||
}
|
||||
|
||||
private fun setupView() {
|
||||
binding.tvClose.setOnClickListener { dismiss() }
|
||||
|
||||
loadingDialog = LoadingDialog(requireActivity(), layoutInflater)
|
||||
adapter = PlaylistAddContentAdapter()
|
||||
adapter = PlaylistAddContentAdapter(
|
||||
selectedContentIdList.map { it.contentId }.toSet(),
|
||||
onItemClick
|
||||
)
|
||||
|
||||
val recyclerView = binding.rvContent
|
||||
recyclerView.layoutManager = LinearLayoutManager(
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package kr.co.vividnext.sodalive.audio_content.playlist.detail
|
||||
|
||||
import androidx.annotation.Keep
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
@Keep
|
||||
data class GetPlaylistDetailResponse(
|
||||
@SerializedName("playlistId") val playlistId: Long,
|
||||
@SerializedName("title") val title: String,
|
||||
|
@ -12,6 +14,7 @@ data class GetPlaylistDetailResponse(
|
|||
@SerializedName("contentList") val contentList: List<AudioContentPlaylistContent>
|
||||
)
|
||||
|
||||
@Keep
|
||||
data class AudioContentPlaylistContent(
|
||||
@SerializedName("id") val id: Long,
|
||||
@SerializedName("title") val title: String,
|
||||
|
|
|
@ -27,6 +27,7 @@ import kr.co.vividnext.sodalive.audio_content.order.AudioContentOrderListViewMod
|
|||
import kr.co.vividnext.sodalive.audio_content.playlist.AudioContentPlaylistRepository
|
||||
import kr.co.vividnext.sodalive.audio_content.playlist.AudioContentPlaylistListViewModel
|
||||
import kr.co.vividnext.sodalive.audio_content.playlist.PlaylistApi
|
||||
import kr.co.vividnext.sodalive.audio_content.playlist.create.AudioContentPlaylistCreateViewModel
|
||||
import kr.co.vividnext.sodalive.audio_content.playlist.detail.AudioContentPlaylistDetailViewModel
|
||||
import kr.co.vividnext.sodalive.audio_content.series.SeriesApi
|
||||
import kr.co.vividnext.sodalive.audio_content.series.SeriesListAllViewModel
|
||||
|
@ -272,6 +273,7 @@ class AppDI(private val context: Context, isDebugMode: Boolean) {
|
|||
viewModel { MenuConfigViewModel(get()) }
|
||||
viewModel { AudioContentPlaylistListViewModel(get()) }
|
||||
viewModel { AudioContentPlaylistDetailViewModel(get()) }
|
||||
viewModel { AudioContentPlaylistCreateViewModel(get()) }
|
||||
}
|
||||
|
||||
private val repositoryModule = module {
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
android:minHeight="48dp"
|
||||
android:paddingHorizontal="13.3dp"
|
||||
android:text="저장"
|
||||
android:textColor="@color/color_555555"
|
||||
android:textColor="@color/color_eeeeee"
|
||||
android:textSize="14.7sp" />
|
||||
</RelativeLayout>
|
||||
|
||||
|
@ -81,6 +81,9 @@
|
|||
android:layout_marginTop="13.3dp"
|
||||
android:background="@drawable/bg_round_corner_6_7_222222"
|
||||
android:fontFamily="@font/gmarket_sans_bold"
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="textWebEditText"
|
||||
android:maxLines="1"
|
||||
android:paddingHorizontal="13.3dp"
|
||||
android:paddingVertical="17dp"
|
||||
android:textColor="@color/color_eeeeee"
|
||||
|
@ -122,6 +125,9 @@
|
|||
android:layout_marginTop="13.3dp"
|
||||
android:background="@drawable/bg_round_corner_6_7_222222"
|
||||
android:fontFamily="@font/gmarket_sans_bold"
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="textWebEditText"
|
||||
android:maxLines="1"
|
||||
android:minHeight="80dp"
|
||||
android:paddingHorizontal="13.3dp"
|
||||
android:paddingVertical="17dp"
|
||||
|
|
|
@ -1,69 +1,73 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/black">
|
||||
android:background="@color/black"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="17dp"
|
||||
android:fontFamily="@font/gmarket_sans_bold"
|
||||
android:text="새로운 콘텐츠 추가"
|
||||
android:textColor="@color/color_eeeeee"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="52dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_close"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="13dp"
|
||||
android:fontFamily="@font/gmarket_sans_medium"
|
||||
android:text="닫기"
|
||||
android:textColor="@color/color_eeeeee"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/tv_title"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/tv_title" />
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:fontFamily="@font/gmarket_sans_bold"
|
||||
android:text="새로운 콘텐츠 추가"
|
||||
android:textColor="@color/color_eeeeee"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_all"
|
||||
android:layout_width="wrap_content"
|
||||
<TextView
|
||||
android:id="@+id/tv_close"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="13dp"
|
||||
android:fontFamily="@font/gmarket_sans_medium"
|
||||
android:text="닫기"
|
||||
android:textColor="@color/color_eeeeee" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="13.3dp"
|
||||
android:layout_marginTop="13.3dp"
|
||||
android:fontFamily="@font/gmarket_sans_medium"
|
||||
android:text="전체"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="14.7sp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_title" />
|
||||
android:paddingHorizontal="13.3dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_content_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5.3dp"
|
||||
android:fontFamily="@font/gmarket_sans_medium"
|
||||
android:textColor="@color/color_909090"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/tv_all"
|
||||
app:layout_constraintStart_toEndOf="@+id/tv_all"
|
||||
app:layout_constraintTop_toTopOf="@+id/tv_all"
|
||||
tools:text="40개" />
|
||||
<TextView
|
||||
android:id="@+id/tv_all"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:fontFamily="@font/gmarket_sans_medium"
|
||||
android:text="전체"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="14.7sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_content_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="5.3dp"
|
||||
android:layout_toEndOf="@+id/tv_all"
|
||||
android:fontFamily="@font/gmarket_sans_medium"
|
||||
android:textColor="@color/color_909090"
|
||||
android:textSize="12sp"
|
||||
tools:text="40개" />
|
||||
</RelativeLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:clipToPadding="false"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_all" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false" />
|
||||
</LinearLayout>
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_cover"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:contentDescription="@null"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_theme"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="13.3dp"
|
||||
android:background="@drawable/bg_round_corner_2_6_28312b"
|
||||
android:fontFamily="@font/gmarket_sans_medium"
|
||||
android:gravity="center"
|
||||
android:padding="2.6dp"
|
||||
android:textColor="@color/color_3bac6a"
|
||||
android:textSize="8sp"
|
||||
app:layout_constraintStart_toEndOf="@+id/iv_cover"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="SmallSp"
|
||||
tools:text="커버곡" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_duration"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:background="@drawable/bg_round_corner_2_6_222222"
|
||||
android:fontFamily="@font/gmarket_sans_medium"
|
||||
android:gravity="center"
|
||||
android:padding="2.6dp"
|
||||
android:textColor="@color/color_777777"
|
||||
android:textSize="8sp"
|
||||
app:layout_constraintStart_toEndOf="@+id/tv_theme"
|
||||
app:layout_constraintTop_toTopOf="@+id/tv_theme"
|
||||
tools:ignore="SmallSp"
|
||||
tools:text="00:30:20" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="6.7dp"
|
||||
android:layout_marginEnd="13.3dp"
|
||||
android:ellipsize="end"
|
||||
android:fontFamily="@font/gmarket_sans_medium"
|
||||
android:maxLines="3"
|
||||
android:textColor="@color/color_d2d2d2"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@+id/tv_theme"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_theme"
|
||||
tools:text="안녕하세요 오늘은 커버곡을 들려드리려고 해요안녕하세요 오늘은 커버곡을 들려드리려고 해요안녕하세요 오늘은 커버곡을 들려드리려고 해요안녕하세요 오늘은 커버곡을 들려드리려고 해요" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -10,6 +10,7 @@
|
|||
android:layout_width="66.7dp"
|
||||
android:layout_height="66.7dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginTop="8dp"
|
||||
android:contentDescription="@null" />
|
||||
|
||||
<LinearLayout
|
||||
|
@ -17,6 +18,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="11dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_toEndOf="@+id/iv_cover"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical">
|
||||
|
|
Loading…
Reference in New Issue