Commit 2a4e7104 by 范玉宾

home meditation entrance done

parent e769d986
package com.yidianling.home
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.yidianling.home.model.MeditationTypeModel
class MeditationTypeAdapter(private val context: Context,
private val data:List<MeditationTypeModel>):RecyclerView.Adapter<MeditationTypeAdapter.MeditationTypeViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MeditationTypeViewHolder {
return MeditationTypeViewHolder(LayoutInflater.from(context)
.inflate(R.layout.layout_meditation_item,parent,false))
}
override fun onBindViewHolder(holder: MeditationTypeViewHolder, position: Int) {
holder.ivType?.let {
Glide.with(context)
.load(data[position].imageUrl)
.into(it)
}
holder.tvName?.let {
it.text = data[position].name
}
}
override fun getItemCount(): Int {
return data.size
}
inner class MeditationTypeViewHolder(itemView:View):RecyclerView.ViewHolder(itemView){
val ivType: ImageView? = itemView.findViewById(R.id.iv_meditation_type)
val tvName: TextView? = itemView.findViewById(R.id.tv_meditation_type)
}
}
\ No newline at end of file
package com.yidianling.home
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.yidianling.home.model.bean.MuseModuleBean
class MeditationTypeView(layoutInflater: LayoutInflater, container:ViewGroup?) {
val view:View = layoutInflater.inflate(R.layout.layout_meditation_entrance,container,false)
private val rv:RecyclerView
init {
rv = view.findViewById(R.id.rv_meditation_type)
}
fun bind(muse: MuseModuleBean.MuseDetailBean){
rv.layoutManager = LinearLayoutManager(view.context,LinearLayoutManager.HORIZONTAL,false)
rv.adapter = null
}
}
\ No newline at end of file
package com.yidianling.home
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.yidianling.home.model.MeditationTypeModel
class MeditationViewPagerAdapter(private val context: Context, private val data:
List<List<MeditationTypeModel>>)
:RecyclerView.Adapter<MeditationViewPagerAdapter.MeditationViewPagerViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MeditationViewPagerViewHolder {
return MeditationViewPagerViewHolder(LayoutInflater
.from(context).inflate(R.layout.layout_meditation_entrance,parent,false))
}
override fun onBindViewHolder(holder: MeditationViewPagerViewHolder, position: Int) {
holder.rv?.also { rv->
rv.layoutManager = LinearLayoutManager(context,LinearLayoutManager.HORIZONTAL,false)
rv.adapter = MeditationTypeAdapter(context,data[position])
}
}
override fun getItemCount(): Int {
return data.size
}
inner class MeditationViewPagerViewHolder(itemView: View):RecyclerView.ViewHolder(itemView){
val rv:RecyclerView? = itemView.findViewById(R.id.rv_meditation_type)
}
}
package com.yidianling.home.model
data class MeditationTypeModel(
val imageUrl:String,
val name:String,
val id:String
)
package com.yidianling.home.widget
import android.content.Context
import android.util.AttributeSet
import android.widget.VideoView
class AdaptiveVideoView:VideoView {
constructor(context: Context):this(context,null)
constructor(context: Context,attributeSet: AttributeSet?):this(context,attributeSet,0)
constructor(context: Context,attributeSet: AttributeSet?,defStyle:Int):super(context,attributeSet,defStyle){
}
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
val width = getDefaultSize(0,widthMeasureSpec)
val height = getDefaultSize(0,heightMeasureSpec)
setMeasuredDimension(width,height)
}
}
\ No newline at end of file
......@@ -11,4 +11,13 @@
<item name="colorAccent">@color/platform_main_theme</item>
</style>
<style name="MeditationTabLayoutStyle" parent="Widget.Design.TabLayout">
<item name="tabIndicatorColor">@color/white</item>
<item name="tabIndicatorHeight">2dp</item>
<item name="tabIndicatorFullWidth">false</item>
<item name="tabSelectedTextColor">@color/white</item>
<item name="android:textSize">16sp</item>
<item name="android:textColor">@color/white_60</item>
</style>
</resources>
\ No newline at end of file
......@@ -2,14 +2,26 @@ package com.yidianling.home.ui.view
import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Typeface
import android.media.MediaPlayer
import android.text.SpannableString
import android.text.Spanned
import android.text.style.StyleSpan
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator
import com.google.gson.Gson
import com.ydl.ydl_image.module.GlideApp
import com.ydl.ydlcommon.utils.LogUtil
import com.yidianling.home.MeditationViewPagerAdapter
import com.yidianling.home.MeditationTypeAdapter
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.MuseModuleBean
import kotlinx.android.synthetic.ydl.home_muse_view.view.*
......@@ -25,6 +37,8 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
private var cacheList: ArrayList<HomeMuseView> = ArrayList()
private val meditationTitles = arrayOf("睡眠","冥想","治愈")
init {
initView()
}
......@@ -94,6 +108,82 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
}
}
}
GlideApp.with(this)
.load("http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")
.into(iv_video_background)
video_view?.setVideoPath("http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")
video_view?.setOnPreparedListener {
it?.setVideoScalingMode(MediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING)
video_view?.setOnInfoListener { mp, what, extra ->
if (what == MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START){
iv_video_background.visibility = GONE
}
true
}
it?.start()
it?.setVolume(0.0F,0.0F)
}
video_view?.setOnCompletionListener { video_view?.start() }
val data = mutableListOf<List<MeditationTypeModel>>()
val innerData = mutableListOf<MeditationTypeModel>()
for (i in 0 until 3){
val name = when(i){
0 -> "溪流"
1 -> "田园"
else -> "雨声"
}
val imageUrl = when(i){
0 -> "https://img0.baidu.com/it/u=2451025451,2376393604&fm=253&fmt=auto&app=138&f=JPEG?w=499&h=328"
1 -> "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.9ku.com%2Fgeshoutuji%2Fsingertuji%2F4%2F40945%2F40945_1.jpg&refer=http%3A%2F%2Fimg.9ku.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1654863419&t=aaea1ecc66afc7859a0cf64c06c6f2a4"
else -> "https://img2.baidu.com/it/u=3357363842,3633429992&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=740"
}
innerData.add(MeditationTypeModel(imageUrl,name,i.toString()))
}
for (i in 0 until 3){
data.add(innerData)
}
view_pager.adapter = MeditationViewPagerAdapter(
mContext,data)
tab_layout.addOnTabSelectedListener(object :TabLayout.OnTabSelectedListener{
override fun onTabSelected(tab: TabLayout.Tab?) {
var text:String? = tab?.text.toString().trim() ?: return
val spStr = SpannableString(text)
val styleSpan = StyleSpan(Typeface.BOLD)
spStr.setSpan(styleSpan,0,text?.length?:0,Spanned.SPAN_INCLUSIVE_EXCLUSIVE)
tab?.text = spStr
}
override fun onTabUnselected(tab: TabLayout.Tab?) {
var text:String? = tab?.text.toString().trim() ?: return
val spStr = SpannableString(text)
val styleSpan = StyleSpan(Typeface.NORMAL)
spStr.setSpan(styleSpan,0,text?.length?:0,Spanned.SPAN_INCLUSIVE_EXCLUSIVE)
tab?.text = spStr
}
override fun onTabReselected(tab: TabLayout.Tab?) {
}
})
TabLayoutMediator(tab_layout,view_pager){
tab, position ->
tab.text = meditationTitles[position]
}.attach()
}
}
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="10dp"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_meditation_type"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="6dp">
<androidx.cardview.widget.CardView
android:id="@+id/card_view"
android:layout_width="105dp"
android:layout_height="102dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:cardCornerRadius="12dp"
app:cardElevation="0dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/iv_meditation_type"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
tools:src="@drawable/play_page_default_bg" />
<TextView
android:id="@+id/tv_meditation_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|start"
android:text="溪流"
android:textColor="@color/white"
android:textSize="14sp"
android:layout_marginStart="6dp"
android:layout_marginBottom="5dp" />
</FrameLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="white_60">#99FFFFFF</color>
<color name="white">#FFFFFF</color>
</resources>
......@@ -20,20 +20,20 @@ import com.yidianling.muse.utils.ShareMeditationUtil
import kotlinx.android.synthetic.main.layout_share_play_meditation.*
class ShareMeditationDialog:DialogFragment() {
class ShareMeditationDialog : DialogFragment() {
private var ivSharePicture:ImageView?=null
private var tvShareContent:TextView?=null
private var ivSharePicture: ImageView? = null
private var tvShareContent: TextView? = null
private var llWeChat:LinearLayout?=null
private var llCircleOfFriends:LinearLayout?=null
private var llSave:LinearLayout?=null
private var llQQZone:LinearLayout?=null
private var llQQFriend:LinearLayout?=null
private var llWeChat: LinearLayout? = null
private var llCircleOfFriends: LinearLayout? = null
private var llSave: LinearLayout? = null
private var llQQZone: LinearLayout? = null
private var llQQFriend: LinearLayout? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(STYLE_NO_TITLE,R.style.share_meditation_dialog)
setStyle(STYLE_NO_TITLE, R.style.share_meditation_dialog)
}
override fun onStart() {
......@@ -42,7 +42,6 @@ class ShareMeditationDialog:DialogFragment() {
activity?.windowManager?.defaultDisplay?.getMetrics(displayMetrics)
val window = dialog?.window
window?.setLayout(MATCH_PARENT, MATCH_PARENT)
}
override fun onCreateView(
......@@ -69,7 +68,7 @@ class ShareMeditationDialog:DialogFragment() {
tvShareContent = view?.findViewById(R.id.tv_share_content)
if (view!=null && ivSharePicture!=null){
if (view != null && ivSharePicture != null) {
Glide.with(view.context)
.load(shareImageUrl)
.into(ivSharePicture!!)
......@@ -83,30 +82,55 @@ class ShareMeditationDialog:DialogFragment() {
llQQFriend = view?.findViewById(R.id.ll_qq_friend)
llWeChat?.setOnClickListener {
ShareUtils.shareTo(SHARE_MEDIA.WEIXIN,
activity as Activity, "share_title", "http://www.baidu.com", "share_context", imageUrl)
ShareUtils.shareTo(
SHARE_MEDIA.WEIXIN,
activity as Activity,
"share_title",
"http://www.baidu.com",
"share_context",
imageUrl
)
dismiss()
}
llCircleOfFriends?.setOnClickListener {
ShareUtils.shareTo(SHARE_MEDIA.WEIXIN_CIRCLE,
activity as Activity, "share_title", "https://www.baidu.com", "share_context", imageUrl)
ShareUtils.shareTo(
SHARE_MEDIA.WEIXIN_CIRCLE,
activity as Activity,
"share_title",
"https://www.baidu.com",
"share_context",
imageUrl
)
dismiss()
}
llSave?.setOnClickListener {
ShareMeditationUtil.saveImageToLocal(csl_layout_top)
dismiss()
}
llQQZone?.setOnClickListener {
ShareUtils.shareTo(SHARE_MEDIA.QZONE,
activity as Activity, "share_title", "http://www.baidu.com", "share_context", imageUrl)
ShareUtils.shareTo(
SHARE_MEDIA.QZONE,
activity as Activity,
"share_title",
"http://www.baidu.com",
"share_context",
imageUrl
)
dismiss()
}
llQQFriend?.setOnClickListener {
ShareUtils.shareTo(SHARE_MEDIA.QQ,
activity as Activity, "share_title", "http://www.baidu.com", "share_context", imageUrl)
ShareUtils.shareTo(
SHARE_MEDIA.QQ,
activity as Activity,
"share_title",
"http://www.baidu.com",
"share_context",
imageUrl
)
dismiss()
}
......@@ -116,16 +140,16 @@ class ShareMeditationDialog:DialogFragment() {
}
companion object{
companion object {
const val TAG = "ShareMeditationDialog"
private const val KEY_SHARE_IMAGE_URL = "key_share_image_url"
private const val KEY_SHARE_CONTENT = "key_share_content"
fun newInstance(shareImageUrl:String,shareContent:String):ShareMeditationDialog{
fun newInstance(shareImageUrl: String, shareContent: String): ShareMeditationDialog {
val args = Bundle()
args.putString(KEY_SHARE_IMAGE_URL,shareImageUrl)
args.putString(KEY_SHARE_CONTENT,shareContent)
args.putString(KEY_SHARE_IMAGE_URL, shareImageUrl)
args.putString(KEY_SHARE_CONTENT, shareContent)
val fragment = ShareMeditationDialog()
fragment.arguments = args
return fragment
......
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="26dp"
android:height="26dp"
android:viewportWidth="26"
android:viewportHeight="26">
android:width="32dp"
android:height="32dp"
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:pathData="M17.8139,3C15.4366,3 13.7337,5.173 12.9998,6.3222C12.2651,5.173 10.5629,3 8.1857,3C4.7744,3 2,6.1183 2,9.9507C2,11.7428 3.1983,14.312 4.653,15.6566C6.6652,18.2791 12.3223,23 13.0207,23C13.7314,23 19.2671,18.3708 21.3157,15.688C22.7959,14.3198 24,11.7472 24,9.9507C24,6.1182 21.2252,3 17.8139,3"
android:pathData="M21.408,4C18.4904,4 16.4004,6.6075 15.4998,7.9867C14.5981,6.6075 12.5091,4 9.5915,4C5.4049,4 2,7.7419 2,12.3409C2,14.4914 3.4707,17.5744 5.256,19.1879C7.7255,22.3349 14.6683,28 15.5254,28C16.3976,28 23.1914,22.445 25.7056,19.2256C27.5222,17.5838 29,14.4966 29,12.3409C29,7.7419 25.5945,4 21.408,4"
android:strokeWidth="1"
android:fillType="nonZero"
android:strokeColor="#00000000">
<aapt:attr name="android:fillColor">
<gradient
android:startY="4.735537"
android:startX="8.220921"
android:endY="18.2729"
android:endX="17.016783"
android:startY="6.5185184"
android:startX="9.634766"
android:endY="22.049383"
android:endX="20.429688"
android:type="linear">
<item android:offset="0" android:color="#FFFFB5A5"/>
<item android:offset="1" android:color="#FFFF7366"/>
......
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