Commit 5c1be648 by 范玉宾

Merge branch 'd/lancet/4.3.93_muse' into 'd/4.3.93_muse'

D/lancet/4.3.93 muse

See merge request app_android_lib/YDL-Component!66
parents 4759771f 3c51b5b3
...@@ -67,7 +67,7 @@ public class PlayFragment extends Fragment implements View.OnClickListener, ...@@ -67,7 +67,7 @@ public class PlayFragment extends Fragment implements View.OnClickListener,
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
initPlayMode(); initPlayMode();
MeditationFloatEvent event = new MeditationFloatEvent(false,true,null,null); MeditationFloatEvent event = new MeditationFloatEvent(false,true,null,null,null);
EventBus.getDefault().post(event); EventBus.getDefault().post(event);
onChangeImpl(AudioPlayer.Companion.get().getPlayMusic()); onChangeImpl(AudioPlayer.Companion.get().getPlayMusic());
......
...@@ -14,7 +14,7 @@ ext { ...@@ -14,7 +14,7 @@ ext {
"m-dynamic" : "0.0.7.73", "m-dynamic" : "0.0.7.73",
"m-article" : "0.0.0.10", "m-article" : "0.0.0.10",
"m-muse" : "0.0.28.46", "m-muse" : "0.0.28.47",
"m-tests" : "0.0.24.18", "m-tests" : "0.0.24.18",
"m-course" : "0.0.43.37", "m-course" : "0.0.43.37",
...@@ -99,7 +99,7 @@ ext { ...@@ -99,7 +99,7 @@ ext {
"m-dynamic" : "0.0.7.73", "m-dynamic" : "0.0.7.73",
"m-article" : "0.0.0.8", "m-article" : "0.0.0.8",
"m-muse" : "0.0.28.46", "m-muse" : "0.0.28.47",
"m-tests" : "0.0.24.18", "m-tests" : "0.0.24.18",
"m-course" : "0.0.43.37", "m-course" : "0.0.43.37",
//-------------- 业务模块 API 层 -------------- //-------------- 业务模块 API 层 --------------
......
...@@ -111,7 +111,6 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -111,7 +111,6 @@ class PlayMeditationActivity : BaseActivity() {
mMeditationType = intent?.getIntExtra("MEDITATION_TYPE", 0) mMeditationType = intent?.getIntExtra("MEDITATION_TYPE", 0)
mMediaUrl = intent?.getStringExtra("MEDIA_URL") ?: "" mMediaUrl = intent?.getStringExtra("MEDIA_URL") ?: ""
mMediaCoverUrl = intent?.getStringExtra("MEDIA_COVER_URL") ?: "" mMediaCoverUrl = intent?.getStringExtra("MEDIA_COVER_URL") ?: ""
broadcastTime = intent?.getIntExtra("BROAD_CAST_TIME",0)?:0
initView() initView()
getData() getData()
...@@ -155,7 +154,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -155,7 +154,7 @@ class PlayMeditationActivity : BaseActivity() {
updateUI() updateUI()
initMediaPlayer(mTitle, currentPosition) initMediaPlayer(mMediaUrl, currentPosition)
//快进点击事件 //快进点击事件
ActionCountUtils.baiDuCountSign3( ActionCountUtils.baiDuCountSign3(
...@@ -172,7 +171,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -172,7 +171,7 @@ class PlayMeditationActivity : BaseActivity() {
show(msg) show(msg)
} }
}) })
} else if (mMeditationType == 1) { } else {
MuseHttp.getInstance().getMeditationPlayDetail( MuseHttp.getInstance().getMeditationPlayDetail(
meditionType = 1, meditionType = 1,
mediaId = mMediaId!!, mediaId = mMediaId!!,
...@@ -350,28 +349,20 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -350,28 +349,20 @@ class PlayMeditationActivity : BaseActivity() {
) )
if(mMeditationType == 0){ if(mMeditationType == 0){
stopPlay()
if (mMeditationId != null && mMediaId != null) { if (mMeditationId != null && mMediaId != null) {
MuseHttp.getInstance().postMeditationPlayRecord( MediaPlayerTimeUtil.uploadPlayRecord(
meditationId = mMeditationId!!.toInt(), meditationId = mMeditationId!!.toInt(),
isQuit = 1, mediaId = mMediaId!!, isQuit = 1, mediaId = mMediaId!!,
playTime = (seekbar_play_progress.progress / 1000.00).roundToInt(), playTime = (seekbar_play_progress.progress / 1000.00).roundToInt(),
isComplete = 0 isComplete = 0
) )
.subscribeOn(Schedulers.io()) stopPlay()
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
finish()
}, {
object : ThrowableConsumer() {
override fun accept(msg: String) {
finish() finish()
}
}
})
} else { } else {
stopPlay()
finish() finish()
} }
}else{ }else{
if (quitDialog == null) { if (quitDialog == null) {
quitDialog = QuitMeditationDialog.newInstance() quitDialog = QuitMeditationDialog.newInstance()
...@@ -379,29 +370,17 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -379,29 +370,17 @@ class PlayMeditationActivity : BaseActivity() {
if (quitDialog != null && quitDialog?.isAdded == false) { if (quitDialog != null && quitDialog?.isAdded == false) {
quitDialog?.setListener(object : QuitMeditationDialog.ClickListener { quitDialog?.setListener(object : QuitMeditationDialog.ClickListener {
override fun quit() { override fun quit() {
stopPlay()
if (mMeditationId != null && mMediaId != null) { if (mMeditationId != null && mMediaId != null) {
MuseHttp.getInstance().postMeditationPlayRecord( MediaPlayerTimeUtil.uploadPlayRecord(
meditationId = mMeditationId!!.toInt(), meditationId = mMeditationId!!.toInt(),
isQuit = 1, mediaId = mMediaId!!, isQuit = 1, mediaId = mMediaId!!,
playTime = (seekbar_play_progress.progress / 1000.00).roundToInt(), playTime = (seekbar_play_progress.progress / 1000.00).roundToInt(),
isComplete = 0 isComplete = 0
) )
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
finish()
}, {
object : ThrowableConsumer() {
override fun accept(msg: String) {
finish()
} }
} stopPlay()
})
} else {
finish() finish()
} }
}
}) })
quitDialog?.show(supportFragmentManager, QuitMeditationDialog.TAG) quitDialog?.show(supportFragmentManager, QuitMeditationDialog.TAG)
} }
...@@ -419,7 +398,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -419,7 +398,7 @@ class PlayMeditationActivity : BaseActivity() {
"" ""
) )
val event = MeditationFloatEvent(true, val event = MeditationFloatEvent(true,
meditationDetail = currentMeditation?.copy(meditationType = mMeditationType)) meditation = currentMeditation?.copy(meditationType = mMeditationType))
EventBus.getDefault().post(event) EventBus.getDefault().post(event)
Handler().postDelayed({ Handler().postDelayed({
...@@ -701,9 +680,14 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -701,9 +680,14 @@ class PlayMeditationActivity : BaseActivity() {
} }
private fun initPlayCompletionListener(isLoop: Boolean = false, isSingle: Boolean = false) { private fun initPlayCompletionListener(isLoop: Boolean = false, isSingle: Boolean = false) {
mMediaPlayer?.setOnCompletionListener { mMediaPlayer?.setOnCompletionListener {
val duration = currentMeditation?.duration?.toInt()?:0
val currentDuration = mMediaPlayer?.currentPosition?:0
if(currentDuration==duration){
val playTime = (seekbar_play_progress.progress / 1000.00).roundToInt() val playTime = (seekbar_play_progress.progress / 1000.00).roundToInt()
MediaPlayerTimeUtil.uploadPlayRecord( MediaPlayerTimeUtil.uploadPlayRecord(
meditationId = mMeditationId?.toInt(), meditationId = mMeditationId?.toInt(),
mediaId = mMediaId, mediaId = mMediaId,
...@@ -711,6 +695,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -711,6 +695,7 @@ class PlayMeditationActivity : BaseActivity() {
playTime = playTime, playTime = playTime,
isComplete = 1 isComplete = 1
) )
}
if (isLoop){ if (isLoop){
if (isSingle || meditations.size == 1){ if (isSingle || meditations.size == 1){
...@@ -756,6 +741,9 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -756,6 +741,9 @@ class PlayMeditationActivity : BaseActivity() {
private fun initMediaPlayer(path: String, current: Int) { private fun initMediaPlayer(path: String, current: Int) {
val event = MeditationFloatEvent(show = false,stop = false,meditation = currentMeditation)
EventBus.getDefault().post(event)
if (MediaPlayerManager.getInstance(this)?.getAudioPath() != null if (MediaPlayerManager.getInstance(this)?.getAudioPath() != null
&& MediaPlayerManager.getInstance(this)?.getAudioPath() == path && MediaPlayerManager.getInstance(this)?.getAudioPath() == path
) { ) {
...@@ -947,7 +935,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -947,7 +935,7 @@ class PlayMeditationActivity : BaseActivity() {
} }
override fun onBackPressed() { override fun onBackPressed() {
val event = MeditationFloatEvent(true, meditationDetail = currentMeditation) val event = MeditationFloatEvent(true, meditation = currentMeditation)
EventBus.getDefault().post(event) EventBus.getDefault().post(event)
super.onBackPressed() super.onBackPressed()
} }
......
...@@ -4,8 +4,9 @@ import com.yidianling.muse.bean.MeditationPlayModuleBean ...@@ -4,8 +4,9 @@ import com.yidianling.muse.bean.MeditationPlayModuleBean
class MeditationFloatEvent( class MeditationFloatEvent(
val show: Boolean, val show: Boolean,
val stop: Boolean?=null, val stop: Boolean? = null,
val time:Long?=null, val time: Long? = null,
val meditationDetail: MeditationPlayModuleBean.MeditationDetail?=null val meditation: MeditationPlayModuleBean.MeditationDetail? = null,
val meditations: ArrayList<MeditationPlayModuleBean.MeditationDetail>? = null
) )
...@@ -17,6 +17,7 @@ import android.view.ViewGroup.LayoutParams.WRAP_CONTENT ...@@ -17,6 +17,7 @@ import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
import android.view.WindowManager import android.view.WindowManager
import android.widget.ImageView import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import androidx.appcompat.widget.AppCompatSeekBar
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
import androidx.lifecycle.LifecycleService import androidx.lifecycle.LifecycleService
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
...@@ -61,12 +62,18 @@ class MeditationWindowService : LifecycleService() { ...@@ -61,12 +62,18 @@ class MeditationWindowService : LifecycleService() {
private var mCurrentMeditation: MeditationPlayModuleBean.MeditationDetail? = null private var mCurrentMeditation: MeditationPlayModuleBean.MeditationDetail? = null
private var mMeditations = mutableListOf<MeditationPlayModuleBean.MeditationDetail>()
private var windowIsShow = false private var windowIsShow = false
private var mDisposable: Disposable? = null private var mDisposable: Disposable? = null
private var mObservable: Observable<Long>? = null private var mObservable: Observable<Long>? = null
private var mObserver: Observer<Long>? = null private var mObserver: Observer<Long>? = null
private var mProgressTimer = Timer()
private lateinit var mSeekBar : AppCompatSeekBar
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
...@@ -80,6 +87,7 @@ class MeditationWindowService : LifecycleService() { ...@@ -80,6 +87,7 @@ class MeditationWindowService : LifecycleService() {
} }
} }
mSeekBar = AppCompatSeekBar(this)
EventBus.getDefault().register(this) EventBus.getDefault().register(this)
} }
...@@ -124,7 +132,7 @@ class MeditationWindowService : LifecycleService() { ...@@ -124,7 +132,7 @@ class MeditationWindowService : LifecycleService() {
mDisposable?.dispose() mDisposable?.dispose()
} }
}else{ }else{
if (!event.show) { if (event.show!=null && !event.show) {
if (event.stop == true){ if (event.stop == true){
try { try {
mMediaPlayer?.stop() mMediaPlayer?.stop()
...@@ -135,14 +143,17 @@ class MeditationWindowService : LifecycleService() { ...@@ -135,14 +143,17 @@ class MeditationWindowService : LifecycleService() {
} }
hideFloatWindow() hideFloatWindow()
} }
if (event.show && event.meditationDetail != null) { if (event.show!=null && event.show && event.meditation != null) {
if (!windowIsShow) { if (!windowIsShow) {
showWindow() showWindow()
} }
updateFloatView(event.meditationDetail) updateFloatView(event.meditation)
} }
} }
mSeekBar.progress = 2
mSeekBar.max = event.meditation?.duration?.toInt()?:0
} }
private fun updateFloatView(meditation: MeditationPlayModuleBean.MeditationDetail) { private fun updateFloatView(meditation: MeditationPlayModuleBean.MeditationDetail) {
...@@ -223,12 +234,22 @@ class MeditationWindowService : LifecycleService() { ...@@ -223,12 +234,22 @@ class MeditationWindowService : LifecycleService() {
}, 0, 50) }, 0, 50)
mMediaPlayer?.setOnCompletionListener { mMediaPlayer?.setOnCompletionListener {
postPlayRecord(
0, (ivProgress?.curProcess?.div(1000.00))?.roundToInt() ?: 0, val duration = meditation?.duration?.toInt()?:0
1, val currentDuration = mMediaPlayer?.currentPosition?:0
meditation.meditationId.toInt(),
meditation.mediaId ?: 0L if(meditation.mediaId!=null && meditation.meditationId!=null){
val playTime = (ivProgress?.curProcess?.div(1000.00))?.roundToInt() ?: 0
if(duration == currentDuration){
MediaPlayerTimeUtil.uploadPlayRecord(
meditationId = meditation.meditationId.toInt(),
mediaId = meditation.mediaId,
isQuit = 0,
playTime = playTime,
isComplete = 1
) )
}
}
if (mMediaPlayer?.isPlaying == true) { if (mMediaPlayer?.isPlaying == true) {
ivPlayOrPause?.setImageResource(R.drawable.icon_meditation_float_play) ivPlayOrPause?.setImageResource(R.drawable.icon_meditation_float_play)
} else { } else {
...@@ -240,12 +261,17 @@ class MeditationWindowService : LifecycleService() { ...@@ -240,12 +261,17 @@ class MeditationWindowService : LifecycleService() {
//悬浮窗关闭点击事件 //悬浮窗关闭点击事件
ActionCountUtils.count(MuseBIConstants.YDL_MUSE_MEDITATION_WINDOW_CLOSE_CLICK,"") ActionCountUtils.count(MuseBIConstants.YDL_MUSE_MEDITATION_WINDOW_CLOSE_CLICK,"")
postPlayRecord( if(meditation.mediaId!=null && meditation.meditationId!=null){
1, (ivProgress?.curProcess?.div(1000.00))?.roundToInt() ?: 0, val playTime = (ivProgress?.curProcess?.div(1000.00))?.roundToInt() ?: 0
0, MediaPlayerTimeUtil.uploadPlayRecord(
meditation.meditationId.toInt(), meditationId = meditation.meditationId.toInt(),
meditation.mediaId ?: 0L mediaId = meditation.mediaId,
isQuit = 0,
playTime = playTime,
isComplete = 0
) )
}
MediaPlayerManager.getInstance(this)?.stop() MediaPlayerManager.getInstance(this)?.stop()
hideFloatWindow() hideFloatWindow()
} }
...@@ -332,30 +358,4 @@ class MeditationWindowService : LifecycleService() { ...@@ -332,30 +358,4 @@ class MeditationWindowService : LifecycleService() {
} }
private fun postPlayRecord(
isQuit: Int,
playTime: Int,
isComplete: Int,
meditationId: Int,
mediaId: Long
) {
MuseHttp.getInstance().postMeditationPlayRecord(
meditationId = meditationId,
isQuit = isQuit, mediaId = mediaId,
playTime = playTime,
isComplete = isComplete
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
}, {
object : ThrowableConsumer() {
override fun accept(msg: String) {
}
}
})
}
} }
\ No newline at end of file
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="#CC282E3F"> android:background="#B3000000">
<ImageView <ImageView
android:id="@+id/iv_bg" android:id="@+id/iv_bg"
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginVertical="28dp" android:layout_marginVertical="28dp"
android:text="确定要结束联系吗?" android:text="确定要结束练习吗?"
android:textColor="#FF242424" android:textColor="#FF242424"
android:textSize="16sp" android:textSize="16sp"
android:layout_gravity="center_horizontal"/> android:layout_gravity="center_horizontal"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment