Commit a5f63d1f by 范玉宾

meditation/index inter debug done

parent 390ba8e0
...@@ -11,10 +11,11 @@ import androidx.recyclerview.widget.RecyclerView ...@@ -11,10 +11,11 @@ import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.yidianling.common.tools.ToastUtil import com.yidianling.common.tools.ToastUtil
import com.yidianling.home.model.MeditationTypeModel import com.yidianling.home.model.MeditationTypeModel
import com.yidianling.home.model.bean.MeditationModuleBean
class MeditationTypeAdapter( class MeditationTypeAdapter(
private val context: Context, private val context: Context,
private val data: List<MeditationTypeModel> private val data: List<MeditationModuleBean.MeditationDetail>
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() { ) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
...@@ -42,12 +43,12 @@ class MeditationTypeAdapter( ...@@ -42,12 +43,12 @@ class MeditationTypeAdapter(
is MeditationTypeViewHolder -> { is MeditationTypeViewHolder -> {
holder.ivType?.let { holder.ivType?.let {
Glide.with(context) Glide.with(context)
.load(data[position].imageUrl) .load(data[position].coverImageUrl)
.into(it) .into(it)
} }
holder.tvName?.let { holder.tvName?.let {
it.text = data[position].name it.text = data[position].title
} }
} }
is MeditationTypeMoreViewHolder -> { is MeditationTypeMoreViewHolder -> {
...@@ -66,7 +67,7 @@ class MeditationTypeAdapter( ...@@ -66,7 +67,7 @@ class MeditationTypeAdapter(
override fun getItemId(position: Int) = position.toLong() override fun getItemId(position: Int) = position.toLong()
override fun getItemViewType(position: Int): Int { override fun getItemViewType(position: Int): Int {
val isMore = data[position].isMore val isMore = false
return if (isMore) { return if (isMore) {
FOOTER_TYPE FOOTER_TYPE
} else { } else {
......
...@@ -7,9 +7,10 @@ import android.view.ViewGroup ...@@ -7,9 +7,10 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.yidianling.home.model.MeditationTypeModel import com.yidianling.home.model.MeditationTypeModel
import com.yidianling.home.model.bean.MeditationModuleBean
class MeditationViewPagerAdapter(private val context: Context, private val data: class MeditationViewPagerAdapter(private val context: Context, private val data:
List<List<MeditationTypeModel>>) MeditationModuleBean)
:RecyclerView.Adapter<MeditationViewPagerAdapter.MeditationViewPagerViewHolder>() { :RecyclerView.Adapter<MeditationViewPagerAdapter.MeditationViewPagerViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MeditationViewPagerViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MeditationViewPagerViewHolder {
...@@ -20,12 +21,16 @@ class MeditationViewPagerAdapter(private val context: Context, private val data: ...@@ -20,12 +21,16 @@ class MeditationViewPagerAdapter(private val context: Context, private val data:
override fun onBindViewHolder(holder: MeditationViewPagerViewHolder, position: Int) { override fun onBindViewHolder(holder: MeditationViewPagerViewHolder, position: Int) {
holder.rv?.also { rv-> holder.rv?.also { rv->
rv.layoutManager = LinearLayoutManager(context,LinearLayoutManager.HORIZONTAL,false) 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 { override fun getItemCount(): Int {
return data.size return data.mditationListResponse?.size?:0
} }
inner class MeditationViewPagerViewHolder(itemView: View):RecyclerView.ViewHolder(itemView){ inner class MeditationViewPagerViewHolder(itemView: View):RecyclerView.ViewHolder(itemView){
......
...@@ -178,5 +178,6 @@ class IHomeBaseContract { ...@@ -178,5 +178,6 @@ class IHomeBaseContract {
* 首页问答 - 关注 * 首页问答 - 关注
*/ */
fun askFocus(id: String): Observable<AskResultBean> fun askFocus(id: String): Observable<AskResultBean>
} }
} }
\ No newline at end of file
...@@ -101,4 +101,5 @@ class HomeBaseHttp { ...@@ -101,4 +101,5 @@ class HomeBaseHttp {
val cmd = AskRequestParamBean.FocusCmd(id, "1") val cmd = AskRequestParamBean.FocusCmd(id, "1")
return RxUtils.mapObservable(cmd).flatMap { getHomePagerApi().askFocus(it) } return RxUtils.mapObservable(cmd).flatMap { getHomePagerApi().askFocus(it) }
} }
} }
\ No newline at end of file
...@@ -87,4 +87,6 @@ open class BaseHomeModelImpl : IHomeBaseContract.Model { ...@@ -87,4 +87,6 @@ open class BaseHomeModelImpl : IHomeBaseContract.Model {
return HomeBaseHttp.getInstance().newHomeHeaderRequest().compose(RxUtils.resultJavaData()) return HomeBaseHttp.getInstance().newHomeHeaderRequest().compose(RxUtils.resultJavaData())
.onErrorReturn { HomeHeaderBean(true) } .onErrorReturn { HomeHeaderBean(true) }
} }
} }
\ No newline at end of file
...@@ -53,6 +53,12 @@ class HomePagerDataBean() { ...@@ -53,6 +53,12 @@ class HomePagerDataBean() {
* 冥想模块数据 * 冥想模块数据
*/ */
var museBean: MuseModuleBean? = null 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, ...@@ -228,7 +228,7 @@ class YdlHomeAdapter(private val mContext: Context,
} }
//壹点*冥想模块 //壹点*冥想模块
is HomeMuseViewHolder -> { is HomeMuseViewHolder -> {
holder.museViewView.initData(list[holder.viewType].museBean) holder.museViewView.initData(list[holder.viewType].meditationBean)
} }
//心灵*电台模块 //心灵*电台模块
is HomeIntelligentViewHolder -> { is HomeIntelligentViewHolder -> {
......
package com.yidianling.home.constract package com.yidianling.home.constract
import com.yidianling.home.constants.IHomeBaseContract import com.yidianling.home.constants.IHomeBaseContract
import com.yidianling.home.model.bean.MeditationModuleBean
import com.yidianling.home.model.bean.MuseModuleBean import com.yidianling.home.model.bean.MuseModuleBean
import io.reactivex.Observable import io.reactivex.Observable
...@@ -20,5 +21,7 @@ class IHomeContract { ...@@ -20,5 +21,7 @@ class IHomeContract {
* 首页冥想请求 * 首页冥想请求
*/ */
fun museRequest(): Observable<MuseModuleBean> fun museRequest(): Observable<MuseModuleBean>
fun getMeditation():Observable<MeditationModuleBean>
} }
} }
\ No newline at end of file
...@@ -2,6 +2,7 @@ package com.yidianling.home.http ...@@ -2,6 +2,7 @@ package com.yidianling.home.http
import com.ydl.ydlcommon.data.http.BaseAPIResponse import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlnet.YDLHttpUtils import com.ydl.ydlnet.YDLHttpUtils
import com.yidianling.home.model.bean.MeditationModuleBean
import com.yidianling.home.model.bean.MuseModuleBean import com.yidianling.home.model.bean.MuseModuleBean
import io.reactivex.Observable import io.reactivex.Observable
...@@ -37,4 +38,9 @@ class HomeHttp { ...@@ -37,4 +38,9 @@ class HomeHttp {
fun newMuseRequest(): Observable<BaseAPIResponse<MuseModuleBean>> { fun newMuseRequest(): Observable<BaseAPIResponse<MuseModuleBean>> {
return getHomePagerApi().getMuseData() 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 ...@@ -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
import com.ydl.ydlcommon.base.config.YDL_DOMAIN_JAVA import com.ydl.ydlcommon.base.config.YDL_DOMAIN_JAVA
import com.ydl.ydlcommon.data.http.BaseAPIResponse import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.yidianling.home.model.bean.MeditationModuleBean
import com.yidianling.home.model.bean.MuseModuleBean import com.yidianling.home.model.bean.MuseModuleBean
import io.reactivex.Observable import io.reactivex.Observable
import retrofit2.http.GET import retrofit2.http.GET
...@@ -21,4 +22,9 @@ interface HomePagerApi { ...@@ -21,4 +22,9 @@ interface HomePagerApi {
@GET("meditation/meditation/list") @GET("meditation/meditation/list")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA) @Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun getMuseData(): Observable<BaseAPIResponse<MuseModuleBean>> 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 ...@@ -3,6 +3,7 @@ package com.yidianling.home.model
import com.ydl.ydlcommon.data.http.RxUtils import com.ydl.ydlcommon.data.http.RxUtils
import com.yidianling.home.constract.IHomeContract import com.yidianling.home.constract.IHomeContract
import com.yidianling.home.http.HomeHttp import com.yidianling.home.http.HomeHttp
import com.yidianling.home.model.bean.MeditationModuleBean
import com.yidianling.home.model.bean.MuseModuleBean import com.yidianling.home.model.bean.MuseModuleBean
import io.reactivex.Observable import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
...@@ -26,5 +27,11 @@ class HomeModelImpl : BaseHomeModelImpl(), IHomeContract.Model { ...@@ -26,5 +27,11 @@ class HomeModelImpl : BaseHomeModelImpl(), IHomeContract.Model {
.onErrorReturn { MuseModuleBean(true) } .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 ...@@ -112,6 +112,12 @@ class HomePresenterImpl: BaseHomePresenterImpl<IHomeContract.View, IHomeContract
homeList.add(getHomeItemFromTempData(it, HomeViewConfig.getOrder().museIndex!!)) 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() val fmObservable = mModel.fmRequest()
.compose(RxUtils.applySchedulers(mView)).map { .compose(RxUtils.applySchedulers(mView)).map {
//首页电台数据 //首页电台数据
...@@ -134,6 +140,7 @@ class HomePresenterImpl: BaseHomePresenterImpl<IHomeContract.View, IHomeContract ...@@ -134,6 +140,7 @@ class HomePresenterImpl: BaseHomePresenterImpl<IHomeContract.View, IHomeContract
if (HomeViewConfig.getOrder().bannerIndex!=null){ if (HomeViewConfig.getOrder().bannerIndex!=null){
mergeArrays.add(headerObservable) mergeArrays.add(headerObservable)
} }
if (HomeViewConfig.getOrder().consultIndex!=null){ if (HomeViewConfig.getOrder().consultIndex!=null){
mergeArrays.add(consultObservable) mergeArrays.add(consultObservable)
} }
...@@ -150,8 +157,11 @@ class HomePresenterImpl: BaseHomePresenterImpl<IHomeContract.View, IHomeContract ...@@ -150,8 +157,11 @@ class HomePresenterImpl: BaseHomePresenterImpl<IHomeContract.View, IHomeContract
mergeArrays.add(askObservable) mergeArrays.add(askObservable)
} }
if (HomeViewConfig.getOrder().museIndex!=null){ if (HomeViewConfig.getOrder().museIndex!=null){
mergeArrays.add(museObservable) mergeArrays.add(meditationObservable)
} }
// if (HomeViewConfig.getOrder().museIndex!=null){
// mergeArrays.add(museObservable)
// }
if (HomeViewConfig.getOrder().fmIndex!=null){ if (HomeViewConfig.getOrder().fmIndex!=null){
mergeArrays.add(fmObservable) mergeArrays.add(fmObservable)
} }
...@@ -297,9 +307,13 @@ class HomePresenterImpl: BaseHomePresenterImpl<IHomeContract.View, IHomeContract ...@@ -297,9 +307,13 @@ class HomePresenterImpl: BaseHomePresenterImpl<IHomeContract.View, IHomeContract
if (dataBean.isRealEmpty || dataBean !is HomeAskBean) homeTempData.askBean else dataBean if (dataBean.isRealEmpty || dataBean !is HomeAskBean) homeTempData.askBean else dataBean
mHomeAskBean = item.askBean mHomeAskBean = item.askBean
} }
// HomeViewConfig.getOrder().museIndex -> {
// item.museBean =
// if (dataBean.isRealEmpty || dataBean !is MuseModuleBean) homeTempData.museBean else dataBean
// }
HomeViewConfig.getOrder().museIndex -> { HomeViewConfig.getOrder().museIndex -> {
item.museBean = item.meditationBean =
if (dataBean.isRealEmpty || dataBean !is MuseModuleBean) homeTempData.museBean else dataBean if (dataBean.isRealEmpty || dataBean !is MeditationModuleBean) homeTempData.meditationBean else dataBean
} }
HomeViewConfig.getOrder().fmIndex -> { HomeViewConfig.getOrder().fmIndex -> {
item.fmBean = item.fmBean =
......
...@@ -20,6 +20,7 @@ import com.yidianling.home.R ...@@ -20,6 +20,7 @@ import com.yidianling.home.R
import com.yidianling.home.constract.HomeViewConfig import com.yidianling.home.constract.HomeViewConfig
import com.yidianling.home.event.IHomeEvent import com.yidianling.home.event.IHomeEvent
import com.yidianling.home.model.MeditationTypeModel import com.yidianling.home.model.MeditationTypeModel
import com.yidianling.home.model.bean.MeditationModuleBean
import com.yidianling.home.model.bean.MuseModuleBean import com.yidianling.home.model.bean.MuseModuleBean
import kotlinx.android.synthetic.ydl.home_muse_view.view.* import kotlinx.android.synthetic.ydl.home_muse_view.view.*
...@@ -35,7 +36,7 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv ...@@ -35,7 +36,7 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
private var cacheList: ArrayList<HomeMuseView> = ArrayList() private var cacheList: ArrayList<HomeMuseView> = ArrayList()
private val meditationTitles = arrayOf("睡眠","冥想","治愈") private val meditationTitles = mutableListOf<String>()
init { init {
initView() initView()
...@@ -53,7 +54,7 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv ...@@ -53,7 +54,7 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
homeModuleMuseViewHomeCommonTitleView.setTitle(HomeViewConfig.getOrder().museTitle) homeModuleMuseViewHomeCommonTitleView.setTitle(HomeViewConfig.getOrder().museTitle)
} }
fun initData(bean: MuseModuleBean?) { fun initData(bean: MeditationModuleBean?) {
if (null != bean) { if (null != bean) {
...@@ -62,56 +63,23 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv ...@@ -62,56 +63,23 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
homeEvent?.museMoreClick(Gson().toJson(bean)) homeEvent?.museMoreClick(Gson().toJson(bean))
} }
if (null != bean.muses) { val greeting = bean?.meditationIndexInfo?.greetings?:"你好"
if (bean.muses?.size!! > 0) { tv_time.text = greeting
muse_first.setOnClickListener { val slogan =
homeEvent?.museClick(bean.muses!![0].audioUrl, dataJson,muse_first_text.text.toString()) if (bean?.meditationIndexInfo?.mditationDay==null){
} "无常的日子里,呼吸间拾起力量"
} }else{
if (bean.muses?.size!! > 1) { "已连续冥想${bean?.meditationIndexInfo?.mditationDay}天"
muse_second.setOnClickListener {
homeEvent?.museClick(bean.muses!![1].audioUrl, dataJson,muse_second_text.text.toString())
}
} }
if (bean.muses?.size!! > 2) { tv_meditation_slogan.text = slogan
muse_third.setOnClickListener {
homeEvent?.museClick(bean.muses!![2].audioUrl, dataJson,muse_third_text.text.toString()) val videoUrl = bean?.meditationIndexInfo?.videoLink?:"http://www.w3school.com.cn/example/html5/mov_bbb.mp4"
}
}
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())
}
}
}
GlideApp.with(this) GlideApp.with(this)
.load("http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4") .load(videoUrl)
.into(iv_video_background) .into(iv_video_background)
video_view?.setVideoPath("http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4") video_view?.setVideoPath(videoUrl)
video_view?.setOnPreparedListener { video_view?.setOnPreparedListener {
it?.setVideoScalingMode(MediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING) 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 ...@@ -126,7 +94,6 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
} }
video_view?.setOnCompletionListener { video_view?.start() } video_view?.setOnCompletionListener { video_view?.start() }
val data = mutableListOf<List<MeditationTypeModel>>() val data = mutableListOf<List<MeditationTypeModel>>()
val innerData = mutableListOf<MeditationTypeModel>() val innerData = mutableListOf<MeditationTypeModel>()
...@@ -152,9 +119,12 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv ...@@ -152,9 +119,12 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
data.add(innerData) data.add(innerData)
} }
bean?.mditationListResponse?.forEach {
meditationTitles.add(it.comment)
}
view_pager.adapter = MeditationViewPagerAdapter( view_pager.adapter = MeditationViewPagerAdapter(mContext,bean)
mContext,data)
tab_layout.addOnTabSelectedListener(object :TabLayout.OnTabSelectedListener{ tab_layout.addOnTabSelectedListener(object :TabLayout.OnTabSelectedListener{
override fun onTabSelected(tab: TabLayout.Tab?) { override fun onTabSelected(tab: TabLayout.Tab?) {
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom|start" android:layout_gravity="bottom|start"
android:text="溪流" tools:text="溪流"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="14sp" android:textSize="14sp"
android:layout_marginStart="6dp" android:layout_marginStart="6dp"
......
...@@ -58,6 +58,9 @@ dependencies { ...@@ -58,6 +58,9 @@ dependencies {
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'
implementation 'com.wx.wheelview:wheelview:1.3.3'
// solve build problem // solve build problem
// cannot access 'androidx.lifecycle.hasdefaultviewmodelproviderfactory' // cannot access 'androidx.lifecycle.hasdefaultviewmodelproviderfactory'
// Comment out when compiling // 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 package com.yidianling.muse.activity
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import com.ydl.ydlcommon.base.BaseActivity import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.bean.StatusBarOptions import com.ydl.ydlcommon.bean.StatusBarOptions
import com.ydl.ydlcommon.utils.LogUtil
import com.ydl.ydlcommon.utils.StatusBarUtils import com.ydl.ydlcommon.utils.StatusBarUtils
import com.ydl.ydlcommon.utils.remind.ToastHelper import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.yidianling.muse.MeditationWheelViewUtil
import com.yidianling.muse.R import com.yidianling.muse.R
import kotlinx.android.synthetic.main.activity_play_meditation_time_off.* import kotlinx.android.synthetic.main.activity_play_meditation_time_off.*
...@@ -21,15 +24,38 @@ class MeditationTimeOffActivity:BaseActivity() { ...@@ -21,15 +24,38 @@ class MeditationTimeOffActivity:BaseActivity() {
private fun initView() { private fun initView() {
iv_close?.setOnClickListener { finish() } iv_close?.setOnClickListener { finish() }
tv_save_setting?.setOnClickListener { tv_save_setting?.setOnClickListener {
ToastHelper.show("保存设置") 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() finish()
} }
tv_cancel_time_off?.setOnClickListener { tv_cancel_time_off?.setOnClickListener {
ToastHelper.show("关闭定时") ToastHelper.show("关闭定时")
val intent = Intent()
intent.putExtra("TIME_OFF_HOUR","")
intent.putExtra("TIME_OFF_MINUTE","")
setResult(RESULT_OK,intent)
finish() finish()
} }
...@@ -39,7 +65,7 @@ class MeditationTimeOffActivity:BaseActivity() { ...@@ -39,7 +65,7 @@ class MeditationTimeOffActivity:BaseActivity() {
private fun initWheel() { private fun initWheel() {
MeditationWheelViewUtil().initWheelView(this,wheel_view_hour,wheel_view_minute)
} }
......
...@@ -21,6 +21,8 @@ import kotlinx.android.synthetic.main.player_control_view.* ...@@ -21,6 +21,8 @@ import kotlinx.android.synthetic.main.player_control_view.*
import java.util.* import java.util.*
@Route(path = "/muse/play") @Route(path = "/muse/play")
class PlayMeditationActivity : BaseActivity() { class PlayMeditationActivity : BaseActivity() {
...@@ -50,7 +52,6 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -50,7 +52,6 @@ class PlayMeditationActivity : BaseActivity() {
setTransparentForImageView(this, null) setTransparentForImageView(this, null)
statusBarLightMode(this) statusBarLightMode(this)
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
initView() initView()
} }
...@@ -118,7 +119,7 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -118,7 +119,7 @@ class PlayMeditationActivity : BaseActivity() {
} }
iv_time_off.setOnClickListener { iv_time_off.setOnClickListener {
startActivity(Intent(this,MeditationTimeOffActivity::class.java)) startActivityForResult(Intent(this,MeditationTimeOffActivity::class.java), request_code)
} }
initMediaPlayer() initMediaPlayer()
...@@ -269,6 +270,19 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -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() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
mTimer.cancel() mTimer.cancel()
...@@ -276,4 +290,10 @@ class PlayMeditationActivity : BaseActivity() { ...@@ -276,4 +290,10 @@ class PlayMeditationActivity : BaseActivity() {
MediaPlayerManager.getInstance(this).release() MediaPlayerManager.getInstance(this).release()
} }
companion object{
const val request_code = 0x0001
}
} }
\ No newline at end of file
...@@ -139,10 +139,13 @@ ...@@ -139,10 +139,13 @@
app:layout_constraintStart_toEndOf="@id/guide_line" /> app:layout_constraintStart_toEndOf="@id/guide_line" />
<TextView <TextView
android:id="@+id/tv_time_off"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
tools:text="56:32" tools:text="56:32"
android:textSize="12sp"
android:textColor="@color/white"
app:layout_constraintTop_toBottomOf="@id/iv_time_off" app:layout_constraintTop_toBottomOf="@id/iv_time_off"
app:layout_constraintStart_toStartOf="@id/iv_time_off" app:layout_constraintStart_toStartOf="@id/iv_time_off"
app:layout_constraintEnd_toEndOf="@id/iv_time_off"/> app:layout_constraintEnd_toEndOf="@id/iv_time_off"/>
......
<?xml version="1.0" encoding="utf-8"?> <?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:tools="http://schemas.android.com/tools"
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"
...@@ -33,12 +34,26 @@ ...@@ -33,12 +34,26 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginHorizontal="72dp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="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> </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