|
@@ -11,6 +11,7 @@ import com.swago.baseswago.agora.AgoraManager
|
|
|
import com.swago.baseswago.constant.ARouteConstant
|
|
|
import com.swago.baseswago.dialog.BaseXDFragment
|
|
|
import com.swago.baseswago.dialog.ChoiceDialogFragment
|
|
|
+import com.swago.baseswago.model.live.pk.PKLiverModel
|
|
|
import com.swago.baseswago.util.AppContext
|
|
|
import com.swago.room.R
|
|
|
import com.swago.room.database.DBHelper
|
|
@@ -19,9 +20,13 @@ import com.swago.room.databinding.DialogMyMusicBinding
|
|
|
class MyMusicDialog : BaseXDFragment<DialogMyMusicBinding>() {
|
|
|
val music_binding get() = binding
|
|
|
var isLocalCome = false
|
|
|
+ var openChooseMusicFun:((musicModel: MusicModel?)->Unit)? =null
|
|
|
+ var musicModel : MusicModel? = null
|
|
|
+
|
|
|
private val musicList by lazy {
|
|
|
ArrayList<MusicModel>()
|
|
|
}
|
|
|
+
|
|
|
private val adapter by lazy {
|
|
|
MyMusicAdapter()
|
|
|
}
|
|
@@ -29,10 +34,10 @@ class MyMusicDialog : BaseXDFragment<DialogMyMusicBinding>() {
|
|
|
get() = LinearLayoutManager(activity)
|
|
|
|
|
|
companion object {
|
|
|
- const val select_local_result = 10002
|
|
|
- fun newInstance(): MyMusicDialog {
|
|
|
+ fun newInstance(chooseMusic: MusicModel?): MyMusicDialog {
|
|
|
val args = Bundle()
|
|
|
val fragment = MyMusicDialog()
|
|
|
+ args.putParcelable("chooseMusic",chooseMusic)
|
|
|
fragment.arguments = args
|
|
|
return fragment
|
|
|
}
|
|
@@ -45,6 +50,10 @@ class MyMusicDialog : BaseXDFragment<DialogMyMusicBinding>() {
|
|
|
}
|
|
|
|
|
|
override fun initOther() {
|
|
|
+ arguments?.let {
|
|
|
+ musicModel = it.getParcelable("chooseMusic")
|
|
|
+
|
|
|
+ }
|
|
|
music_binding.rvMusic.layoutManager = layoutManager
|
|
|
music_binding.rvMusic.adapter = adapter
|
|
|
music_binding.ivClose.setOnClickListener {
|
|
@@ -57,6 +66,13 @@ class MyMusicDialog : BaseXDFragment<DialogMyMusicBinding>() {
|
|
|
if (!data.isNullOrEmpty()){
|
|
|
music_binding.clAdd.visibility = View.VISIBLE
|
|
|
music_binding.clNoContent.visibility = View.GONE
|
|
|
+ data.forEachIndexed { index, item ->
|
|
|
+ if (musicModel != null && item.id == musicModel?.id){
|
|
|
+ data[index].setIsPlaying(true)
|
|
|
+ return@forEachIndexed
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
musicList.addAll(data)
|
|
|
adapter.setNewData(musicList)
|
|
|
} else {
|
|
@@ -85,6 +101,7 @@ class MyMusicDialog : BaseXDFragment<DialogMyMusicBinding>() {
|
|
|
DBHelper.getMusicModel()?.delete(adapter.data[position])
|
|
|
musicList.remove(adapter.data[position])
|
|
|
adapter.setNewData(musicList)
|
|
|
+ AgoraManager.getRtcEngine()?.stopAudioMixing()
|
|
|
if (adapter.data.isEmpty()){
|
|
|
music_binding.clAdd.visibility = View.GONE
|
|
|
music_binding.clNoContent.visibility = View.VISIBLE
|
|
@@ -101,6 +118,7 @@ class MyMusicDialog : BaseXDFragment<DialogMyMusicBinding>() {
|
|
|
adapter.data[position].setIsPlaying(false)
|
|
|
adapter.notifyItemChanged(position)
|
|
|
AgoraManager.getRtcEngine()?.stopAudioMixing()
|
|
|
+ openChooseMusicFun?.invoke(null)
|
|
|
return@setOnItemClickListener
|
|
|
}
|
|
|
adapter.data.forEachIndexed { index, musicModel ->
|
|
@@ -110,6 +128,7 @@ class MyMusicDialog : BaseXDFragment<DialogMyMusicBinding>() {
|
|
|
return@forEachIndexed
|
|
|
}
|
|
|
}
|
|
|
+ openChooseMusicFun?.invoke(adapter.data[position])
|
|
|
adapter.data[position].setIsPlaying(true)
|
|
|
AgoraManager.getRtcEngine()?.startAudioMixing(
|
|
|
adapter.data[position].data,
|
|
@@ -131,6 +150,13 @@ class MyMusicDialog : BaseXDFragment<DialogMyMusicBinding>() {
|
|
|
binding.clAdd.visibility = View.VISIBLE
|
|
|
binding.clNoContent.visibility = View.GONE
|
|
|
musicList.clear()
|
|
|
+ data.forEachIndexed { index, item ->
|
|
|
+ if (musicModel != null && item.id == musicModel?.id){
|
|
|
+ data[index].setIsPlaying(true)
|
|
|
+ return@forEachIndexed
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
musicList.addAll(data)
|
|
|
adapter.setNewData(musicList)
|
|
|
} else {
|