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