Commit 33f5c1d9 by 范玉宾

fix bug

parent 0875cc9f
...@@ -9,12 +9,12 @@ ext { ...@@ -9,12 +9,12 @@ ext {
"m-consultant" : "0.0.60.25", "m-consultant" : "0.0.60.25",
"m-fm" : "0.0.30.08", "m-fm" : "0.0.30.08",
"m-user" : "0.0.62.24", "m-user" : "0.0.62.24",
"m-home" : "0.0.23.75", "m-home" : "0.0.23.76",
"m-im" : "0.0.21.44", "m-im" : "0.0.21.44",
"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.57", "m-muse" : "0.0.28.58",
"m-tests" : "0.0.24.18", "m-tests" : "0.0.24.18",
"m-course" : "0.0.43.37", "m-course" : "0.0.43.37",
...@@ -94,12 +94,12 @@ ext { ...@@ -94,12 +94,12 @@ ext {
"m-consultant" : "0.0.60.25", "m-consultant" : "0.0.60.25",
"m-fm" : "0.0.30.08", "m-fm" : "0.0.30.08",
"m-user" : "0.0.62.24", "m-user" : "0.0.62.24",
"m-home" : "0.0.23.75", "m-home" : "0.0.23.76",
"m-im" : "0.0.21.44", "m-im" : "0.0.21.44",
"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.57", "m-muse" : "0.0.28.58",
"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 层 --------------
......
...@@ -31,10 +31,10 @@ ...@@ -31,10 +31,10 @@
android:focusable="false" android:focusable="false"
android:focusableInTouchMode="false"/> android:focusableInTouchMode="false"/>
<View <ImageView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="#88999999"/> android:src="@drawable/bg_meditation_video"/>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0.5dp" android:layout_height="0.5dp"
android:layout_marginBottom="14dp" android:layout_marginBottom="14dp"
android:background="#66FFFFFF"/> android:background="#33FFFFFF"/>
<androidx.viewpager2.widget.ViewPager2 <androidx.viewpager2.widget.ViewPager2
android:id="@+id/view_pager" android:id="@+id/view_pager"
......
...@@ -36,6 +36,8 @@ import com.yidianling.user.api.service.IUserService ...@@ -36,6 +36,8 @@ import com.yidianling.user.api.service.IUserService
import de.greenrobot.event.EventBus import de.greenrobot.event.EventBus
import io.reactivex.Observable import io.reactivex.Observable
import io.reactivex.Observer import io.reactivex.Observer
import io.reactivex.Scheduler
import io.reactivex.Single
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable import io.reactivex.disposables.Disposable
import io.reactivex.functions.Consumer import io.reactivex.functions.Consumer
...@@ -45,6 +47,7 @@ import kotlinx.android.synthetic.main.activity_play_meditation.iv_close ...@@ -45,6 +47,7 @@ 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.activity_play_meditation.tv_title
import kotlinx.android.synthetic.main.layout_meditation_play_float_view.* 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 org.reactivestreams.Subscription
import java.util.* import java.util.*
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import kotlin.math.roundToInt import kotlin.math.roundToInt
...@@ -85,7 +88,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -85,7 +88,7 @@ class PlayMeditationActivity : BaseActivity() {
private var isSeekbarChanging = false private var isSeekbarChanging = false
private var mDisposable: Disposable? = null private var mDisposable: Disposable? = null
private var mObservable: Observable<Long>? = null private lateinit var mObservable: Observable<Long>
private var mObserver: Observer<Long>? = null private var mObserver: Observer<Long>? = null
private var mBuried: String? = null private var mBuried: String? = null
...@@ -828,20 +831,25 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -828,20 +831,25 @@ class PlayMeditationActivity : BaseActivity() {
tv_time_off_pure_music.visibility = View.VISIBLE tv_time_off_pure_music.visibility = View.VISIBLE
tv_time_off.visibility = View.GONE tv_time_off.visibility = View.GONE
mDisposable?.dispose() mDisposable?.dispose()
mDisposable = null
MediaPlayerManager.getInstance(this)?.setTimeOffStatus(true)
initRxTimeOff((minute * 60 * 1000).toLong(), 0) initRxTimeOff((minute * 60 * 1000).toLong(), 0)
} else { } else {
initPlayCompletionListener(isLoop = true, isSingle = false) initPlayCompletionListener(isLoop = true, isSingle = false)
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()
mDisposable = null
MediaPlayerManager.getInstance(this)?.setTimeOffStatus(true)
initRxTimeOff((minute * 60 * 1000).toLong(), 1) initRxTimeOff((minute * 60 * 1000).toLong(), 1)
} }
val event = MeditationFloatEvent(false,time = (minute * 60 * 1000).toLong()) val event = MeditationFloatEvent(false,time = (minute * 60 * 1000).toLong())
EventBus.getDefault().post(event) EventBus.getDefault().post(event)
} else { } else {
initPlayCompletionListener() initPlayCompletionListener()
MediaPlayerManager.getInstance(this)?.dispose() MediaPlayerManager.getInstance(this)?.setTimeOffStatus(false)
mDisposable?.dispose() mDisposable?.dispose()
mDisposable = null
tv_time_off.visibility = View.GONE tv_time_off.visibility = View.GONE
tv_time_off_pure_music.visibility = View.GONE tv_time_off_pure_music.visibility = View.GONE
mMediaPlayer?.isLooping = false mMediaPlayer?.isLooping = false
...@@ -866,13 +874,12 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -866,13 +874,12 @@ class PlayMeditationActivity : BaseActivity() {
} }
) )
val timeOff = MediaPlayerManager.getInstance(this)?.getTimeOff() if(MediaPlayerManager.getInstance(this)?.getTimeOffStatus() == true){
if (timeOff!=null && timeOff>0 && mMeditationType!=null){ val timeOff = MediaPlayerManager.getInstance(this)?.getTimeOff()
mDisposable?.dispose() if (timeOff!=null && timeOff>0 && mMeditationType!=null){
initRxTimeOff(timeOff, mMeditationType!!) initRxTimeOff(timeOff, mMeditationType!!)
}
} }
} }
private fun initRxTimeOff(time: Long, meditationType: Int) { private fun initRxTimeOff(time: Long, meditationType: Int) {
...@@ -899,7 +906,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -899,7 +906,7 @@ class PlayMeditationActivity : BaseActivity() {
} }
override fun onError(e: Throwable) { override fun onError(e: Throwable) {
mDisposable?.dispose()
} }
override fun onComplete() { override fun onComplete() {
...@@ -917,7 +924,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -917,7 +924,7 @@ class PlayMeditationActivity : BaseActivity() {
} }
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>) {
......
...@@ -21,6 +21,7 @@ class MediaPlayerManager private constructor() { ...@@ -21,6 +21,7 @@ class MediaPlayerManager private constructor() {
private var mMediaId:Long? = null private var mMediaId:Long? = null
private var mTime = 0L private var mTime = 0L
private var mTimeOffStatus = false
private var mDisposable:Disposable? = null private var mDisposable:Disposable? = null
private var mObservable: Observable<Long>? = null private var mObservable: Observable<Long>? = null
...@@ -34,6 +35,16 @@ class MediaPlayerManager private constructor() { ...@@ -34,6 +35,16 @@ class MediaPlayerManager private constructor() {
fun getTimeOff():Long = mTime fun getTimeOff():Long = mTime
fun getTimeOffStatus():Boolean = mTimeOffStatus
fun setTimeOffStatus(timeOffStatus:Boolean){
mTimeOffStatus = timeOffStatus
}
fun setTimeOff(time:Long){
mTime = time
}
fun setAudioPath(path: String,isLoop:Boolean = false){ fun setAudioPath(path: String,isLoop:Boolean = false){
val attrs = AudioAttributes.Builder() val attrs = AudioAttributes.Builder()
...@@ -88,13 +99,7 @@ class MediaPlayerManager private constructor() { ...@@ -88,13 +99,7 @@ class MediaPlayerManager private constructor() {
fun initRxTimeOff(time: Long) { fun initRxTimeOff(time: Long) {
if (time ==null && time <=0){ if (time ==null && time <=0){
if (mObserver != null && mObserver is Observer<Long>) { mDisposable?.dispose()
mObservable?.subscribe(mObserver as Observer<Long>)
}
if (mDisposable?.isDisposed == true && mObserver != null && mObserver is Observer<Long>) {
mObservable?.subscribe(mObserver as Observer<Long>)
}
} }
mObservable = Observable.interval(0, 1, TimeUnit.SECONDS) mObservable = Observable.interval(0, 1, TimeUnit.SECONDS)
...@@ -132,6 +137,7 @@ class MediaPlayerManager private constructor() { ...@@ -132,6 +137,7 @@ class MediaPlayerManager private constructor() {
} }
fun dispose() { fun dispose() {
mTime = 0
mDisposable?.dispose() mDisposable?.dispose()
} }
......
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
<corners android:radius="12dp" /> <corners android:radius="12dp" />
<solid android:color="#99000000" /> <solid android:color="#CC000000" />
</shape> </shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginTop="150dp" android:layout_marginTop="150dp"
android:background="@drawable/shape_bg_solid_282e3f_r_top_20"> android:background="@drawable/shape_bg_solid_282e3f_r_top_20">
<WebView <androidx.cardview.widget.CardView
android:id="@+id/wv_choose_music"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="#282E3F" android:layout_marginBottom="-20dp"
android:scrollbars="none" /> app:cardCornerRadius="20dp">
<LinearLayout <FrameLayout
android:id="@+id/ll_close" android:layout_width="match_parent"
android:layout_width="match_parent" android:layout_height="match_parent">
android:gravity="center_horizontal"
android:layout_height="38dp"> <WebView
android:id="@+id/wv_choose_music"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#282E3F"
android:scrollbars="none" />
<LinearLayout
android:id="@+id/ll_close"
android:layout_width="match_parent"
android:gravity="center_horizontal"
android:layout_height="38dp">
<ImageView
android:layout_width="24dp"
android:layout_height="10dp"
android:src="@drawable/ic_close_choose_music"
android:layout_marginTop="12dp" />
</LinearLayout>
<ImageView </FrameLayout>
android:layout_width="24dp"
android:layout_height="10dp"
android:src="@drawable/ic_close_choose_music"
android:layout_marginTop="12dp" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</FrameLayout> </FrameLayout>
\ No newline at end of file
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