Commit 33f5c1d9 by 范玉宾

fix bug

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