Commit a5f63d1f by 范玉宾

meditation/index inter debug done

parent 390ba8e0
......@@ -11,10 +11,11 @@ import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.yidianling.common.tools.ToastUtil
import com.yidianling.home.model.MeditationTypeModel
import com.yidianling.home.model.bean.MeditationModuleBean
class MeditationTypeAdapter(
private val context: Context,
private val data: List<MeditationTypeModel>
private val data: List<MeditationModuleBean.MeditationDetail>
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
......@@ -42,12 +43,12 @@ class MeditationTypeAdapter(
is MeditationTypeViewHolder -> {
holder.ivType?.let {
Glide.with(context)
.load(data[position].imageUrl)
.load(data[position].coverImageUrl)
.into(it)
}
holder.tvName?.let {
it.text = data[position].name
it.text = data[position].title
}
}
is MeditationTypeMoreViewHolder -> {
......@@ -66,7 +67,7 @@ class MeditationTypeAdapter(
override fun getItemId(position: Int) = position.toLong()
override fun getItemViewType(position: Int): Int {
val isMore = data[position].isMore
val isMore = false
return if (isMore) {
FOOTER_TYPE
} else {
......
......@@ -7,9 +7,10 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.yidianling.home.model.MeditationTypeModel
import com.yidianling.home.model.bean.MeditationModuleBean
class MeditationViewPagerAdapter(private val context: Context, private val data:
List<List<MeditationTypeModel>>)
MeditationModuleBean)
:RecyclerView.Adapter<MeditationViewPagerAdapter.MeditationViewPagerViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MeditationViewPagerViewHolder {
......@@ -20,12 +21,16 @@ class MeditationViewPagerAdapter(private val context: Context, private val data:
override fun onBindViewHolder(holder: MeditationViewPagerViewHolder, position: Int) {
holder.rv?.also { rv->
rv.layoutManager = LinearLayoutManager(context,LinearLayoutManager.HORIZONTAL,false)
rv.adapter = MeditationTypeAdapter(context,data[position])
rv.adapter =
data.mditationListResponse?.get(position)?.let {
MeditationTypeAdapter(context,
it.mditationResponseList)
}
}
}
override fun getItemCount(): Int {
return data.size
return data.mditationListResponse?.size?:0
}
inner class MeditationViewPagerViewHolder(itemView: View):RecyclerView.ViewHolder(itemView){
......
......@@ -178,5 +178,6 @@ class IHomeBaseContract {
* 首页问答 - 关注
*/
fun askFocus(id: String): Observable<AskResultBean>
}
}
\ No newline at end of file
......@@ -101,4 +101,5 @@ class HomeBaseHttp {
val cmd = AskRequestParamBean.FocusCmd(id, "1")
return RxUtils.mapObservable(cmd).flatMap { getHomePagerApi().askFocus(it) }
}
}
\ No newline at end of file
......@@ -87,4 +87,6 @@ open class BaseHomeModelImpl : IHomeBaseContract.Model {
return HomeBaseHttp.getInstance().newHomeHeaderRequest().compose(RxUtils.resultJavaData())
.onErrorReturn { HomeHeaderBean(true) }
}
}
\ No newline at end of file
......@@ -53,6 +53,12 @@ class HomePagerDataBean() {
* 冥想模块数据
*/
var museBean: MuseModuleBean? = null
/**
* 冥想改版
*/
var meditationBean:MeditationModuleBean?=null
/**
* 电台模块数据
*/
......
package com.yidianling.home.model.bean
/**
* 冥想模块所有数据
* Created by xj on 2019/9/16.
*/
class MeditationModuleBean : HomeItemBaseBean {
constructor():super(false)
constructor(isRealEmpty:Boolean):super(isRealEmpty)
var meditationIndexInfo:MeditationSlogan? = null
data class MeditationSlogan(
val greetings:String?=null,
val mditationDay:Int = 0,
val desc:String?=null,
val videoLink:String?=null,
val uid:Int
)
/**
* 冥想数据
*/
var mditationListResponse: ArrayList<MeditationList>? = null
data class MeditationList(
val comment:String,
val meditionType:Int,
val cateId:Long,
val mditationResponseList:ArrayList<MeditationDetail>
)
data class MeditationDetail(
val meditationId:Int,
val title:String,
val coverImageUrl:String,
val tagId:Int
)
}
\ No newline at end of file
......@@ -228,7 +228,7 @@ class YdlHomeAdapter(private val mContext: Context,
}
//壹点*冥想模块
is HomeMuseViewHolder -> {
holder.museViewView.initData(list[holder.viewType].museBean)
holder.museViewView.initData(list[holder.viewType].meditationBean)
}
//心灵*电台模块
is HomeIntelligentViewHolder -> {
......
package com.yidianling.home.constract
import com.yidianling.home.constants.IHomeBaseContract
import com.yidianling.home.model.bean.MeditationModuleBean
import com.yidianling.home.model.bean.MuseModuleBean
import io.reactivex.Observable
......@@ -20,5 +21,7 @@ class IHomeContract {
* 首页冥想请求
*/
fun museRequest(): Observable<MuseModuleBean>
fun getMeditation():Observable<MeditationModuleBean>
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.yidianling.home.http
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlnet.YDLHttpUtils
import com.yidianling.home.model.bean.MeditationModuleBean
import com.yidianling.home.model.bean.MuseModuleBean
import io.reactivex.Observable
......@@ -37,4 +38,9 @@ class HomeHttp {
fun newMuseRequest(): Observable<BaseAPIResponse<MuseModuleBean>> {
return getHomePagerApi().getMuseData()
}
fun getMeditationInfo():Observable<BaseAPIResponse<MeditationModuleBean>>{
return getHomePagerApi().getMeditation()
}
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ package com.yidianling.home.http
import com.ydl.ydlcommon.base.config.YDL_DOMAIN
import com.ydl.ydlcommon.base.config.YDL_DOMAIN_JAVA
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.yidianling.home.model.bean.MeditationModuleBean
import com.yidianling.home.model.bean.MuseModuleBean
import io.reactivex.Observable
import retrofit2.http.GET
......@@ -21,4 +22,9 @@ interface HomePagerApi {
@GET("meditation/meditation/list")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun getMuseData(): Observable<BaseAPIResponse<MuseModuleBean>>
@GET("cms/meditation/index")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun getMeditation(): Observable<BaseAPIResponse<MeditationModuleBean>>
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ package com.yidianling.home.model
import com.ydl.ydlcommon.data.http.RxUtils
import com.yidianling.home.constract.IHomeContract
import com.yidianling.home.http.HomeHttp
import com.yidianling.home.model.bean.MeditationModuleBean
import com.yidianling.home.model.bean.MuseModuleBean
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
......@@ -26,5 +27,11 @@ class HomeModelImpl : BaseHomeModelImpl(), IHomeContract.Model {
.onErrorReturn { MuseModuleBean(true) }
}
override fun getMeditation(): Observable<MeditationModuleBean> {
return HomeHttp.getInstance().getMeditationInfo().compose(RxUtils.resultJavaData())
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.onErrorReturn { MeditationModuleBean(true) }
}
}
\ No newline at end of file
......@@ -112,6 +112,12 @@ class HomePresenterImpl: BaseHomePresenterImpl<IHomeContract.View, IHomeContract
homeList.add(getHomeItemFromTempData(it, HomeViewConfig.getOrder().museIndex!!))
}
val meditationObservable = mModel.getMeditation()
.compose(RxUtils.applySchedulers(mView)).map {
homeList.add(getHomeItemFromTempData(it,HomeViewConfig.getOrder().museIndex!!))
}
val fmObservable = mModel.fmRequest()
.compose(RxUtils.applySchedulers(mView)).map {
//首页电台数据
......@@ -134,6 +140,7 @@ class HomePresenterImpl: BaseHomePresenterImpl<IHomeContract.View, IHomeContract
if (HomeViewConfig.getOrder().bannerIndex!=null){
mergeArrays.add(headerObservable)
}
if (HomeViewConfig.getOrder().consultIndex!=null){
mergeArrays.add(consultObservable)
}
......@@ -150,8 +157,11 @@ class HomePresenterImpl: BaseHomePresenterImpl<IHomeContract.View, IHomeContract
mergeArrays.add(askObservable)
}
if (HomeViewConfig.getOrder().museIndex!=null){
mergeArrays.add(museObservable)
mergeArrays.add(meditationObservable)
}
// if (HomeViewConfig.getOrder().museIndex!=null){
// mergeArrays.add(museObservable)
// }
if (HomeViewConfig.getOrder().fmIndex!=null){
mergeArrays.add(fmObservable)
}
......@@ -297,9 +307,13 @@ class HomePresenterImpl: BaseHomePresenterImpl<IHomeContract.View, IHomeContract
if (dataBean.isRealEmpty || dataBean !is HomeAskBean) homeTempData.askBean else dataBean
mHomeAskBean = item.askBean
}
// HomeViewConfig.getOrder().museIndex -> {
// item.museBean =
// if (dataBean.isRealEmpty || dataBean !is MuseModuleBean) homeTempData.museBean else dataBean
// }
HomeViewConfig.getOrder().museIndex -> {
item.museBean =
if (dataBean.isRealEmpty || dataBean !is MuseModuleBean) homeTempData.museBean else dataBean
item.meditationBean =
if (dataBean.isRealEmpty || dataBean !is MeditationModuleBean) homeTempData.meditationBean else dataBean
}
HomeViewConfig.getOrder().fmIndex -> {
item.fmBean =
......
......@@ -20,6 +20,7 @@ import com.yidianling.home.R
import com.yidianling.home.constract.HomeViewConfig
import com.yidianling.home.event.IHomeEvent
import com.yidianling.home.model.MeditationTypeModel
import com.yidianling.home.model.bean.MeditationModuleBean
import com.yidianling.home.model.bean.MuseModuleBean
import kotlinx.android.synthetic.ydl.home_muse_view.view.*
......@@ -35,7 +36,7 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
private var cacheList: ArrayList<HomeMuseView> = ArrayList()
private val meditationTitles = arrayOf("睡眠","冥想","治愈")
private val meditationTitles = mutableListOf<String>()
init {
initView()
......@@ -53,7 +54,7 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
homeModuleMuseViewHomeCommonTitleView.setTitle(HomeViewConfig.getOrder().museTitle)
}
fun initData(bean: MuseModuleBean?) {
fun initData(bean: MeditationModuleBean?) {
if (null != bean) {
......@@ -62,56 +63,23 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
homeEvent?.museMoreClick(Gson().toJson(bean))
}
if (null != bean.muses) {
if (bean.muses?.size!! > 0) {
muse_first.setOnClickListener {
homeEvent?.museClick(bean.muses!![0].audioUrl, dataJson,muse_first_text.text.toString())
}
}
if (bean.muses?.size!! > 1) {
muse_second.setOnClickListener {
homeEvent?.museClick(bean.muses!![1].audioUrl, dataJson,muse_second_text.text.toString())
}
val greeting = bean?.meditationIndexInfo?.greetings?:"你好"
tv_time.text = greeting
val slogan =
if (bean?.meditationIndexInfo?.mditationDay==null){
"无常的日子里,呼吸间拾起力量"
}else{
"已连续冥想${bean?.meditationIndexInfo?.mditationDay}天"
}
if (bean.muses?.size!! > 2) {
muse_third.setOnClickListener {
homeEvent?.museClick(bean.muses!![2].audioUrl, dataJson,muse_third_text.text.toString())
}
}
if (bean.muses?.size!! > 3) {
muse_forth.setOnClickListener {
homeEvent?.museClick(bean.muses!![3].audioUrl, dataJson,muse_forth_text.text.toString())
}
}
}
if (null != bean.sleeps) {
if (bean.sleeps?.size!! > 0) {
sleeps_first.setOnClickListener {
homeEvent?.museClick(bean.sleeps!![0].audioUrl, dataJson,sleeps_first_text.text.toString())
}
}
if (bean.sleeps?.size!! > 1) {
sleeps_second.setOnClickListener {
homeEvent?.museClick(bean.sleeps!![1].audioUrl, dataJson,sleeps_second_text.toString())
}
}
if (bean.sleeps?.size!! > 2) {
sleeps_third.setOnClickListener {
homeEvent?.museClick(bean.sleeps!![2].audioUrl, dataJson,sleeps_third_text.text.toString())
}
}
if (bean.sleeps?.size!! > 3) {
sleeps_forth.setOnClickListener {
homeEvent?.museClick(bean.sleeps!![3].audioUrl, dataJson,sleeps_forth_text.text.toString())
}
}
}
tv_meditation_slogan.text = slogan
val videoUrl = bean?.meditationIndexInfo?.videoLink?:"http://www.w3school.com.cn/example/html5/mov_bbb.mp4"
GlideApp.with(this)
.load("http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")
.load(videoUrl)
.into(iv_video_background)
video_view?.setVideoPath("http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")
video_view?.setVideoPath(videoUrl)
video_view?.setOnPreparedListener {
it?.setVideoScalingMode(MediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING)
......@@ -126,7 +94,6 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
}
video_view?.setOnCompletionListener { video_view?.start() }
val data = mutableListOf<List<MeditationTypeModel>>()
val innerData = mutableListOf<MeditationTypeModel>()
......@@ -152,9 +119,12 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
data.add(innerData)
}
bean?.mditationListResponse?.forEach {
meditationTitles.add(it.comment)
}
view_pager.adapter = MeditationViewPagerAdapter(
mContext,data)
view_pager.adapter = MeditationViewPagerAdapter(mContext,bean)
tab_layout.addOnTabSelectedListener(object :TabLayout.OnTabSelectedListener{
override fun onTabSelected(tab: TabLayout.Tab?) {
......
......@@ -50,7 +50,7 @@
android:layout_marginStart="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:text="下午好"
tools:text="下午好"
android:textColor="@color/white"
android:textStyle="bold"
android:textSize="24sp" />
......@@ -66,7 +66,6 @@
app:layout_constraintStart_toStartOf="@id/tv_time"
app:layout_constraintTop_toBottomOf="@id/tv_time" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="150dp"
......@@ -76,7 +75,7 @@
<com.google.android.material.tabs.TabLayout
android:id="@+id/tab_layout"
android:layout_width="160dp"
android:layout_width="200dp"
android:layout_height="40dp"
android:layout_marginBottom="14dp"
style="@style/MeditationTabLayoutStyle" />
......@@ -90,331 +89,8 @@
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
</androidx.cardview.widget.CardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="88dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<androidx.cardview.widget.CardView
android:id="@+id/muse_first"
android:layout_width="0dp"
android:layout_height="78dp"
android:layout_marginLeft="@dimen/platform_dp_15"
android:layout_marginRight="5dp"
android:layout_weight="1"
app:cardElevation="0dp"
app:cardCornerRadius="@dimen/platform_dp_4">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/home_muse_first_img" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="13dp"
android:gravity="center_vertical"
android:layout_marginRight="@dimen/platform_dp_15"
android:orientation="horizontal">
<TextView
android:id="@+id/muse_first_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="深度睡眠"
android:maxLines="1"
android:ellipsize="end"
android:textColor="@color/platform_black"
android:textSize="@dimen/platform_dp_16" />
<ImageView
android:layout_width="18dp"
android:layout_height="@dimen/platform_dp_18"
android:layout_marginLeft="@dimen/platform_dp_4"
android:src="@drawable/home_muse_play" />
</LinearLayout>
</RelativeLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/muse_second"
android:layout_width="0dp"
android:layout_height="78dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="@dimen/platform_dp_15"
android:layout_weight="1"
app:cardElevation="0dp"
app:cardCornerRadius="@dimen/platform_dp_4">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/muse_animation_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:lottie_autoPlay="true"
app:lottie_loop="true"
app:lottie_imageAssetsFolder="images"
app:lottie_fileName="pinna.json"
android:scaleType="centerCrop" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="@dimen/platform_dp_15"
android:layout_marginTop="13dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/muse_second_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="节奏调整"
android:maxLines="1"
android:ellipsize="end"
android:textColor="@color/platform_black"
android:textSize="@dimen/platform_dp_16" />
<ImageView
android:layout_width="18dp"
android:layout_height="@dimen/platform_dp_18"
android:layout_marginLeft="@dimen/platform_dp_4"
android:src="@drawable/home_muse_play" />
</LinearLayout>
</RelativeLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="88dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<androidx.cardview.widget.CardView
android:id="@+id/muse_third"
android:layout_width="0dp"
android:layout_height="78dp"
android:layout_marginLeft="@dimen/platform_dp_15"
android:layout_marginRight="5dp"
android:layout_weight="1"
app:cardElevation="0dp"
app:cardCornerRadius="@dimen/platform_dp_4">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/home_muse_third_img" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="@dimen/platform_dp_15"
android:layout_marginTop="13dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/muse_third_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="身体扫描"
android:maxLines="1"
android:ellipsize="end"
android:textColor="@color/platform_black"
android:textSize="@dimen/platform_dp_16" />
<ImageView
android:layout_width="18dp"
android:layout_height="@dimen/platform_dp_18"
android:layout_marginLeft="@dimen/platform_dp_4"
android:src="@drawable/home_muse_play" />
</LinearLayout>
</RelativeLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/muse_forth"
android:layout_width="0dp"
android:layout_height="78dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="@dimen/platform_dp_15"
android:layout_weight="1"
app:cardElevation="0dp"
app:cardCornerRadius="@dimen/platform_dp_4">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/home_muse_fouth_img" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="@dimen/platform_dp_15"
android:layout_marginTop="13dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/muse_forth_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="压力缓冲"
android:maxLines="1"
android:ellipsize="end"
android:textColor="@color/platform_black"
android:textSize="@dimen/platform_dp_16" />
<ImageView
android:layout_width="18dp"
android:layout_height="@dimen/platform_dp_18"
android:layout_marginLeft="@dimen/platform_dp_4"
android:src="@drawable/home_muse_play" />
</LinearLayout>
</RelativeLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/platform_dp_7"
android:orientation="horizontal"
android:paddingLeft="6.5dp"
android:paddingRight="6.5dp"
android:layout_marginBottom="16dp">
<RelativeLayout
android:id="@+id/sleeps_first"
android:layout_width="0dp"
android:layout_height="80dp"
android:layout_weight="1">
<com.ydl.ydlcommon.view.widgets.RoundImageView
android:layout_width="72dp"
android:layout_height="72dp"
android:scaleType="centerCrop"
android:src="@drawable/home_muse_circle_first"
android:layout_centerInParent="true"
app:pa_type="pa_circle" />
<TextView
android:id="@+id/sleeps_first_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="篝火"
android:textColor="@color/platform_black"
android:textSize="@dimen/platform_dp_14"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/sleeps_second"
android:layout_width="0dp"
android:layout_height="80dp"
android:layout_weight="1">
<com.ydl.ydlcommon.view.widgets.RoundImageView
android:layout_width="72dp"
android:layout_height="72dp"
android:scaleType="centerCrop"
android:src="@drawable/home_muse_circle_second"
android:layout_centerInParent="true"
app:pa_type="pa_circle" />
<TextView
android:id="@+id/sleeps_second_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="溪流"
android:textColor="@color/platform_black"
android:textSize="@dimen/platform_dp_14"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/sleeps_third"
android:layout_width="0dp"
android:layout_height="80dp"
android:layout_weight="1">
<com.ydl.ydlcommon.view.widgets.RoundImageView
android:layout_width="72dp"
android:layout_height="72dp"
android:scaleType="centerCrop"
android:src="@drawable/home_muse_circle_third"
android:layout_centerInParent="true"
app:pa_type="pa_circle" />
<TextView
android:id="@+id/sleeps_third_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="风声"
android:textColor="@color/platform_black"
android:textSize="@dimen/platform_dp_14"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/sleeps_forth"
android:layout_width="0dp"
android:layout_height="80dp"
android:layout_weight="1">
<com.ydl.ydlcommon.view.widgets.RoundImageView
android:layout_width="72dp"
android:layout_height="72dp"
android:scaleType="centerCrop"
android:src="@drawable/home_muse_circle_fouth"
android:layout_centerInParent="true"
app:pa_type="pa_circle" />
<TextView
android:id="@+id/sleeps_forth_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="落雨"
android:textColor="@color/platform_black"
android:textSize="@dimen/platform_dp_14"
android:textStyle="bold" />
</RelativeLayout>
</LinearLayout>
</merge>
</merge>
\ No newline at end of file
......@@ -34,7 +34,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|start"
android:text="溪流"
tools:text="溪流"
android:textColor="@color/white"
android:textSize="14sp"
android:layout_marginStart="6dp"
......
......@@ -58,6 +58,9 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.wx.wheelview:wheelview:1.3.3'
// solve build problem
// cannot access 'androidx.lifecycle.hasdefaultviewmodelproviderfactory'
// Comment out when compiling
......
package com.yidianling.muse;
import android.content.Context;
import android.graphics.Color;
import com.wx.wheelview.adapter.ArrayWheelAdapter;
import com.wx.wheelview.widget.WheelView;
import java.util.ArrayList;
import java.util.List;
public class MeditationWheelViewUtil {
private List<String> hours = new ArrayList<>();
private List<String> minutes = new ArrayList<>();
public void initWheelView(Context context, WheelView wheelViewH, WheelView wheelViewM){
createHours();
createMinutes();
wheelViewH.setWheelAdapter(new ArrayWheelAdapter(context));
wheelViewH.setWheelData(hours);
WheelView.WheelViewStyle style = new WheelView.WheelViewStyle();
style.textColor = Color.parseColor("#80FFFFFF");
style.selectedTextColor = Color.parseColor("#FFFFFF");
style.textSize = 30;
style.backgroundColor = Color.parseColor("#00000000");
style.selectedTextSize = 32;
style.selectedTextZoom = 1.2f;
wheelViewH.setStyle(style);
wheelViewH.setExtraText("小时", Color.parseColor("#FFFFFFFF"), 50, 120);
wheelViewM.setWheelAdapter(new ArrayWheelAdapter(context));
wheelViewM.setWheelData(minutes);
wheelViewM.setStyle(style);
wheelViewM.setExtraText("分钟", Color.parseColor("#FFFFFFFF"), 50, 120);
}
private void createHours(){
for (int i = 0; i < 24; i++) {
hours.add("" + i);
}
}
private void createMinutes() {
for (int i = 0; i < 60; i+=5) {
if (i < 10 ) {
minutes.add("0" + i);
} else {
minutes.add("" + i);
}
}
}
}
package com.yidianling.muse.activity
import android.content.Intent
import android.os.Bundle
import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.bean.StatusBarOptions
import com.ydl.ydlcommon.utils.LogUtil
import com.ydl.ydlcommon.utils.StatusBarUtils
import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.yidianling.muse.MeditationWheelViewUtil
import com.yidianling.muse.R
import kotlinx.android.synthetic.main.activity_play_meditation_time_off.*
......@@ -21,15 +24,38 @@ class MeditationTimeOffActivity:BaseActivity() {
private fun initView() {
iv_close?.setOnClickListener { finish() }
tv_save_setting?.setOnClickListener {
ToastHelper.show("保存设置")
val hour =
if (wheel_view_hour.selectionItem.equals("0")){
""
}else{
wheel_view_hour.selectionItem
}
val minute =
if (wheel_view_minute.selectionItem.equals("00")){
""
}else{
wheel_view_minute.selectionItem
}
LogUtil.d("time off","hour=$hour === minute=$minute")
val intent = Intent()
intent.putExtra("TIME_OFF_HOUR",hour.toString())
intent.putExtra("TIME_OFF_MINUTE",minute.toString())
setResult(RESULT_OK,intent)
finish()
}
tv_cancel_time_off?.setOnClickListener {
ToastHelper.show("关闭定时")
val intent = Intent()
intent.putExtra("TIME_OFF_HOUR","")
intent.putExtra("TIME_OFF_MINUTE","")
setResult(RESULT_OK,intent)
finish()
}
......@@ -39,7 +65,7 @@ class MeditationTimeOffActivity:BaseActivity() {
private fun initWheel() {
MeditationWheelViewUtil().initWheelView(this,wheel_view_hour,wheel_view_minute)
}
......
......@@ -21,6 +21,8 @@ import kotlinx.android.synthetic.main.player_control_view.*
import java.util.*
@Route(path = "/muse/play")
class PlayMeditationActivity : BaseActivity() {
......@@ -50,7 +52,6 @@ class PlayMeditationActivity : BaseActivity() {
setTransparentForImageView(this, null)
statusBarLightMode(this)
super.onCreate(savedInstanceState)
initView()
}
......@@ -118,7 +119,7 @@ class PlayMeditationActivity : BaseActivity() {
}
iv_time_off.setOnClickListener {
startActivity(Intent(this,MeditationTimeOffActivity::class.java))
startActivityForResult(Intent(this,MeditationTimeOffActivity::class.java), request_code)
}
initMediaPlayer()
......@@ -269,6 +270,19 @@ class PlayMeditationActivity : BaseActivity() {
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (resultCode == RESULT_OK && request_code == requestCode){
val hour = data?.extras?.getString("TIME_OFF_HOUR","")
val minute = data?.extras?.getString("TIME_OFF_MINUTE","")
if (!hour.isNullOrEmpty() or (!minute.isNullOrEmpty())){
tv_time_off.text = "$hour:$minute"
}else{
tv_time_off.text = ""
}
}
}
override fun onDestroy() {
super.onDestroy()
mTimer.cancel()
......@@ -276,4 +290,10 @@ class PlayMeditationActivity : BaseActivity() {
MediaPlayerManager.getInstance(this).release()
}
companion object{
const val request_code = 0x0001
}
}
\ No newline at end of file
......@@ -139,10 +139,13 @@
app:layout_constraintStart_toEndOf="@id/guide_line" />
<TextView
android:id="@+id/tv_time_off"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
tools:text="56:32"
android:textSize="12sp"
android:textColor="@color/white"
app:layout_constraintTop_toBottomOf="@id/iv_time_off"
app:layout_constraintStart_toStartOf="@id/iv_time_off"
app:layout_constraintEnd_toEndOf="@id/iv_time_off"/>
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
......@@ -33,12 +34,26 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginHorizontal="72dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
<com.wx.wheelview.widget.WheelView
android:id="@+id/wheel_view_hour"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_margin="1dp"
android:layout_height="wrap_content" />
<com.wx.wheelview.widget.WheelView
android:id="@+id/wheel_view_minute"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_margin="1dp"
android:layout_height="wrap_content" />
</LinearLayout>
......
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