Commit c6b43e16 by 范玉宾

to be test

parent deddb032
...@@ -8,13 +8,13 @@ ext { ...@@ -8,13 +8,13 @@ ext {
"m-confide" : "0.0.49.69", "m-confide" : "0.0.49.69",
"m-consultant" : "0.0.60.16", "m-consultant" : "0.0.60.16",
"m-fm" : "0.0.30.08", "m-fm" : "0.0.30.08",
"m-user" : "0.0.62.04", "m-user" : "0.0.62.05",
"m-home" : "0.0.23.35", "m-home" : "0.0.23.49",
"m-im" : "0.0.21.30", "m-im" : "0.0.21.30",
"m-dynamic" : "0.0.7.35", "m-dynamic" : "0.0.7.35",
"m-article" : "0.0.0.10", "m-article" : "0.0.0.10",
"m-muse" : "0.0.28.28", "m-muse" : "0.0.28.29",
"m-tests" : "0.0.24.18", "m-tests" : "0.0.24.18",
"m-course" : "0.0.43.37", "m-course" : "0.0.43.37",
...@@ -35,10 +35,10 @@ ext { ...@@ -35,10 +35,10 @@ ext {
//mdt 组件 //mdt 组件
"ydl-tuicore" : "0.0.22", "ydl-tuicore" : "0.0.22",
//第一步 //第一步
"ydl-platform" : "0.0.41.2", "ydl-platform" : "0.0.41.5",
//第二步 若干 //第二步 若干
"ydl-webview" : "0.0.38.71", "ydl-webview" : "0.0.38.73",
"ydl-media" : "0.0.21.44", "ydl-media" : "0.0.21.44",
"ydl-pay" : "0.0.18.19", "ydl-pay" : "0.0.18.19",
"m-audioim" : "0.0.49.29.85", "m-audioim" : "0.0.49.29.85",
...@@ -94,13 +94,13 @@ ext { ...@@ -94,13 +94,13 @@ ext {
"m-confide" : "0.0.49.69", "m-confide" : "0.0.49.69",
"m-consultant" : "0.0.60.16", "m-consultant" : "0.0.60.16",
"m-fm" : "0.0.30.08", "m-fm" : "0.0.30.08",
"m-user" : "0.0.62.04", "m-user" : "0.0.62.05",
"m-home" : "0.0.23.35", "m-home" : "0.0.23.49",
"m-im" : "0.0.21.30", "m-im" : "0.0.21.30",
"m-dynamic" : "0.0.7.35", "m-dynamic" : "0.0.7.35",
"m-article" : "0.0.0.8", "m-article" : "0.0.0.8",
"m-muse" : "0.0.28.28", "m-muse" : "0.0.28.29",
"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 层 --------------
...@@ -119,10 +119,10 @@ ext { ...@@ -119,10 +119,10 @@ ext {
//mdt组件 //mdt组件
"ydl-tuicore" : "0.0.22", "ydl-tuicore" : "0.0.22",
//第一步 //第一步
"ydl-platform" : "0.0.41.2", "ydl-platform" : "0.0.41.5",
//第二步 若干 //第二步 若干
"ydl-webview" : "0.0.38.71", "ydl-webview" : "0.0.38.73",
"ydl-media" : "0.0.21.44", "ydl-media" : "0.0.21.44",
"ydl-pay" : "0.0.18.19", "ydl-pay" : "0.0.18.19",
"m-audioim" : "0.0.49.29.85", "m-audioim" : "0.0.49.29.85",
......
...@@ -33,6 +33,9 @@ import io.reactivex.disposables.Disposable ...@@ -33,6 +33,9 @@ import io.reactivex.disposables.Disposable
import io.reactivex.functions.Consumer import io.reactivex.functions.Consumer
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.activity_play_meditation.* import kotlinx.android.synthetic.main.activity_play_meditation.*
import kotlinx.android.synthetic.main.activity_play_meditation.iv_close
import kotlinx.android.synthetic.main.activity_play_meditation.tv_title
import kotlinx.android.synthetic.main.layout_meditation_play_float_view.*
import kotlinx.android.synthetic.main.player_control_view.* import kotlinx.android.synthetic.main.player_control_view.*
import java.util.* import java.util.*
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
...@@ -55,7 +58,10 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -55,7 +58,10 @@ class PlayMeditationActivity : BaseActivity() {
private val newPath = private val newPath =
"http://file.diyring.cc/UserRingWorksFile/0/50284096.mp3" "http://file.diyring.cc/UserRingWorksFile/0/50284096.mp3"
private var currentPath = "" private var shareTitle = ""
private var shareUrl = ""
private var shareContent = ""
private var shareImageUrl = ""
private var collected = false private var collected = false
private var isPlaying = false private var isPlaying = false
...@@ -79,9 +85,11 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -79,9 +85,11 @@ class PlayMeditationActivity : BaseActivity() {
statusBarLightMode(this) statusBarLightMode(this)
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
mMediaPlayer = MediaPlayerManager.getInstance(this)?.getMediaPlayer()
EventBus.getDefault().register(this) EventBus.getDefault().register(this)
mediaId = intent?.getLongExtra("MEDIA_ID",0L) mediaId = intent?.getLongExtra("MEDIA_ID", 0L)
meditationId = intent?.getLongExtra("MEDITATION_ID", 0L) meditationId = intent?.getLongExtra("MEDITATION_ID", 0L)
meditationType = intent?.getIntExtra("MEDITATION_TYPE", 0) meditationType = intent?.getIntExtra("MEDITATION_TYPE", 0)
mediaUrl = intent?.getStringExtra("MEDIA_URL") ?: "" mediaUrl = intent?.getStringExtra("MEDIA_URL") ?: ""
...@@ -118,7 +126,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -118,7 +126,7 @@ class PlayMeditationActivity : BaseActivity() {
if (meditationPlayBean.mediaId == currentMediaId) { if (meditationPlayBean.mediaId == currentMediaId) {
mediaId = module?.mediaId ?: 0L mediaId = module?.mediaId ?: 0L
val title = meditationPlayBean.title ?: "未知标题" val title = meditationPlayBean.title ?: "未知标题"
val desc = meditationPlayBean.desc ?: "写着人们心疼的曲折,我想我很快乐,做一个旁观者" val desc = meditationPlayBean.desc ?: ""
val mediaUrl = meditationPlayBean.mediaUrl val mediaUrl = meditationPlayBean.mediaUrl
...@@ -133,6 +141,10 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -133,6 +141,10 @@ class PlayMeditationActivity : BaseActivity() {
tv_title.text = title tv_title.text = title
tv_content.text = desc tv_content.text = desc
shareTitle = title
shareContent = desc
shareUrl = mediaUrl
iv_collect.setImageResource( iv_collect.setImageResource(
if (status == 0) { if (status == 0) {
R.drawable.icon_play_meditation_collect R.drawable.icon_play_meditation_collect
...@@ -141,6 +153,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -141,6 +153,7 @@ class PlayMeditationActivity : BaseActivity() {
} }
) )
initMediaPlayer(mediaUrl, currentPosition) initMediaPlayer(mediaUrl, currentPosition)
} }
} }
...@@ -168,7 +181,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -168,7 +181,7 @@ class PlayMeditationActivity : BaseActivity() {
if (meditationPlayBean.mediaId == currentMediaId) { if (meditationPlayBean.mediaId == currentMediaId) {
mediaId = module?.mediaId ?: 0L mediaId = module?.mediaId ?: 0L
val title = meditationPlayBean.title val title = meditationPlayBean.title
val desc = meditationPlayBean.desc ?: "写着人们心疼的曲折,我想我很快乐,做一个旁观者" val desc = meditationPlayBean.desc ?: ""
val bgImageUrl = meditationPlayBean.coverImageUrl val bgImageUrl = meditationPlayBean.coverImageUrl
...@@ -189,6 +202,10 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -189,6 +202,10 @@ class PlayMeditationActivity : BaseActivity() {
tv_title.text = title tv_title.text = title
tv_content.text = desc tv_content.text = desc
shareTitle = title
shareContent = desc
shareUrl = mediaUrl
iv_collect.setImageResource( iv_collect.setImageResource(
if (status == 0) { if (status == 0) {
R.drawable.icon_play_meditation_collect R.drawable.icon_play_meditation_collect
...@@ -196,6 +213,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -196,6 +213,7 @@ class PlayMeditationActivity : BaseActivity() {
R.drawable.icon_meditation_collected R.drawable.icon_meditation_collected
} }
) )
initMediaPlayer(mediaUrl, currentPosition) initMediaPlayer(mediaUrl, currentPosition)
} }
} }
...@@ -290,6 +308,8 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -290,6 +308,8 @@ class PlayMeditationActivity : BaseActivity() {
private fun initView() { private fun initView() {
shareImageUrl = mediaCoverUrl
Glide.with(this) Glide.with(this)
.load(mediaCoverUrl) .load(mediaCoverUrl)
.into(iv_bg) .into(iv_bg)
...@@ -336,7 +356,11 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -336,7 +356,11 @@ class PlayMeditationActivity : BaseActivity() {
iv_share.setOnClickListener { iv_share.setOnClickListener {
if (shareDialog == null) { if (shareDialog == null) {
shareDialog = ShareMeditationDialog shareDialog = ShareMeditationDialog
.newInstance(shareImageUrl = "") .newInstance(
shareTitle = shareTitle,
shareContent = shareContent,
shareUrl = shareUrl,
shareImageUrl = shareImageUrl)
} }
if (shareDialog != null && shareDialog?.isAdded == false) { if (shareDialog != null && shareDialog?.isAdded == false) {
shareDialog?.show(supportFragmentManager, ShareMeditationDialog.TAG) shareDialog?.show(supportFragmentManager, ShareMeditationDialog.TAG)
...@@ -360,7 +384,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -360,7 +384,7 @@ class PlayMeditationActivity : BaseActivity() {
exo_play.setOnClickListener { exo_play.setOnClickListener {
if (isPlaying) { if (isPlaying) {
MediaPlayerManager.getInstance(this)?.pause() mMediaPlayer?.pause()
if (meditationId == null || mediaId == null) return@setOnClickListener if (meditationId == null || mediaId == null) return@setOnClickListener
postPlayRecord( postPlayRecord(
isQuit = 0, isQuit = 0,
...@@ -370,7 +394,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -370,7 +394,7 @@ class PlayMeditationActivity : BaseActivity() {
} else { } else {
val duration = mMediaPlayer?.duration val duration = mMediaPlayer?.duration
MediaPlayerManager.getInstance(this)?.play() MediaPlayerManager.getInstance(this@PlayMeditationActivity)?.play()
if (duration != null) { if (duration != null) {
seekbar_play_progress.max = duration seekbar_play_progress.max = duration
...@@ -378,7 +402,9 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -378,7 +402,9 @@ class PlayMeditationActivity : BaseActivity() {
mTimer.schedule(object : TimerTask() { mTimer.schedule(object : TimerTask() {
override fun run() { override fun run() {
if (!isSeekbarChanging) { if (!isSeekbarChanging) {
seekbar_play_progress.progress = mMediaPlayer?.currentPosition ?: 0 seekbar_play_progress.progress = MediaPlayerManager
.getInstance(this@PlayMeditationActivity)
?.getMediaPlayer()?.currentPosition ?: 0
} }
} }
}, 0, 50) }, 0, 50)
...@@ -398,14 +424,18 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -398,14 +424,18 @@ class PlayMeditationActivity : BaseActivity() {
postPlayRecord(isQuit = 0, playTime = 0, isComplete = 0) postPlayRecord(isQuit = 0, playTime = 0, isComplete = 0)
MediaPlayerManager.getInstance(this)?.setAudioPath(newPath) MediaPlayerManager.getInstance(this)?.setAudioPath(newPath)
isPlaying = if (mMediaPlayer?.isPlaying == true) { isPlaying = if (MediaPlayerManager
.getInstance(this@PlayMeditationActivity)?.getMediaPlayer()?.isPlaying == true
) {
exo_play.setImageResource(R.drawable.icon_pause_play) exo_play.setImageResource(R.drawable.icon_pause_play)
if (duration != null) { if (duration != null) {
seekbar_play_progress.max = duration seekbar_play_progress.max = duration
} }
mTimer.schedule(object : TimerTask() { mTimer.schedule(object : TimerTask() {
override fun run() { override fun run() {
seekbar_play_progress.progress = mMediaPlayer?.currentPosition ?: 0 seekbar_play_progress.progress = MediaPlayerManager
.getInstance(this@PlayMeditationActivity)
?.getMediaPlayer()?.currentPosition ?: 0
} }
}, 0, 50) }, 0, 50)
true true
...@@ -420,7 +450,9 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -420,7 +450,9 @@ class PlayMeditationActivity : BaseActivity() {
postPlayRecord(isQuit = 0, playTime = 0, isComplete = 0) postPlayRecord(isQuit = 0, playTime = 0, isComplete = 0)
MediaPlayerManager.getInstance(this)?.setAudioPath(newPath) MediaPlayerManager.getInstance(this)?.setAudioPath(newPath)
isPlaying = if (mMediaPlayer?.isPlaying == true) { isPlaying = if (MediaPlayerManager
.getInstance(this@PlayMeditationActivity)?.getMediaPlayer()?.isPlaying == true
) {
exo_play.setImageResource(R.drawable.icon_pause_play) exo_play.setImageResource(R.drawable.icon_pause_play)
if (duration != null) { if (duration != null) {
seekbar_play_progress.max = duration seekbar_play_progress.max = duration
...@@ -428,7 +460,9 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -428,7 +460,9 @@ class PlayMeditationActivity : BaseActivity() {
mTimer.schedule(object : TimerTask() { mTimer.schedule(object : TimerTask() {
override fun run() { override fun run() {
if (!isSeekbarChanging) { if (!isSeekbarChanging) {
seekbar_play_progress.progress = mMediaPlayer?.currentPosition ?: 0 seekbar_play_progress.progress = MediaPlayerManager
.getInstance(this@PlayMeditationActivity)
?.getMediaPlayer()?.currentPosition ?: 0
} }
} }
}, 0, 50) }, 0, 50)
...@@ -440,19 +474,22 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -440,19 +474,22 @@ class PlayMeditationActivity : BaseActivity() {
} }
exo_rew.setOnClickListener { exo_rew.setOnClickListener {
if (mMediaPlayer != null) { val currentPosition = MediaPlayerManager
val currentPosition = mMediaPlayer!!.currentPosition .getInstance(this@PlayMeditationActivity)?.getMediaPlayer()?.currentPosition
val seekPosition = 0.coerceAtLeast(currentPosition - 15000) val seekPosition = 0.coerceAtLeast(currentPosition?.minus(15000) ?: 0)
mMediaPlayer!!.seekTo(seekPosition) MediaPlayerManager.getInstance(this@PlayMeditationActivity)?.getMediaPlayer()
} ?.seekTo(seekPosition)
} }
exo_ffwd.setOnClickListener { exo_ffwd.setOnClickListener {
if (mMediaPlayer != null) {
val currentPosition = mMediaPlayer!!.currentPosition val currentPosition = MediaPlayerManager
val seekPosition = duration.coerceAtMost(currentPosition + 15000) .getInstance(this@PlayMeditationActivity)?.getMediaPlayer()?.currentPosition
mMediaPlayer!!.seekTo(seekPosition) val seekPosition = duration.coerceAtMost(currentPosition?.plus(15000) ?: 0)
} MediaPlayerManager
.getInstance(this@PlayMeditationActivity)?.getMediaPlayer()?.seekTo(seekPosition)
} }
seekbar_play_progress.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener { seekbar_play_progress.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
...@@ -521,17 +558,61 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -521,17 +558,61 @@ class PlayMeditationActivity : BaseActivity() {
private fun initMediaPlayer(path: String, current: Int) { private fun initMediaPlayer(path: String, current: Int) {
if (currentPath == MediaPlayerManager.getInstance(this)?.getAudioPath()) { if (MediaPlayerManager.getInstance(this)?.getAudioPath() == null
&& MediaPlayerManager.getInstance(this)?.getAudioPath() == path
) {
MediaPlayerManager.getInstance(this)?.play()
if (mMediaPlayer?.isPlaying == true) { if (mMediaPlayer?.isPlaying == true) {
return exo_play.setImageResource(R.drawable.icon_pause_play)
true
} else { } else {
mMediaPlayer?.start() exo_play.setImageResource(R.drawable.icon_pause_meditation)
false
}
val currentPosition = mMediaPlayer?.currentPosition
duration = mMediaPlayer?.duration ?: 0
if (current != null && current > 0) {
mMediaPlayer?.seekTo(current * 1000)
seekbar_play_progress.max = duration
seekbar_play_progress.progress = current
exo_position.text = MediaPlayerTimeUtil.calculateTime(current)
} else if (currentPosition != null) {
seekbar_play_progress.max = duration
seekbar_play_progress.progress = current
exo_position.text = MediaPlayerTimeUtil.calculateTime(currentPosition / 1000)
}
if (duration != null) {
exo_duration.text = MediaPlayerTimeUtil.calculateTime(duration / 1000)
}
if (duration != null) {
seekbar_play_progress.max = duration
}
mTimer.schedule(object : TimerTask() {
override fun run() {
if (!isSeekbarChanging) {
seekbar_play_progress.progress = mMediaPlayer?.currentPosition ?: 0
}
} }
}, 0, 50)
} else { } else {
MediaPlayerManager.getInstance(this)?.setAudioPath(path)
MediaPlayerManager.getInstance(this)
?.setOnPreparedListener(object : MediaPlayerManager.OnMediaPlayerManagerListener {
override fun onPrepared(mediaPlayer: MediaPlayer) {
MediaPlayerManager.getInstance(this@PlayMeditationActivity)?.play()
if (mMediaPlayer?.isPlaying == true) { if (mMediaPlayer?.isPlaying == true) {
stopPlay() exo_play.setImageResource(R.drawable.icon_pause_play)
true
} else {
exo_play.setImageResource(R.drawable.icon_pause_meditation)
false
} }
MediaPlayerManager.getInstance(this)?.getAudioPath() == path
val currentPosition = mMediaPlayer?.currentPosition val currentPosition = mMediaPlayer?.currentPosition
duration = mMediaPlayer?.duration ?: 0 duration = mMediaPlayer?.duration ?: 0
if (current != null && current > 0) { if (current != null && current > 0) {
...@@ -542,11 +623,23 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -542,11 +623,23 @@ class PlayMeditationActivity : BaseActivity() {
} else if (currentPosition != null) { } else if (currentPosition != null) {
seekbar_play_progress.max = duration seekbar_play_progress.max = duration
seekbar_play_progress.progress = current seekbar_play_progress.progress = current
exo_position.text = MediaPlayerTimeUtil.calculateTime(currentPosition / 1000) exo_position.text =
MediaPlayerTimeUtil.calculateTime(currentPosition / 1000)
} }
if (duration != null) { if (duration != null) {
exo_duration.text = MediaPlayerTimeUtil.calculateTime(duration / 1000) exo_duration.text = MediaPlayerTimeUtil.calculateTime(duration / 1000)
} }
mTimer.schedule(object : TimerTask() {
override fun run() {
if (!isSeekbarChanging) {
seekbar_play_progress.progress = mMediaPlayer?.currentPosition ?: 0
}
}
}, 0, 50)
}
})
} }
} }
...@@ -561,13 +654,13 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -561,13 +654,13 @@ class PlayMeditationActivity : BaseActivity() {
tv_time_off.visibility = View.GONE tv_time_off.visibility = View.GONE
mDisposable?.dispose() mDisposable?.dispose()
initRxTimeOff((minute*60*1000).toLong(),0) initRxTimeOff((minute * 60 * 1000).toLong(), 0)
} else { } else {
tv_time_off_pure_music.visibility = View.GONE tv_time_off_pure_music.visibility = View.GONE
tv_time_off.visibility = View.VISIBLE tv_time_off.visibility = View.VISIBLE
mDisposable?.dispose() mDisposable?.dispose()
initRxTimeOff((minute*60*1000).toLong(),1) initRxTimeOff((minute * 60 * 1000).toLong(), 1)
} }
} else { } else {
mDisposable?.dispose() mDisposable?.dispose()
...@@ -577,22 +670,22 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -577,22 +670,22 @@ class PlayMeditationActivity : BaseActivity() {
} }
} }
private fun initRxTimeOff(time:Long,meditationType:Int){ private fun initRxTimeOff(time: Long, meditationType: Int) {
mObservable = Observable.interval(0,1,TimeUnit.SECONDS) mObservable = Observable.interval(0, 1, TimeUnit.SECONDS)
.take(time / 1000 + 1) .take(time / 1000 + 1)
.map { t -> time - t * 1000 } .map { t -> time - t * 1000 }
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
mObserver = object : Observer<Long>{ mObserver = object : Observer<Long> {
override fun onSubscribe(d: Disposable) { override fun onSubscribe(d: Disposable) {
mDisposable = d mDisposable = d
} }
override fun onNext(t: Long) { override fun onNext(t: Long) {
if (meditationType == 0){ if (meditationType == 0) {
tv_time_off_pure_music.text = MediaPlayerTimeUtil.formatTimeOff(t) tv_time_off_pure_music.text = MediaPlayerTimeUtil.formatTimeOff(t)
}else{ } else {
tv_time_off.text = MediaPlayerTimeUtil.formatTimeOff(t) tv_time_off.text = MediaPlayerTimeUtil.formatTimeOff(t)
} }
} }
...@@ -603,37 +696,64 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -603,37 +696,64 @@ class PlayMeditationActivity : BaseActivity() {
override fun onComplete() { override fun onComplete() {
show("倒计时结束,停止播放吧!") show("倒计时结束,停止播放吧!")
if (mMediaPlayer?.isPlaying == true){ if (mMediaPlayer?.isPlaying == true) {
mMediaPlayer?.stop() mMediaPlayer?.stop()
exo_play.setImageResource(R.drawable.icon_pause_meditation) exo_play.setImageResource(R.drawable.icon_pause_meditation)
} }
if (meditationType == 0){ if (meditationType == 0) {
tv_time_off_pure_music.text = "" tv_time_off_pure_music.text = ""
}else{ } else {
tv_time_off.text = "" tv_time_off.text = ""
} }
} }
} }
if (mObserver!=null && mObserver is Observer<Long>){ if (mObserver != null && mObserver is Observer<Long>) {
mObservable?.subscribe(mObserver as Observer<Long>) mObservable?.subscribe(mObserver as Observer<Long>)
} }
if (mDisposable?.isDisposed == true && mObserver!=null && mObserver is Observer<Long>){ if (mDisposable?.isDisposed == true && mObserver != null && mObserver is Observer<Long>) {
mObservable?.subscribe(mObserver as Observer<Long>) mObservable?.subscribe(mObserver as Observer<Long>)
} }
} }
fun onEvent(event: MeditationEvent){ fun onEventMainThread(event: MeditationEvent) {
if(event!=null){ if (event != null) {
LogUtil.d("Lancet =====",event.toString()) Glide.with(this)
.load(event.mediaCoverUrl)
.into(iv_bg)
tv_title.text = event.title
tv_content.text = event.desc
shareTitle = event.title
shareContent = event.desc
shareUrl = event.mediaUrl
shareImageUrl = event.mediaCoverUrl
val status = event.status
iv_collect.setImageResource(
if (status == 0) {
R.drawable.icon_play_meditation_collect
} else {
R.drawable.icon_meditation_collected
}
)
if (event.mediaUrl == MediaPlayerManager.getInstance(this)?.getAudioPath()) {
return
}
initMediaPlayer(event.mediaUrl, 0)
} }
} }
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
if(EventBus.getDefault().isRegistered(this)){ if (EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().unregister(this) EventBus.getDefault().unregister(this)
} }
...@@ -641,9 +761,8 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -641,9 +761,8 @@ class PlayMeditationActivity : BaseActivity() {
mTimer.cancel() mTimer.cancel()
} }
private fun stopPlay(){ private fun stopPlay() {
// MediaPlayerManager.getInstance(this).stop()
// MediaPlayerManager.getInstance(this).release()
} }
companion object { companion object {
......
package com.yidianling.muse.helper
import android.view.MotionEvent
import android.view.View
import android.view.WindowManager
class FloatViewTouchListener(val wl: WindowManager.LayoutParams,val windowManager: WindowManager):
View.OnTouchListener{
private var x = 0
private var y = 0
override fun onTouch(view: View, motionEvent: MotionEvent): Boolean {
when (motionEvent.action) {
MotionEvent.ACTION_DOWN -> {
x = motionEvent.rawX.toInt()
y = motionEvent.rawY.toInt()
}
MotionEvent.ACTION_MOVE -> {
val nowX = motionEvent.rawX.toInt()
val nowY = motionEvent.rawY.toInt()
val movedX = nowX - x
val movedY = nowY - y
x = nowX
y = nowY
wl.apply {
x += movedX
y += movedY
}
//更新悬浮窗位置
windowManager.updateViewLayout(view, wl)
}
else -> {
}
}
return false
}
}
\ No newline at end of file
...@@ -21,6 +21,7 @@ class MediaPlayerManager private constructor() { ...@@ -21,6 +21,7 @@ class MediaPlayerManager private constructor() {
} }
} }
fun getMediaPlayer():MediaPlayer = mMediaPlayer
fun getAudioPath():String? = mPath fun getAudioPath():String? = mPath
......
package com.yidianling.muse.helper
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
object MeditationViewModel: ViewModel() {
//悬浮窗口创建 移除 基于无障碍服务
var isShowWindow = MutableLiveData<Boolean>()
//悬浮窗口创建 移除
var isShowSuspendWindow = MutableLiveData<Boolean>()
//悬浮窗口显示 隐藏
var isVisible = MutableLiveData<Boolean>()
}
\ No newline at end of file
...@@ -59,9 +59,11 @@ class ShareMeditationDialog : DialogFragment() { ...@@ -59,9 +59,11 @@ class ShareMeditationDialog : DialogFragment() {
private fun initView(view: View?) { private fun initView(view: View?) {
val imageUrl = "http://static.ydlcdn.com/v1/images/logo320.png"
val shareImageUrl = arguments?.getString(KEY_SHARE_IMAGE_URL) val shareImageUrl = arguments?.getString(KEY_SHARE_IMAGE_URL)?:""
val shareTitle = arguments?.getString(KEY_SHARE_TITLE)?:""
val shareContent = arguments?.getString(KEY_SHARE_CONTENT)?:""
val shareUrl = arguments?.getString(KEY_SHARE_URL)?:""
ivSharePicture = view?.findViewById(R.id.iv_share_picture) ivSharePicture = view?.findViewById(R.id.iv_share_picture)
...@@ -83,10 +85,10 @@ class ShareMeditationDialog : DialogFragment() { ...@@ -83,10 +85,10 @@ class ShareMeditationDialog : DialogFragment() {
ShareUtils.shareTo( ShareUtils.shareTo(
SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN,
activity as Activity, activity as Activity,
"share_title", shareTitle,
"http://www.baidu.com", shareUrl,
"share_context", shareContent,
imageUrl shareImageUrl
) )
dismiss() dismiss()
} }
...@@ -95,10 +97,10 @@ class ShareMeditationDialog : DialogFragment() { ...@@ -95,10 +97,10 @@ class ShareMeditationDialog : DialogFragment() {
ShareUtils.shareTo( ShareUtils.shareTo(
SHARE_MEDIA.WEIXIN_CIRCLE, SHARE_MEDIA.WEIXIN_CIRCLE,
activity as Activity, activity as Activity,
"share_title", shareTitle,
"https://www.baidu.com", shareUrl,
"share_context", shareContent,
imageUrl shareImageUrl
) )
dismiss() dismiss()
} }
...@@ -112,10 +114,10 @@ class ShareMeditationDialog : DialogFragment() { ...@@ -112,10 +114,10 @@ class ShareMeditationDialog : DialogFragment() {
ShareUtils.shareTo( ShareUtils.shareTo(
SHARE_MEDIA.QZONE, SHARE_MEDIA.QZONE,
activity as Activity, activity as Activity,
"share_title", shareTitle,
"http://www.baidu.com", shareUrl,
"share_context", shareContent,
imageUrl shareImageUrl
) )
dismiss() dismiss()
} }
...@@ -124,10 +126,10 @@ class ShareMeditationDialog : DialogFragment() { ...@@ -124,10 +126,10 @@ class ShareMeditationDialog : DialogFragment() {
ShareUtils.shareTo( ShareUtils.shareTo(
SHARE_MEDIA.QQ, SHARE_MEDIA.QQ,
activity as Activity, activity as Activity,
"share_title", shareTitle,
"http://www.baidu.com", shareUrl,
"share_context", shareContent,
imageUrl shareImageUrl
) )
dismiss() dismiss()
} }
...@@ -141,10 +143,16 @@ class ShareMeditationDialog : DialogFragment() { ...@@ -141,10 +143,16 @@ class ShareMeditationDialog : DialogFragment() {
companion object { companion object {
const val TAG = "ShareMeditationDialog" const val TAG = "ShareMeditationDialog"
private const val KEY_SHARE_TITLE = "key_share_title"
private const val KEY_SHARE_URL = "key_share_url"
private const val KEY_SHARE_CONTENT = "key_share_content"
private const val KEY_SHARE_IMAGE_URL = "key_share_image_url" private const val KEY_SHARE_IMAGE_URL = "key_share_image_url"
fun newInstance(shareImageUrl: String): ShareMeditationDialog { fun newInstance(shareTitle:String,shareUrl:String,shareContent:String,shareImageUrl: String): ShareMeditationDialog {
val args = Bundle() val args = Bundle()
args.putString(KEY_SHARE_TITLE, shareTitle)
args.putString(KEY_SHARE_CONTENT, shareContent)
args.putString(KEY_SHARE_URL, shareUrl)
args.putString(KEY_SHARE_IMAGE_URL, shareImageUrl) args.putString(KEY_SHARE_IMAGE_URL, shareImageUrl)
val fragment = ShareMeditationDialog() val fragment = ShareMeditationDialog()
fragment.arguments = args fragment.arguments = args
......
...@@ -484,11 +484,11 @@ public class MineFragment extends BaseFragment implements SwipeRefreshLayout.OnR ...@@ -484,11 +484,11 @@ public class MineFragment extends BaseFragment implements SwipeRefreshLayout.OnR
} }
ModularServiceManager.INSTANCE.provide(ICourseService.class).startMyCourseActivity(mActivity); ModularServiceManager.INSTANCE.provide(ICourseService.class).startMyCourseActivity(mActivity);
} else if (id == R.id.ll_meditation){ //冥想 } else if (id == R.id.ll_meditation){ //冥想
// TODO: 2022/5/6 冥想入口
if (!OneKeyLoginHelp.INSTANCE.startLoginByStatus(mActivity,true)) { if (!OneKeyLoginHelp.INSTANCE.startLoginByStatus(mActivity,true)) {
return; return;
} }
ToastUtil.toastShort("冥想冥想冥想"); H5Params h5Params3 = new H5Params(HttpConfig.Companion.getMH5_URL() + "meditation?hideNavBar=1", null);
NewH5Activity.start(getActivity(), h5Params3);
} else if (id == R.id.ll_call_order) {//倾诉 } else if (id == R.id.ll_call_order) {//倾诉
ActionCountUtils.Companion.count(YDL_USER_MY_MIDDLE_TYPE_CLICK,"倾诉记录"); ActionCountUtils.Companion.count(YDL_USER_MY_MIDDLE_TYPE_CLICK,"倾诉记录");
......
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