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