parent
4012b44344
commit
6fbe7da71e
|
@ -27,7 +27,7 @@ class AudioContentPlaylistListFragment : BaseFragment<FragmentAudioContentPlayli
|
|||
private lateinit var loadingDialog: LoadingDialog
|
||||
private lateinit var adapter: AudioContentPlaylistListAdapter
|
||||
|
||||
private val createPlaylistResult = registerForActivityResult(
|
||||
private val createOrUpdatePlaylistResult = registerForActivityResult(
|
||||
ActivityResultContracts.StartActivityForResult()
|
||||
) { result ->
|
||||
if (result.resultCode == RESULT_OK) {
|
||||
|
@ -46,7 +46,7 @@ class AudioContentPlaylistListFragment : BaseFragment<FragmentAudioContentPlayli
|
|||
private fun setupView() {
|
||||
loadingDialog = LoadingDialog(requireActivity(), layoutInflater)
|
||||
adapter = AudioContentPlaylistListAdapter { playlistId ->
|
||||
startActivity(
|
||||
createOrUpdatePlaylistResult.launch(
|
||||
Intent(requireContext(), AudioContentPlaylistDetailActivity::class.java).apply {
|
||||
putExtra(
|
||||
Constants.EXTRA_AUDIO_CONTENT_PLAYLIST_ID,
|
||||
|
@ -98,7 +98,7 @@ class AudioContentPlaylistListFragment : BaseFragment<FragmentAudioContentPlayli
|
|||
recyclerView.adapter = adapter
|
||||
|
||||
binding.tvCreatePlaylist.setOnClickListener {
|
||||
createPlaylistResult.launch(
|
||||
createOrUpdatePlaylistResult.launch(
|
||||
Intent(
|
||||
requireContext(),
|
||||
AudioContentPlaylistCreateActivity::class.java
|
||||
|
|
|
@ -17,4 +17,12 @@ class AudioContentPlaylistRepository(private val api: PlaylistApi) {
|
|||
request: CreatePlaylistRequest,
|
||||
token: String
|
||||
) = api.createPlaylist(request, token)
|
||||
|
||||
fun deletePlaylist(
|
||||
playlistId: Long,
|
||||
token: String
|
||||
) = api.deletePlaylist(
|
||||
id = playlistId,
|
||||
authHeader = token
|
||||
)
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import kr.co.vividnext.sodalive.audio_content.playlist.create.CreatePlaylistRequ
|
|||
import kr.co.vividnext.sodalive.audio_content.playlist.detail.GetPlaylistDetailResponse
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import retrofit2.http.Body
|
||||
import retrofit2.http.DELETE
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Header
|
||||
import retrofit2.http.POST
|
||||
|
@ -27,4 +28,10 @@ interface PlaylistApi {
|
|||
@Body request: CreatePlaylistRequest,
|
||||
@Header("Authorization") authHeader: String
|
||||
): Single<ApiResponse<Any>>
|
||||
|
||||
@DELETE("/audio-content/playlist/{id}")
|
||||
fun deletePlaylist(
|
||||
@Path("id") id: Long,
|
||||
@Header("Authorization") authHeader: String
|
||||
): Single<ApiResponse<Any>>
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
|||
import androidx.recyclerview.widget.RecyclerView
|
||||
import coil.load
|
||||
import kr.co.vividnext.sodalive.base.BaseActivity
|
||||
import kr.co.vividnext.sodalive.base.SodaDialog
|
||||
import kr.co.vividnext.sodalive.common.Constants
|
||||
import kr.co.vividnext.sodalive.common.LoadingDialog
|
||||
import kr.co.vividnext.sodalive.databinding.ActivityAudioContentPlaylistDetailBinding
|
||||
|
@ -85,7 +86,30 @@ class AudioContentPlaylistDetailActivity : BaseActivity<ActivityAudioContentPlay
|
|||
|
||||
binding.llPlay.setOnClickListener { }
|
||||
binding.llShuffle.setOnClickListener { }
|
||||
binding.toolbar.tvBack.setOnClickListener { finish() }
|
||||
binding.tvBack.setOnClickListener { finish() }
|
||||
binding.ivEdit.setOnClickListener { }
|
||||
binding.ivMore.setOnClickListener {
|
||||
val notifyFragment = AudioContentPlaylistDetailNotifyFragment {
|
||||
SodaDialog(
|
||||
activity = this@AudioContentPlaylistDetailActivity,
|
||||
layoutInflater = layoutInflater,
|
||||
title = "재생 목록 삭제",
|
||||
desc = "'${binding.tvTitle.text}'을 삭제하시겠습니까?",
|
||||
confirmButtonTitle = "삭제",
|
||||
confirmButtonClick = {
|
||||
viewModel.deletePlaylist(playlistId = playlistId) {
|
||||
setResult(RESULT_OK)
|
||||
finish()
|
||||
}
|
||||
},
|
||||
cancelButtonTitle = "취소",
|
||||
cancelButtonClick = {}
|
||||
).show(screenWidth)
|
||||
}
|
||||
|
||||
if (notifyFragment.isAdded) return@setOnClickListener
|
||||
notifyFragment.show(supportFragmentManager, notifyFragment.tag)
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package kr.co.vividnext.sodalive.audio_content.playlist.detail
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import kr.co.vividnext.sodalive.R
|
||||
|
||||
class AudioContentPlaylistDetailNotifyFragment(
|
||||
private val onClickDelete: () -> Unit
|
||||
) : BottomSheetDialogFragment() {
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View = inflater.inflate(
|
||||
R.layout.fragment_audio_content_playlist_detail_notify,
|
||||
container,
|
||||
false
|
||||
)
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
view.findViewById<TextView>(R.id.tv_delete).setOnClickListener {
|
||||
onClickDelete()
|
||||
dialog?.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -56,4 +56,38 @@ class AudioContentPlaylistDetailViewModel(
|
|||
)
|
||||
)
|
||||
}
|
||||
|
||||
fun deletePlaylist(playlistId: Long, onSuccess: () -> Unit) {
|
||||
_isLoading.value = true
|
||||
compositeDisposable.add(
|
||||
repository.deletePlaylist(
|
||||
playlistId = playlistId,
|
||||
token = "Bearer ${SharedPreferenceManager.token}"
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
{
|
||||
if (it.success) {
|
||||
_toastLiveData.value = "삭제되었습니다."
|
||||
onSuccess()
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
_toastLiveData.postValue(it.message)
|
||||
} else {
|
||||
_toastLiveData.postValue(
|
||||
"알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||
)
|
||||
}
|
||||
}
|
||||
_isLoading.value = false
|
||||
},
|
||||
{
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
_toastLiveData.postValue("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 496 B |
Binary file not shown.
After Width: | Height: | Size: 360 B |
|
@ -7,9 +7,54 @@
|
|||
android:background="@color/black"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include
|
||||
android:id="@+id/toolbar"
|
||||
layout="@layout/detail_toolbar" />
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="51.7dp"
|
||||
android:background="@color/black"
|
||||
android:paddingHorizontal="13.3dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_back"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:drawablePadding="6.7dp"
|
||||
android:ellipsize="end"
|
||||
android:fontFamily="@font/gmarket_sans_bold"
|
||||
android:gravity="center"
|
||||
android:minHeight="48dp"
|
||||
android:textColor="@color/color_eeeeee"
|
||||
android:textSize="18.3sp"
|
||||
app:drawableStartCompat="@drawable/ic_back"
|
||||
tools:ignore="RelativeOverlap"
|
||||
tools:text="보이스온" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_edit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@null"
|
||||
android:padding="8dp"
|
||||
android:src="@drawable/ic_edit_white" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_more"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5.3dp"
|
||||
android:contentDescription="@null"
|
||||
android:padding="8dp"
|
||||
android:src="@drawable/ic_seemore_vertical_white" />
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -173,8 +218,8 @@
|
|||
android:textColor="@color/color_eeeeee"
|
||||
android:textSize="13.3sp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/tv_create_date"
|
||||
app:layout_constraintTop_toTopOf="@+id/tv_create_date"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/tv_create_date"
|
||||
tools:text=" 5개" />
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<?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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/bg_top_round_corner_10_222222"
|
||||
android:padding="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_delete"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/gmarket_sans_medium"
|
||||
android:text="삭제"
|
||||
android:textColor="@color/color_eeeeee"
|
||||
android:textSize="13.3sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue