Commit eccc3d06 by 范玉宾

meditation play & meditation share controls events done

parent e9c01bf0
......@@ -154,6 +154,9 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
ModularServiceManager.provide(IConsultantService::class.java).requestGuideData()
bt_to_muse.setOnClickListener {
ARouter.getInstance().build("/muse/play")
.navigation()
val list =
ModularServiceManager.provide(IConsultantService::class.java).getGuideImage(1)
list?.forEach {
......
......@@ -58,6 +58,11 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
// solve build problem
// cannot access 'androidx.lifecycle.hasdefaultviewmodelproviderfactory'
// Comment out when compiling
// implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
implementation "com.alibaba:arouter-api:$arouter_api"
// 注意此处的依赖方式:kotlin中使用和java中使用方式有不同
kapt "com.alibaba:arouter-compiler:$arouter_compiler"
......
......@@ -9,5 +9,9 @@
android:name=".activity.MuseCenterActivity"
android:screenOrientation="portrait"
android:theme="@style/muse_Transparent"/>
<activity android:name=".activity.PlayMeditationActivity"
android:screenOrientation="portrait"
android:theme="@style/platform_NoTitleTheme" />
</application>
</manifest>
package com.yidianling.muse.activity
import android.os.Build
import android.os.Bundle
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.widget.AppCompatSeekBar
import androidx.constraintlayout.widget.ConstraintLayout
import com.alibaba.android.arouter.facade.annotation.Route
import com.bumptech.glide.Glide
import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.bean.StatusBarOptions
import com.ydl.ydlcommon.utils.StatusBarUtils.Companion.setTransparentForImageView
import com.ydl.ydlcommon.utils.StatusBarUtils.Companion.statusBarLightMode
import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.yidianling.muse.R
import com.yidianling.muse.widget.ShareMeditationDialog
import kotlinx.android.synthetic.main.activity_play_meditation.*
import kotlin.properties.Delegates
@Route(path = "/muse/play")
class PlayMeditationActivity : BaseActivity() {
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"
private var collected = false
private var shareDialog: ShareMeditationDialog? = null
override fun onCreate(savedInstanceState: Bundle?) {
setTransparentForImageView(this, null)
statusBarLightMode(this)
super.onCreate(savedInstanceState)
initView()
}
override fun initDataAndEvent() {
}
override fun layoutResId(): Int {
return R.layout.activity_play_meditation
}
override fun getStatusViewOptions(): StatusBarOptions {
return StatusBarOptions(true, false)
}
private fun initView() {
Glide.with(this)
.load(bgUrl)
.into(iv_bg)
iv_close.setOnClickListener {
finish()
}
iv_back.setOnClickListener {
finish()
}
iv_share.setOnClickListener {
if (shareDialog == null) {
shareDialog = ShareMeditationDialog
.newInstance(
shareImageUrl = bgUrl,
shareContent = "老铁,我是你要分享的内容"
)
}
if (shareDialog != null && shareDialog?.isAdded == false) {
shareDialog?.show(supportFragmentManager, ShareMeditationDialog.TAG)
}
}
tv_title.text = "这是一首简单的冥想BGM"
tv_content.text = "写着人们心疼的曲折,我想我很快乐,做一个旁观者"
iv_collect.setOnClickListener {
collected = !collected
if (collected) {
ToastHelper.show("收藏成功!")
iv_collect.setImageResource(R.drawable.icon_play_meditation_collect)
} else {
ToastHelper.show("取消收藏!")
iv_collect.setImageResource(R.drawable.icon_play_meditation_collect)
}
}
iv_time_off.setOnClickListener {
ToastHelper.show("设置定时关闭!")
}
iv_play_or_pause.setOnClickListener {
}
iv_previous.setOnClickListener {
ToastHelper.show("上一首!")
}
iv_next.setOnClickListener {
ToastHelper.show("下一首!")
}
iv_rewind.setOnClickListener {
val currentProgress = seekbar_play_progress.progress
val progress = 0.coerceAtLeast(currentProgress - 15)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
seekbar_play_progress.setProgress(progress, true)
} else {
seekbar_play_progress.progress = progress
}
}
iv_fast_forward.setOnClickListener {
val currentProgress = seekbar_play_progress.progress
val progress = 100.coerceAtMost(currentProgress + 15)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
seekbar_play_progress.setProgress(progress, true)
} else {
seekbar_play_progress.progress = progress
}
}
}
}
\ No newline at end of file
package com.yidianling.muse.widget
import android.os.Bundle
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
class PureMusicListBottomDialog():BottomSheetDialogFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
}
\ No newline at end of file
package com.yidianling.muse.widget
import android.os.Bundle
import android.util.DisplayMetrics
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.fragment.app.DialogFragment
import com.bumptech.glide.Glide
import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.yidianling.muse.R
class ShareMeditationDialog:DialogFragment() {
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
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(STYLE_NO_TITLE,R.style.share_meditation_dialog)
}
override fun onStart() {
super.onStart()
val displayMetrics = DisplayMetrics()
activity?.windowManager?.defaultDisplay?.getMetrics(displayMetrics)
val window = dialog?.window
window?.setLayout(MATCH_PARENT, MATCH_PARENT)
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.layout_share_play_meditation, container)
initView(view)
return view
}
private fun initView(view: View?) {
val shareImageUrl = arguments?.getString(KEY_SHARE_IMAGE_URL)
val shareContent = arguments?.getString(KEY_SHARE_CONTENT)
ivSharePicture = view?.findViewById(R.id.iv_share_picture)
tvShareContent = view?.findViewById(R.id.tv_share_content)
if (view!=null && ivSharePicture!=null){
Glide.with(view.context)
.load(shareImageUrl)
.into(ivSharePicture!!)
}
tvShareContent?.text = shareContent
llWeChat = view?.findViewById(R.id.ll_wechat_friend)
llCircleOfFriends = view?.findViewById(R.id.ll_wechat_circle_of_friends)
llSave = view?.findViewById(R.id.ll_save_picture)
llQQZone = view?.findViewById(R.id.ll_qq_zone)
llQQFriend = view?.findViewById(R.id.ll_qq_friend)
llWeChat?.setOnClickListener {
ToastHelper.show("分享给微信好友!")
}
llCircleOfFriends?.setOnClickListener {
ToastHelper.show("分享到朋友圈!")
}
llSave?.setOnClickListener {
ToastHelper.show("保存图片!")
}
llQQZone?.setOnClickListener {
ToastHelper.show("分享到QQ空间!")
}
llQQFriend?.setOnClickListener {
ToastHelper.show("分享给QQ好友!")
}
view?.findViewById<TextView>(R.id.tv_cancel_share)?.setOnClickListener {
dismiss()
}
}
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{
val args = Bundle()
args.putString(KEY_SHARE_IMAGE_URL,shareImageUrl)
args.putString(KEY_SHARE_CONTENT,shareContent)
val fragment = ShareMeditationDialog()
fragment.arguments = args
return fragment
}
}
}
\ No newline at end of file
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:pathData="M5.4974,9.7329L22.7015,9.7329C22.9762,9.7329 23.1989,9.4787 23.1989,9.1653L23.1989,7.5675C23.1989,7.2551 22.9762,7 22.7015,7L5.4974,7C5.2227,7 5,7.2542 5,7.5675L5,9.1653C5,9.4778 5.2227,9.7329 5.4974,9.7329M5.4979,17.9315L18.8706,17.9315C19.1462,17.9315 19.3685,17.6773 19.3685,17.364L19.3685,15.7662C19.3685,15.4528 19.1462,15.1986 18.8706,15.1986L5.4987,15.1986C5.2232,15.1986 5.0009,15.4528 5.0009,15.7662L5.0009,17.364C5.0009,17.6773 5.2232,17.9315 5.4987,17.9315M14.0771,23.3973L5.5013,23.3973C5.2243,23.3973 5,23.6906 5,24.0531L5,25.4742C5,25.8368 5.2243,26.1301 5.5013,26.1301L14.0771,26.1301C14.3541,26.1301 14.5784,25.8368 14.5784,25.4742L14.5784,24.0531C14.5784,23.6906 14.3541,23.3973 14.0771,23.3973M27.5537,11.2257C25.3607,11.4482 23.6014,13.2989 23.5679,15.6311L23.5672,15.6311L23.5672,19.484C23.0651,19.2341 22.5141,19.1048 21.9559,19.1061C19.9407,19.1061 18.3294,20.7404 18.3294,22.7838C18.3294,24.8273 19.9407,26.4615 21.9559,26.4615C23.9703,26.4615 25.6493,24.8273 25.5816,22.7838L25.5816,15.6989C25.5816,14.457 26.4743,13.4436 27.6474,13.2722C27.8484,13.2445 27.9988,13.0693 28,12.8615L28,11.6379C27.9995,11.5207 27.9508,11.4092 27.8658,11.3307C27.7809,11.2523 27.6675,11.2141 27.5537,11.2257"
android:strokeWidth="1"
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
</vector>
<?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="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:background="#ff002222">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/csl_layout"
android:layout_width="104dp"
android:layout_height="36dp"
android:background="@drawable/bg_meditation_play_top"
android:layout_marginStart="16dp"
android:layout_marginTop="55dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/iv_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingHorizontal="16dp"
android:paddingVertical="8dp"
android:src="@drawable/icon_close_play_meditation"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
<View
android:layout_width="1dp"
android:layout_height="20dp"
android:background="#FF8E8E8E"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
<ImageView
android:id="@+id/iv_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_play_meditation_down_arrow"
android:paddingHorizontal="16dp"
android:paddingVertical="9dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<ImageView
android:id="@+id/iv_share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:layout_marginEnd="17dp"
android:src="@drawable/icon_play_meditation_share"
app:layout_constraintBottom_toBottomOf="@id/csl_layout"
app:layout_constraintTop_toTopOf="@id/csl_layout"
app:layout_constraintEnd_toEndOf="parent" />
<TextView
android:id="@+id/tv_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="150dp"
android:gravity="center"
android:textColor="@color/white"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/csl_layout"
tools:text="舒缓安神舒神舒缓安神舒缓安神舒缓安神舒缓安神" />
<TextView
android:id="@+id/tv_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="12dp"
android:gravity="center"
android:textColor="@color/white"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_title"
tools:text="舒缓安神舒缓安神舒缓安神舒缓安神舒缓安神舒缓安神舒缓安神舒缓安神" />
<ImageView
android:id="@+id/iv_play_or_pause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_pause_meditation"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="60dp"/>
<androidx.appcompat.widget.AppCompatSeekBar
android:id="@+id/seekbar_play_progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="64dp"
android:layout_marginBottom="50dp"
android:thumb="@drawable/play_meditation_thumb"
android:progress="50"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/iv_play_or_pause"/>
<TextView
android:id="@+id/tv_current_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="12dp"
android:textColor="#B3FFFFFF"
android:textSize="12sp"
app:layout_constraintEnd_toStartOf="@id/seekbar_play_progress"
app:layout_constraintTop_toTopOf="@id/seekbar_play_progress"
app:layout_constraintBottom_toBottomOf="@id/seekbar_play_progress"
tools:text="03:46"/>
<TextView
android:id="@+id/tv_total_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="12dp"
android:textColor="#B3FFFFFF"
android:textSize="12sp"
app:layout_constraintStart_toEndOf="@id/seekbar_play_progress"
app:layout_constraintTop_toTopOf="@id/seekbar_play_progress"
app:layout_constraintBottom_toBottomOf="@id/seekbar_play_progress"
tools:text="13:46"/>
<ImageView
android:id="@+id/iv_time_off"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="48dp"
android:src="@drawable/icon_play_meditation_time_off"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/seekbar_play_progress"/>
<ImageView
android:id="@+id/iv_collect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="56dp"
android:layout_marginBottom="48dp"
android:src="@drawable/icon_play_meditation_collect"
app:layout_constraintEnd_toStartOf="@id/iv_time_off"
app:layout_constraintBottom_toTopOf="@id/seekbar_play_progress"/>
<ImageView
android:id="@+id/iv_play_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="56dp"
android:layout_marginBottom="48dp"
android:src="@drawable/icon_pure_music_list"
app:layout_constraintStart_toEndOf="@id/iv_time_off"
app:layout_constraintBottom_toTopOf="@id/seekbar_play_progress"/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.tabs.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="50dp"/>
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
\ No newline at end of file
......@@ -7,4 +7,13 @@
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsTranslucent">true</item>
</style>
<style name="share_meditation_dialog" parent="Theme.Design.BottomSheetDialog">
<item name="android:windowIsFloating">true</item>
<item name="android:statusBarColor">@color/transparent</item>
<item name="android:windowSoftInputMode">adjustResize</item>
</style>
</resources>
\ 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