增加录音点击播放业务
This commit is contained in:
parent
9379e7a7bb
commit
ebfdd778b9
@ -10,23 +10,20 @@ import android.view.ViewGroup
|
|||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.databinding.DataBindingUtil
|
import androidx.databinding.DataBindingUtil
|
||||||
import androidx.navigation.NavOptions
|
import androidx.navigation.NavOptions
|
||||||
import androidx.navigation.findNavController
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.navinfo.omqs.Constant
|
import com.navinfo.omqs.Constant
|
||||||
import com.navinfo.omqs.R
|
import com.navinfo.omqs.R
|
||||||
import com.navinfo.omqs.databinding.FragmentEvaluationResultBinding
|
import com.navinfo.omqs.databinding.FragmentEvaluationResultBinding
|
||||||
import com.navinfo.omqs.ui.fragment.BaseFragment
|
import com.navinfo.omqs.ui.fragment.BaseFragment
|
||||||
import com.navinfo.omqs.ui.fragment.tasklist.TaskListAdapter
|
|
||||||
import com.navinfo.omqs.ui.other.shareViewModels
|
import com.navinfo.omqs.ui.other.shareViewModels
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import androidx.navigation.findNavController
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
|
class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
|
||||||
private lateinit var binding: FragmentEvaluationResultBinding
|
private lateinit var binding: FragmentEvaluationResultBinding
|
||||||
private val viewModel by shareViewModels<EvaluationResultViewModel>("QsRecode")
|
private val viewModel by shareViewModels<EvaluationResultViewModel>("QsRecode")
|
||||||
private val adapter: SoundtListAdapter by lazy {
|
|
||||||
SoundtListAdapter()
|
|
||||||
}
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||||
): View {
|
): View {
|
||||||
@ -39,10 +36,18 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
|
|||||||
//// 设置 RecyclerView 的固定大小,避免在滚动时重新计算视图大小和布局,提高性能
|
//// 设置 RecyclerView 的固定大小,避免在滚动时重新计算视图大小和布局,提高性能
|
||||||
binding.evaluationVoiceRecyclerview.setHasFixedSize(true)
|
binding.evaluationVoiceRecyclerview.setHasFixedSize(true)
|
||||||
binding.evaluationVoiceRecyclerview.layoutManager = layoutManager
|
binding.evaluationVoiceRecyclerview.layoutManager = layoutManager
|
||||||
|
/**
|
||||||
|
* 监听左侧栏的点击事件
|
||||||
|
*/
|
||||||
|
val adapter = SoundtListAdapter { _, view ->
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
binding.evaluationVoiceRecyclerview.adapter = adapter
|
binding.evaluationVoiceRecyclerview.adapter = adapter
|
||||||
viewModel.listDataChatMsgEntityList.observe(viewLifecycleOwner) {
|
viewModel.listDataChatMsgEntityList.observe(viewLifecycleOwner) {
|
||||||
adapter.refreshData(it)
|
adapter.refreshData(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
viewModel.getChatMsgEntityList()
|
viewModel.getChatMsgEntityList()
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import java.io.*
|
|||||||
*使用 LifecycleRegistry 给 ViewHolder 分发生命周期(这里使用了这个)
|
*使用 LifecycleRegistry 给 ViewHolder 分发生命周期(这里使用了这个)
|
||||||
*/
|
*/
|
||||||
class SoundtListAdapter(
|
class SoundtListAdapter(
|
||||||
|
private var itemListener: ((Int, View) -> Unit?)? = null
|
||||||
) : BaseRecyclerViewAdapter<ChatMsgEntity>() {
|
) : BaseRecyclerViewAdapter<ChatMsgEntity>() {
|
||||||
|
|
||||||
//媒体播放器
|
//媒体播放器
|
||||||
@ -42,8 +43,6 @@ class SoundtListAdapter(
|
|||||||
//录音时动画效果
|
//录音时动画效果
|
||||||
private var animaV: AnimationDrawable? = null
|
private var animaV: AnimationDrawable? = null
|
||||||
|
|
||||||
private var itemClick: OnItemClickListner? = null
|
|
||||||
|
|
||||||
//最大宽度
|
//最大宽度
|
||||||
private val maxWidth = 0
|
private val maxWidth = 0
|
||||||
|
|
||||||
@ -67,14 +66,14 @@ class SoundtListAdapter(
|
|||||||
holder.viewBinding.tvTime.isSelected = entity.isDelete
|
holder.viewBinding.tvTime.isSelected = entity.isDelete
|
||||||
holder.viewBinding.rlSoundContent.isSelected = entity.isDelete
|
holder.viewBinding.rlSoundContent.isSelected = entity.isDelete
|
||||||
holder.viewBinding.ivSoundAnim.setBackgroundResource(R.drawable.icon_sound_03)
|
holder.viewBinding.ivSoundAnim.setBackgroundResource(R.drawable.icon_sound_03)
|
||||||
/* if (itemClick != null) {
|
|
||||||
holder.viewBinding.rlSoundContent.setOnClickListener {
|
holder.viewBinding.rlSoundContent.setOnClickListener {
|
||||||
itemClick!!.onItemClick(it.findViewById<View>(R.id.rl_sound_content), position)
|
setPlayerIndex(it.findViewById<View>(R.id.rl_sound_content),position)
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
//mixWidth
|
//mixWidth
|
||||||
if (!TextUtils.isEmpty(entity.name)) {
|
if (!TextUtils.isEmpty(entity.name)) {
|
||||||
/* if (entity.name.indexOf(".pcm") > 0) {
|
if (entity.name!!.indexOf(".pcm") > 0) {
|
||||||
val file: File = File(entity.voiceUri + entity.name)
|
val file: File = File(entity.voiceUri + entity.name)
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
val time = (file.length() / 16000).toInt()
|
val time = (file.length() / 16000).toInt()
|
||||||
@ -90,7 +89,7 @@ class SoundtListAdapter(
|
|||||||
try {
|
try {
|
||||||
md = MediaPlayer()
|
md = MediaPlayer()
|
||||||
md!!.reset()
|
md!!.reset()
|
||||||
md!!.setDataSource(entity.voiceUri+entity.name)
|
md!!.setDataSource(entity.voiceUri + entity.name)
|
||||||
md!!.prepare()
|
md!!.prepare()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
@ -111,7 +110,7 @@ class SoundtListAdapter(
|
|||||||
}
|
}
|
||||||
holder.viewBinding.tvTime.text = time
|
holder.viewBinding.tvTime.text = time
|
||||||
md!!.release()
|
md!!.release()
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,11 +142,11 @@ class SoundtListAdapter(
|
|||||||
imageV.setBackgroundResource(R.drawable.sound_anim)
|
imageV.setBackgroundResource(R.drawable.sound_anim)
|
||||||
animaV = imageV.background as AnimationDrawable
|
animaV = imageV.background as AnimationDrawable
|
||||||
animaV!!.start()
|
animaV!!.start()
|
||||||
/* if (name.index(".pcm") > 0) {
|
if (name!!.indexOf(".pcm") > 0) {
|
||||||
audioTrackPlay(name, imageV)
|
audioTrackPlay(name, imageV)
|
||||||
} else {
|
} else {
|
||||||
mediaPlayer(name, imageV)
|
mediaPlayer(name, imageV)
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun mediaPlayer(name: String, imageV: ImageView) {
|
fun mediaPlayer(name: String, imageV: ImageView) {
|
||||||
@ -225,13 +224,6 @@ class SoundtListAdapter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setOnItemClickListener(clickListner: OnItemClickListner) {
|
|
||||||
itemClick = clickListner
|
|
||||||
}
|
|
||||||
|
|
||||||
interface OnItemClickListner {
|
|
||||||
fun onItemClick(view: View?, postion: Int)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getItemViewRes(position: Int): Int {
|
override fun getItemViewRes(position: Int): Int {
|
||||||
return R.layout.adapter_sound_list
|
return R.layout.adapter_sound_list
|
||||||
|
Loading…
x
Reference in New Issue
Block a user