|
|
@@ -1,5 +1,6 @@
|
|
|
package com.yingyangfly.baselib.dialog
|
|
|
|
|
|
+import android.annotation.SuppressLint
|
|
|
import android.content.Context
|
|
|
import android.os.Bundle
|
|
|
import android.view.LayoutInflater
|
|
|
@@ -35,13 +36,12 @@ class TaskFragment : DialogFragment(), View.OnTouchListener {
|
|
|
private var tvContent: AppCompatTextView? = null
|
|
|
private var confirmBtan: AppCompatButton? = null
|
|
|
private var id = ""
|
|
|
+
|
|
|
/**
|
|
|
* 语音合成
|
|
|
*/
|
|
|
private var voicePlayer: VoicePlayer? = null
|
|
|
|
|
|
- private var content: Context? = null
|
|
|
-
|
|
|
var onDialogClickListener: ((bean: String) -> Unit)? = null
|
|
|
|
|
|
fun setTaskDesn(taskDesn: String, id: String) {
|
|
|
@@ -73,7 +73,6 @@ class TaskFragment : DialogFragment(), View.OnTouchListener {
|
|
|
hideBar(BarHide.FLAG_HIDE_BAR)
|
|
|
navigationBarColor(R.color.transparent)
|
|
|
}
|
|
|
- content = activity
|
|
|
val rootView = ViewTool.inflateFragmentPixels(
|
|
|
activity, R.layout.fragment_task, container, 1194, 834
|
|
|
)
|
|
|
@@ -106,16 +105,14 @@ class TaskFragment : DialogFragment(), View.OnTouchListener {
|
|
|
* 播放语音合成内容
|
|
|
*/
|
|
|
private fun speak(taskDesn: String) {
|
|
|
- if (content != null) {
|
|
|
- val db = AppDataBase.getInstance(content!!)
|
|
|
- if (db != null) {
|
|
|
- val voicePlayerDao = db.getVoicePlayerDao()
|
|
|
- if (voicePlayerDao != null) {
|
|
|
- val voicePlayerBean = voicePlayerDao.getVoicePlayerBean(taskDesn)
|
|
|
- if (voicePlayerBean != null && voicePlayer != null) {
|
|
|
- voicePlayer?.play(voicePlayerBean.url) {
|
|
|
+ val db = AppDataBase.getInstance(requireActivity())
|
|
|
+ if (db != null) {
|
|
|
+ val voicePlayerDao = db.getVoicePlayerDao()
|
|
|
+ if (voicePlayerDao != null) {
|
|
|
+ val voicePlayerBean = voicePlayerDao.getVoicePlayerBean(taskDesn)
|
|
|
+ if (voicePlayerBean != null && voicePlayer != null) {
|
|
|
+ voicePlayer?.play(voicePlayerBean.url) {
|
|
|
|
|
|
- }
|
|
|
}
|
|
|
} else {
|
|
|
getWordsUrl(taskDesn)
|
|
|
@@ -123,6 +120,8 @@ class TaskFragment : DialogFragment(), View.OnTouchListener {
|
|
|
} else {
|
|
|
getWordsUrl(taskDesn)
|
|
|
}
|
|
|
+ } else {
|
|
|
+ getWordsUrl(taskDesn)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -133,11 +132,11 @@ class TaskFragment : DialogFragment(), View.OnTouchListener {
|
|
|
BaselibServiceFactory.getService()
|
|
|
.getVoiceUrl(word)
|
|
|
.subscribeOn(Schedulers.io())
|
|
|
- .compose(MyRxScheduler.ioMain(content!!, false))
|
|
|
+ .compose(MyRxScheduler.ioMain(requireActivity(), false))
|
|
|
.subscribe(object : BaseObserver<String>() {
|
|
|
override fun onSuccess(t: String?) {
|
|
|
t?.let {
|
|
|
- val db = AppDataBase.getInstance(content!!)
|
|
|
+ val db = AppDataBase.getInstance(requireActivity())
|
|
|
if (db != null) {
|
|
|
val voicePlayerDao = db.getVoicePlayerDao()
|
|
|
if (voicePlayerDao != null) {
|
|
|
@@ -160,6 +159,7 @@ class TaskFragment : DialogFragment(), View.OnTouchListener {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ @SuppressLint("ClickableViewAccessibility")
|
|
|
override fun onTouch(v: View?, event: MotionEvent?): Boolean {
|
|
|
if (isCancelable && dialog?.isShowing == true) {
|
|
|
dismiss()
|