Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
a3ad4cce
Commit
a3ad4cce
authored
May 18, 2022
by
范玉宾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
meditation collect & meditation play record inter debug to be continue
Took 3 minutes
parent
55086c20
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
56 additions
and
39 deletions
+56
-39
build.gradle
m-home/build.gradle
+1
-0
MeditationTypeAdapter.kt
m-home/src/main/java/com/yidianling/home/MeditationTypeAdapter.kt
+8
-2
build.gradle
m-muse/build.gradle
+1
-1
PlayMeditationActivity.kt
m-muse/src/main/java/com/yidianling/muse/activity/PlayMeditationActivity.kt
+10
-6
MeditationModule.kt
m-muse/src/main/java/com/yidianling/muse/bean/MeditationModule.kt
+6
-2
MuseHttp.kt
m-muse/src/main/java/com/yidianling/muse/http/MuseHttp.kt
+23
-11
MusePagerApi.kt
m-muse/src/main/java/com/yidianling/muse/http/MusePagerApi.kt
+7
-17
No files found.
m-home/build.gradle
View file @
a3ad4cce
...
...
@@ -68,6 +68,7 @@ dependencies {
implementation
'androidx.appcompat:appcompat:1.2.0'
implementation
'androidx.fragment:fragment-ktx:1.2.4'
implementation
"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation
project
(
path:
':m-user'
)
testImplementation
'junit:junit:4.13.2'
androidTestImplementation
'androidx.test.ext:junit:1.1.2'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.3.0'
...
...
m-home/src/main/java/com/yidianling/home/MeditationTypeAdapter.kt
View file @
a3ad4cce
package
com.yidianling.home
import
android.content.Context
import
android.content.Intent
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
...
...
@@ -12,9 +11,9 @@ import androidx.cardview.widget.CardView
import
androidx.recyclerview.widget.RecyclerView
import
com.alibaba.android.arouter.launcher.ARouter
import
com.bumptech.glide.Glide
import
com.yidianling.common.tools.LogUtil
import
com.yidianling.common.tools.ToastUtil
import
com.yidianling.home.model.bean.MeditationModuleBean
import
com.yidianling.user.ui.login.OneKeyLoginHelp
class
MeditationTypeAdapter
(
private
val
context
:
Context
,
...
...
@@ -53,7 +52,14 @@ class MeditationTypeAdapter(
holder
.
tvName
?.
let
{
it
.
text
=
data
[
position
].
title
}
holder
.
cvLayout
?.
setOnClickListener
{
if
(!
OneKeyLoginHelp
.
startLoginByStatus
(
context
,
true
))
{
return
@setOnClickListener
}
ARouter
.
getInstance
().
build
(
"/muse/play"
)
.
withLong
(
"MEDITATION_ID"
,
data
[
position
].
meditationId
)
.
withInt
(
"MEDITATION_TYPE"
,
meditationType
)
...
...
m-muse/build.gradle
View file @
a3ad4cce
...
...
@@ -63,7 +63,7 @@ dependencies {
// solve build problem
// cannot access 'androidx.lifecycle.hasdefaultviewmodelproviderfactory'
// 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"
// 注意此处的依赖方式:kotlin中使用和java中使用方式有不同
...
...
m-muse/src/main/java/com/yidianling/muse/activity/PlayMeditationActivity.kt
View file @
a3ad4cce
...
...
@@ -42,6 +42,7 @@ class PlayMeditationActivity : BaseActivity() {
private
var
meditationId
=
0L
private
var
meditationType
=
0
private
var
mediaId
=
0L
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"
...
...
@@ -117,6 +118,8 @@ class PlayMeditationActivity : BaseActivity() {
val
module
=
it
.
data
mediaId
=
module
?.
mediaId
?:
0L
val
title
=
module
.
title
?:
"未知标题"
val
desc
=
module
.
dec
?:
"写着人们心疼的曲折,我想我很快乐,做一个旁观者"
...
...
@@ -152,7 +155,7 @@ class PlayMeditationActivity : BaseActivity() {
}
else
if
(
meditationType
==
1
)
{
MuseHttp
.
getInstance
().
getMeditationPlayDetail
(
meditionType
=
1
,
mediaId
=
1
,
meditationId
=
1
mediaId
=
mediaId
,
meditationId
=
1
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
Consumer
{
...
...
@@ -233,7 +236,7 @@ class PlayMeditationActivity : BaseActivity() {
MuseHttp
.
getInstance
().
collectMeditation
(
meditationId
=
meditationId
,
status
=
if
(
collected
)
0
else
1
)
.
compose
(
resultData
())
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
({
result
->
if
(
result
!=
null
&&
result
.
code
==
"200"
){
...
...
@@ -321,10 +324,11 @@ class PlayMeditationActivity : BaseActivity() {
}
MuseHttp
.
getInstance
().
postMeditationPlayRecord
(
meditationId
=
meditationId
.
toInt
(),
playTime
=
(
seekbar_play_progress
.
progress
/
1000.00
).
roundToInt
()
).
compose
(
resultData
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
isQuit
=
0
,
mediaId
=
mediaId
,
playTime
=
(
seekbar_play_progress
.
progress
/
1000.00
).
roundToInt
(),
isComplete
=
0
)
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
({
if
(
it
.
code
!=
null
&&
it
.
code
==
"200"
){
posted
=
true
...
...
m-muse/src/main/java/com/yidianling/muse/bean/MeditationModule.kt
View file @
a3ad4cce
...
...
@@ -9,12 +9,16 @@ data class CollectResultModule(
data class
MeditationCollectRequestModule
(
val
meditationId
:
Long
,
val
status
:
Int
val
status
:
Int
,
val
businessType
:
Int
)
data class
MeditationPlayRecordRequestModule
(
val
meditationId
:
Int
,
val
playTime
:
Int
val
isQuit
:
Int
,
val
mediaId
:
Long
,
val
playTime
:
Int
,
val
isComplete
:
Int
)
data class
MeditationPlayRecordResponseModule
(
...
...
m-muse/src/main/java/com/yidianling/muse/http/MuseHttp.kt
View file @
a3ad4cce
package
com.yidianling.home.http
import
com.google.gson.Gson
import
com.ydl.ydlcommon.data.http.BaseAPIResponse
import
com.ydl.ydlcommon.data.http.BaseResponse
import
com.ydl.ydlcommon.data.http.RxUtils
import
com.ydl.ydlnet.YDLHttpUtils
import
com.yidianling.muse.bean.*
import
io.reactivex.Observable
import
okhttp3.MediaType
import
okhttp3.RequestBody
/**
* @author jiucheng
...
...
@@ -62,19 +65,29 @@ class MuseHttp {
)
}
fun
collectMeditation
(
meditationId
:
Long
,
status
:
Int
):
Observable
<
BaseResponse
<
CollectResultModule
>>
{
val
params
=
MeditationCollectRequestModule
(
meditationId
,
status
)
return
RxUtils
.
mapObservable
(
params
).
flatMap
{
getMusePagerApi
().
collectMeditation
(
it
)
}
fun
collectMeditation
(
meditationId
:
Long
,
status
:
Int
):
Observable
<
BaseAPIResponse
<
CollectResultModule
>>
{
val
params
=
MeditationCollectRequestModule
(
meditationId
,
status
,
1
)
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
>>
{
val
params
=
MeditationPlayRecordRequestModule
(
meditationId
,
playTime
)
return
RxUtils
.
mapObservable
(
params
).
flatMap
{
getMusePagerApi
().
meditationPlayRecord
(
it
)
}
fun
postMeditationPlayRecord
(
meditationId
:
Int
,
isQuit
:
Int
,
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
m-muse/src/main/java/com/yidianling/muse/http/MusePagerApi.kt
View file @
a3ad4cce
...
...
@@ -6,6 +6,7 @@ import com.ydl.ydlcommon.data.http.BaseAPIResponse
import
com.ydl.ydlcommon.data.http.BaseResponse
import
com.yidianling.muse.bean.*
import
io.reactivex.Observable
import
okhttp3.RequestBody
import
retrofit2.http.*
/**
...
...
@@ -47,28 +48,18 @@ interface MusePagerApi {
/**
* 收藏和取消收藏
*/
@FormUrlEncoded
@POST
(
"cms/meditation/collect"
)
@Headers
(
YDL_DOMAIN
+
YDL_DOMAIN_JAVA
)
fun
collectMeditation
(
@FieldMap
params
:
Map
<
String
,
String
>
):
Observable
<
BaseResponse
<
CollectResultModule
>>
@Headers
(
YDL_DOMAIN
+
YDL_DOMAIN_JAVA
,
"Content-Type:application/json"
)
fun
collectMeditation
(
@Body
body
:
RequestBody
):
Observable
<
BaseAPIResponse
<
CollectResultModule
>>
/**
* 冥想播放记录
*/
@FormUrlEncoded
@POST
(
"cms/meditation/playRecord"
)
@Headers
(
YDL_DOMAIN
+
YDL_DOMAIN_JAVA
)
fun
meditationPlayRecord
(
@FieldMap
params
:
Map
<
String
,
String
>
):
Observable
<
BaseResponse
<
MeditationPlayRecordResponseModule
>>
@Headers
(
YDL_DOMAIN
+
YDL_DOMAIN_JAVA
,
"Content-Type:application/json"
)
fun
meditationPlayRecord
(
@Body
body
:
RequestBody
):
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment