Commit a3ad4cce by 范玉宾

meditation collect & meditation play record inter debug to be continue

Took 3 minutes
parent 55086c20
...@@ -68,6 +68,7 @@ dependencies { ...@@ -68,6 +68,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.fragment:fragment-ktx:1.2.4' implementation 'androidx.fragment:fragment-ktx:1.2.4'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation project(path: ':m-user')
testImplementation 'junit:junit:4.13.2' testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
......
package com.yidianling.home package com.yidianling.home
import android.content.Context import android.content.Context
import android.content.Intent
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
...@@ -12,9 +11,9 @@ import androidx.cardview.widget.CardView ...@@ -12,9 +11,9 @@ import androidx.cardview.widget.CardView
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.alibaba.android.arouter.launcher.ARouter import com.alibaba.android.arouter.launcher.ARouter
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.ToastUtil import com.yidianling.common.tools.ToastUtil
import com.yidianling.home.model.bean.MeditationModuleBean import com.yidianling.home.model.bean.MeditationModuleBean
import com.yidianling.user.ui.login.OneKeyLoginHelp
class MeditationTypeAdapter( class MeditationTypeAdapter(
private val context: Context, private val context: Context,
...@@ -53,7 +52,14 @@ class MeditationTypeAdapter( ...@@ -53,7 +52,14 @@ class MeditationTypeAdapter(
holder.tvName?.let { holder.tvName?.let {
it.text = data[position].title it.text = data[position].title
} }
holder.cvLayout?.setOnClickListener { holder.cvLayout?.setOnClickListener {
if (!OneKeyLoginHelp.startLoginByStatus(context, true)) {
return@setOnClickListener
}
ARouter.getInstance().build("/muse/play") ARouter.getInstance().build("/muse/play")
.withLong("MEDITATION_ID",data[position].meditationId) .withLong("MEDITATION_ID",data[position].meditationId)
.withInt("MEDITATION_TYPE",meditationType) .withInt("MEDITATION_TYPE",meditationType)
......
...@@ -63,7 +63,7 @@ dependencies { ...@@ -63,7 +63,7 @@ dependencies {
// solve build problem // solve build problem
// cannot access 'androidx.lifecycle.hasdefaultviewmodelproviderfactory' // cannot access 'androidx.lifecycle.hasdefaultviewmodelproviderfactory'
// Comment out when compiling // Comment out when compiling
// implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
implementation "com.alibaba:arouter-api:$arouter_api" implementation "com.alibaba:arouter-api:$arouter_api"
// 注意此处的依赖方式:kotlin中使用和java中使用方式有不同 // 注意此处的依赖方式:kotlin中使用和java中使用方式有不同
......
...@@ -42,6 +42,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -42,6 +42,7 @@ class PlayMeditationActivity : BaseActivity() {
private var meditationId = 0L private var meditationId = 0L
private var meditationType = 0 private var meditationType = 0
private var mediaId = 0L
private var bgUrl = private var bgUrl =
"https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fcuimianxinli.com%2Fupload%2F2016-07%2F16072613412794.jpg&refer=http%3A%2F%2Fcuimianxinli.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1654150276&t=393628420414c371b4b00540943cf0c7" "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fcuimianxinli.com%2Fupload%2F2016-07%2F16072613412794.jpg&refer=http%3A%2F%2Fcuimianxinli.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1654150276&t=393628420414c371b4b00540943cf0c7"
...@@ -117,6 +118,8 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -117,6 +118,8 @@ class PlayMeditationActivity : BaseActivity() {
val module = it.data val module = it.data
mediaId = module?.mediaId?:0L
val title = module.title ?: "未知标题" val title = module.title ?: "未知标题"
val desc = module.dec ?: "写着人们心疼的曲折,我想我很快乐,做一个旁观者" val desc = module.dec ?: "写着人们心疼的曲折,我想我很快乐,做一个旁观者"
...@@ -152,7 +155,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -152,7 +155,7 @@ class PlayMeditationActivity : BaseActivity() {
} else if (meditationType == 1) { } else if (meditationType == 1) {
MuseHttp.getInstance().getMeditationPlayDetail( MuseHttp.getInstance().getMeditationPlayDetail(
meditionType = 1, meditionType = 1,
mediaId = 1, meditationId = 1 mediaId = mediaId, meditationId = 1
) )
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer { .subscribe(Consumer {
...@@ -233,7 +236,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -233,7 +236,7 @@ class PlayMeditationActivity : BaseActivity() {
MuseHttp.getInstance().collectMeditation(meditationId = meditationId, MuseHttp.getInstance().collectMeditation(meditationId = meditationId,
status = if(collected) 0 else 1) status = if(collected) 0 else 1)
.compose(resultData()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe ({ result -> .subscribe ({ result ->
if (result!=null && result.code == "200"){ if (result!=null && result.code == "200"){
...@@ -321,10 +324,11 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -321,10 +324,11 @@ class PlayMeditationActivity : BaseActivity() {
} }
MuseHttp.getInstance().postMeditationPlayRecord(meditationId = meditationId.toInt(), MuseHttp.getInstance().postMeditationPlayRecord(meditationId = meditationId.toInt(),
playTime = (seekbar_play_progress.progress / 1000.00).roundToInt() isQuit = 0,mediaId = mediaId,
playTime = (seekbar_play_progress.progress / 1000.00).roundToInt(),
).compose(resultData()) isComplete = 0)
.observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ .subscribe({
if (it.code!=null && it.code == "200"){ if (it.code!=null && it.code == "200"){
posted = true posted = true
......
...@@ -9,12 +9,16 @@ data class CollectResultModule( ...@@ -9,12 +9,16 @@ data class CollectResultModule(
data class MeditationCollectRequestModule( data class MeditationCollectRequestModule(
val meditationId: Long, val meditationId: Long,
val status: Int val status: Int,
val businessType:Int
) )
data class MeditationPlayRecordRequestModule( data class MeditationPlayRecordRequestModule(
val meditationId:Int, val meditationId:Int,
val playTime:Int val isQuit:Int,
val mediaId:Long,
val playTime:Int,
val isComplete:Int
) )
data class MeditationPlayRecordResponseModule( data class MeditationPlayRecordResponseModule(
......
package com.yidianling.home.http package com.yidianling.home.http
import com.google.gson.Gson
import com.ydl.ydlcommon.data.http.BaseAPIResponse import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.data.http.BaseResponse import com.ydl.ydlcommon.data.http.BaseResponse
import com.ydl.ydlcommon.data.http.RxUtils import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlnet.YDLHttpUtils import com.ydl.ydlnet.YDLHttpUtils
import com.yidianling.muse.bean.* import com.yidianling.muse.bean.*
import io.reactivex.Observable import io.reactivex.Observable
import okhttp3.MediaType
import okhttp3.RequestBody
/** /**
* @author jiucheng * @author jiucheng
...@@ -62,19 +65,29 @@ class MuseHttp { ...@@ -62,19 +65,29 @@ class MuseHttp {
) )
} }
fun collectMeditation(meditationId:Long,status:Int): Observable<BaseResponse<CollectResultModule>> { fun collectMeditation(meditationId:Long,status:Int): Observable<BaseAPIResponse<CollectResultModule>> {
val params = MeditationCollectRequestModule(meditationId, status) val params = MeditationCollectRequestModule(meditationId, status,1)
return RxUtils.mapObservable(params).flatMap { getMusePagerApi().collectMeditation(it) } var str = Gson().toJson(params)
val body = RequestBody.create(
MediaType.parse("application/json; charset=utf-8"),
str
) as RequestBody
return RxUtils.mapObservable(params).flatMap { getMusePagerApi().collectMeditation(body) }
} }
fun postMeditationPlayRecord(meditationId:Int,playTime:Int): Observable<BaseResponse<MeditationPlayRecordResponseModule>> { fun postMeditationPlayRecord(meditationId:Int,
val params = MeditationPlayRecordRequestModule(meditationId, playTime) isQuit:Int,
return RxUtils.mapObservable(params).flatMap { getMusePagerApi().meditationPlayRecord(it) } mediaId: Long,
playTime:Int,isComplete:Int): Observable<BaseAPIResponse<MeditationPlayRecordResponseModule>> {
val params = MeditationPlayRecordRequestModule(meditationId = meditationId,
isQuit = isQuit,mediaId = mediaId,playTime = playTime,isComplete = isComplete)
var str = Gson().toJson(params)
val body = RequestBody.create(
MediaType.parse("application/json; charset=utf-8"),
str
) as RequestBody
return RxUtils.mapObservable(params).flatMap { getMusePagerApi().meditationPlayRecord(body) }
} }
fun getShareMeditationUrl(meditationId:Int): Observable<BaseResponse<MeditationShareResponseModule>> {
val params = MeditationShareRequestModule(meditationId)
return RxUtils.mapObservable(params).flatMap { getMusePagerApi().shareMeditationInfo(it) }
}
} }
\ No newline at end of file
...@@ -6,6 +6,7 @@ import com.ydl.ydlcommon.data.http.BaseAPIResponse ...@@ -6,6 +6,7 @@ import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.data.http.BaseResponse import com.ydl.ydlcommon.data.http.BaseResponse
import com.yidianling.muse.bean.* import com.yidianling.muse.bean.*
import io.reactivex.Observable import io.reactivex.Observable
import okhttp3.RequestBody
import retrofit2.http.* import retrofit2.http.*
/** /**
...@@ -47,28 +48,18 @@ interface MusePagerApi { ...@@ -47,28 +48,18 @@ interface MusePagerApi {
/** /**
* 收藏和取消收藏 * 收藏和取消收藏
*/ */
@FormUrlEncoded
@POST("cms/meditation/collect") @POST("cms/meditation/collect")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA) @Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA,"Content-Type:application/json")
fun collectMeditation(@FieldMap params: Map<String, String> fun collectMeditation(@Body body: RequestBody): Observable<BaseAPIResponse<CollectResultModule>>
): Observable<BaseResponse<CollectResultModule>>
/** /**
* 冥想播放记录 * 冥想播放记录
*/ */
@FormUrlEncoded
@POST("cms/meditation/playRecord") @POST("cms/meditation/playRecord")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA) @Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA,"Content-Type:application/json")
fun meditationPlayRecord(@FieldMap params: Map<String, String> fun meditationPlayRecord(@Body body: RequestBody
): Observable<BaseResponse<MeditationPlayRecordResponseModule>> ): Observable<BaseAPIResponse<MeditationPlayRecordResponseModule>>
/**
* 生成分享海报
*/
@FormUrlEncoded
@POST("cms/meditation/share")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun shareMeditationInfo(@FieldMap params: Map<String, String>
): Observable<BaseResponse<MeditationShareResponseModule>>
} }
\ 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