Commit 7da17db6 by 万齐军

feature: 倾诉首页ui,与点击事件

parent 31597ce1
......@@ -2,13 +2,15 @@ package com.ydl.confide.home
import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Color
import android.os.Build
import android.view.View
import android.widget.LinearLayout
import android.view.WindowManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.SimpleItemAnimator
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.jcodecraeer.xrecyclerview.ProgressStyle
......@@ -31,17 +33,18 @@ import com.ydl.confide.router.PhoneCallIn
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydl_image.listener.YDLImageRecyclerOnScrollListener
import com.ydl.ydlcommon.base.config.HttpConfig.Companion.H5_URL
import com.ydl.ydlcommon.base.config.HttpConfig.Companion.YDL_H5
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.mvp.lce.BaseLceActivity
import com.ydl.ydlcommon.utils.BuryPointUtils
import com.ydl.ydlcommon.utils.StatusBarUtils
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.ydl.ydlcommon.view.DrawableRightTextView
import com.ydl.ydlcommon.view.WrapContentLinearLayoutManager
import com.yidianling.common.tools.RxImageTool
import com.yidianling.consultant.api.IConsultantService
import com.yidianling.im.api.service.IImService
import kotlinx.android.synthetic.main.confide_home_activity.*
import kotlinx.android.synthetic.main.confide_title_bar.*
......@@ -187,7 +190,7 @@ class ConfideHomeActivity : BaseLceActivity<IConfideHomeContract.View,IConfideHo
initClick()
initQuickConsultDialog()
initStatus();
initStatusBar()
ModularServiceManager.provide(IConsultantService::class.java).showConfideListDialog(this)
ActionCountUtils.count("daoyi_advertisement_page|daoyi_advertisement_visit","17")
Glide.with(this)
......@@ -200,13 +203,12 @@ class ConfideHomeActivity : BaseLceActivity<IConfideHomeContract.View,IConfideHo
/**
* 初始化状态栏位置
*/
private fun initStatus() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//4.4以下不支持状态栏变色
StatusBarUtils.setTransparentForImageView(this, null)
val statusBarHeight = StatusBarUtils.getStatusBarHeight(this)
val lp1 = rl_confide_title_layout.layoutParams as LinearLayout.LayoutParams
lp1.height = (RxImageTool.dp2px(48f) + statusBarHeight)
rl_confide_title_layout.setPadding(0, statusBarHeight, 0, 0)
private fun initStatusBar() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
window?.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
window?.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window?.statusBarColor = Color.WHITE
window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
}
}
......@@ -257,6 +259,15 @@ class ConfideHomeActivity : BaseLceActivity<IConfideHomeContract.View,IConfideHo
val h5Paramsqing = H5Params(YDL_H5 + "confideOrderList", null)
NewH5Activity.start(this, h5Paramsqing)
}
findViewById<View>(R.id.img_customer)?.setOnClickListener {
val imService = ARouter.getInstance().navigation(IImService::class.java)
imService?.startKefuChat(this, "", 0, 0)
}
findViewById<View>(R.id.img_help)?.setOnClickListener {
val params = H5Params(H5_URL + "help/", "")
params.isShowMenu = true
NewH5Activity.start(this, params)
}
ll_bar_root.setOnClickListener {
}
......
......@@ -153,8 +153,7 @@ class ConfideHomeAdapter(private val mContext: Context,
holder.rv.layoutManager =
LinearLayoutManager(holder.itemView.context, RecyclerView.HORIZONTAL, false)
val recentBody = mListData!![position].body
val data = recentBody?.map { ItemVideoShowViewModel().mapOf(it) } ?: emptyList()
holder.rv.adapter = VideoShowAdapter(data, confideHomeEvent)
holder.rv.adapter = VideoShowAdapter(recentBody, confideHomeEvent)
} else if (holder is EmptyViewHolder) {
} else {
......
......@@ -9,12 +9,12 @@ import com.ydl.confide.R
import com.ydl.confide.databinding.ItemConfideHomeRecentBinding
import com.ydl.confide.databinding.ItemVideoShowBinding
import com.ydl.confide.home.bean.ConfideHomeBodyBean
import com.ydl.confide.home.bean.ConfideHomeDataBean
import com.ydl.confide.home.event.IConfideHomeEvent
import com.ydl.confide.intro.BindingViewHolder
class VideoShowAdapter(private val data: List<ItemVideoShowViewModel>, private val event: IConfideHomeEvent) :
class VideoShowAdapter(private val data: List<ConfideHomeBodyBean>?, private val event: IConfideHomeEvent) :
RecyclerView.Adapter<BindingViewHolder<ItemVideoShowBinding>>() {
private val dataList:List<ItemVideoShowViewModel> = data?.map { ItemVideoShowViewModel().mapOf(it) } ?: emptyList()
override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int
......@@ -26,12 +26,12 @@ class VideoShowAdapter(private val data: List<ItemVideoShowViewModel>, private v
}
override fun onBindViewHolder(holder: BindingViewHolder<ItemVideoShowBinding>, position: Int) {
val itemVideoShowViewModel = data[position]
val itemVideoShowViewModel = dataList[position]
holder.binding.item = itemVideoShowViewModel
holder.itemView.setOnClickListener { event.videoShowClick(position) }
holder.itemView.setOnClickListener { event.videoShowClick(position, data) }
}
override fun getItemCount() = data.size
override fun getItemCount() = dataList.size
}
......
......@@ -13,6 +13,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialog
import com.tencent.smtt.sdk.WebSettings
import com.ydl.confide.R
import com.alibaba.android.arouter.launcher.ARouter
import com.alibaba.fastjson.JSON
import com.ydl.confide.api.ConfideRoute
import com.ydl.confide.home.ConfideHomeActivity
import com.ydl.confide.home.adapter.ConfideHomeAdapter
......@@ -185,8 +186,10 @@ class ConfideHomeEventImpl(context: Context, var confideHomeView: IConfideHomeCo
// link(linkUrl)
}
override fun videoShowClick(index: Int) {
ARouter.getInstance().build(ConfideRoute.R_VIDEO_SHOW).withInt("initPos", index).navigation()
override fun videoShowClick(index: Int, data: List<ConfideHomeBodyBean>?) {
val dataJson = if (data != null) JSON.toJSONString(data) else null
ARouter.getInstance().build(ConfideRoute.R_VIDEO_SHOW).withInt("initPos", index)
.withString("initData", dataJson).navigation()
}
/**
......
......@@ -75,7 +75,7 @@ interface IConfideHomeEvent {
*/
fun consultantClick(linkUrl: String?)
fun videoShowClick(index: Int)
fun videoShowClick(index: Int, data: List<ConfideHomeBodyBean>?)
/**
* 咨询师推荐--更多情感恋爱专家
......
......@@ -9,10 +9,19 @@ import androidx.databinding.DataBindingUtil
import androidx.viewpager2.widget.ViewPager2
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.alibaba.fastjson.JSON
import com.ydl.confide.R
import com.ydl.confide.api.ConfideRoute
import com.ydl.confide.databinding.ActivityExpertIntroBinding
import com.ydl.confide.home.bean.ConfideHomeBodyBean
import com.ydl.confide.home.bean.ConfideHomeDataBean
import com.ydl.confide.home.util.ConfideNetworkUtil
import com.ydl.confide.router.PhoneCallIn
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydlcommon.base.config.HttpConfig.Companion.YDL_H5
import com.ydl.ydlcommon.utils.BuryPointUtils
import com.ydl.ydlcommon.view.dialog.CommonDialog
......@@ -22,7 +31,10 @@ class ExpertIntroActivity : AppCompatActivity() {
@Autowired
@JvmField
var initPos: Int = 0
@Autowired
@JvmField
var initData:String?=null
private var lastSelectPos = 0
private lateinit var binding: ActivityExpertIntroBinding
private lateinit var adapter: IntroAdapter
......@@ -30,6 +42,7 @@ class ExpertIntroActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
ARouter.getInstance().inject(this)
binding = DataBindingUtil.setContentView(this, R.layout.activity_expert_intro)
if (Build.VERSION.SDK_INT >= 21) {
val decorView = window.decorView
......@@ -38,7 +51,22 @@ class ExpertIntroActivity : AppCompatActivity() {
decorView.systemUiVisibility = option
window.statusBarColor = Color.TRANSPARENT
}
if(initData!=null){
val beans = JSON.parseArray(initData, ConfideHomeBodyBean::class.java)
val vms = beans.map { VideoViewModel().mapOf(it) }
data.addAll(vms)
}
binding.ivBack.setOnClickListener { onBackPressed() }
binding.tvConfideRecord.setOnClickListener {
if (!PhoneCallIn.loginByOneKeyLogin(this,true)) {
return@setOnClickListener
}
BuryPointUtils.getInstance().createMap()
.put("mine_name", "倾诉记录")
.burryPoint("mine")
val h5Paramsqing = H5Params(YDL_H5 + "confideOrderList", null)
NewH5Activity.start(this, h5Paramsqing)
}
data.add(VideoViewModel())
data.add(VideoViewModel())
data.add(VideoViewModel())
......@@ -51,9 +79,10 @@ class ExpertIntroActivity : AppCompatActivity() {
binding.viewPager.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
override fun onPageSelected(position: Int) {
adapter.onSelect(position)
if (position == data.size - 1) {
if (position == data.size - 1 && lastSelectPos < position) {
loadMore()
}
lastSelectPos = position
}
})
adapter.checkNetwork()
......
......@@ -42,13 +42,12 @@ internal class IntroAdapter(
false
)
val holder = ItemIntroHolder(binding)
lifecycleOwner.lifecycle.addObserver(holder)
return holder
}
override fun onBindViewHolder(holder: ItemIntroHolder, position: Int) {
holder.onBind()
val item = data[position]
holder.onBind(item)
holder.binding.item = item
}
......@@ -105,7 +104,6 @@ internal class IntroAdapter(
val video = videoViews.get(adapterPosition)
video?.release(true)
videoViews.remove(adapterPosition)
lifecycleOwner.lifecycle.removeObserver(holder)
holder.onDetach()
}
......@@ -120,6 +118,18 @@ internal class IntroAdapter(
}
}
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
private fun onResume() {
val ijkVideoView = videoViews[curPos]
ijkVideoView?.start()
}
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
private fun onPause() {
val ijkVideoView = videoViews[curPos]
ijkVideoView?.pause()
}
fun onSelect(position: Int) {
curPos = position
if (!ConfideNetworkUtil.isWifi(context) && !hasAgreePlayWithoutWiFi) {
......
package com.ydl.confide.intro
import android.app.Activity
import android.util.Log
import android.view.View
import android.widget.SeekBar
import androidx.databinding.ObservableField
import androidx.databinding.ObservableInt
import androidx.databinding.ViewDataBinding
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent
import androidx.recyclerview.widget.RecyclerView
import com.alibaba.android.arouter.launcher.ARouter
import com.dou361.ijkplayer.widget.IjkVideoView
import com.ydl.confide.databinding.ItemExpertIntroBinding
import com.ydl.confide.home.bean.ConfideHomeBodyBean
import com.ydl.ydlcommon.view.dialog.YDLShareDialog
import com.yidianling.im.api.service.IImService
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
......@@ -20,7 +22,7 @@ import tv.danmaku.ijk.media.player.IjkMediaPlayer
import java.util.concurrent.TimeUnit
internal class ItemIntroHolder(binding: ItemExpertIntroBinding) :
BindingViewHolder<ItemExpertIntroBinding>(binding), LifecycleObserver {
BindingViewHolder<ItemExpertIntroBinding>(binding) {
companion object {
private const val TAG = "ItemIntroHolder"
}
......@@ -33,11 +35,23 @@ internal class ItemIntroHolder(binding: ItemExpertIntroBinding) :
video?.release(true)
}
fun onBind() {
fun onBind(item: VideoViewModel) {
binding.btnCall.setOnClickListener { }
binding.btnChat.setOnClickListener { }
binding.btnChat.setOnClickListener {
val aty = it.context as? Activity
if (aty != null && !item.uid.isNullOrEmpty()) {
ARouter.getInstance().navigation(IImService::class.java)?.startChat(aty, item.uid!!, 0, 0)
}
}
binding.btnEvaluate.setOnClickListener { }
binding.btnShare.setOnClickListener { }
binding.vDisableClick.setOnClickListener { }
binding.btnShare.setOnClickListener {
val aty = it.context as? Activity
if (aty != null) {
val dialog = YDLShareDialog.style8(aty, "title", "url", ";sss", "head")
dialog.show(aty.fragmentManager, "share")
}
}
binding.videoView.setOnClickListener {
video?.pause()
binding.ivPlay.visibility = View.VISIBLE
......@@ -99,17 +113,6 @@ internal class ItemIntroHolder(binding: ItemExpertIntroBinding) :
private fun stopTiming() {
disposable?.dispose()
}
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
private fun onResume() {
video?.onResume()
}
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
private fun onPause() {
video?.onPause()
}
}
class VideoViewModel {
......@@ -118,11 +121,35 @@ class VideoViewModel {
val count = ObservableInt()
val intro = ObservableField<String>("")
val tag = ObservableField<String>("")
var playUrl: String? = "https://video.ydlcdn.com/2020/04/01/ac2e4bb4e3ac8e2f0eca41e2d49c8484.mp4"
var coverUrl: String? = null
var playUrl: String? = null//"https://video.ydlcdn.com/2020/04/01/ac2e4bb4e3ac8e2f0eca41e2d49c8484.mp4"
var coverUrl = ObservableField<String>("")
var isVideo = true
var uid: String? = null
var linkUrl: String? = null
}
internal fun VideoViewModel.mapOf(bean: ConfideHomeBodyBean): VideoViewModel {
name.set(bean.confidedName)
avatar.set(bean.confidedIcon)
// count.set(bean.confideHearNum)
intro.set(bean.categoryContent)
val sb = StringBuilder()
bean.confidedTag?.forEach { sb.append(it).append("|") }
sb.setLength(sb.length - 1)
tag.set(sb.toString())
if (bean.videoUrl != null) {
playUrl = bean.videoUrl
isVideo = true
coverUrl.set(bean.coverVideoPicture)
} else {
playUrl = bean.confideVoice
isVideo = false
coverUrl.set(bean.coverPicture)
}
uid = bean.uid?.toString()
linkUrl = bean.linkUrl
return this
}
open class BindingViewHolder<T : ViewDataBinding>(val binding: T) :
RecyclerView.ViewHolder(binding.root)
\ No newline at end of file
......@@ -28,14 +28,17 @@
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:shape="@{1}"
app:shapeBg="@{0x33ff0000}"
app:shapeBg="@{0x33000000}"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/tvConfideRecord"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="16dp"
android:drawableLeft="@drawable/ic_confide_record"
android:drawablePadding="4dp"
android:gravity="center"
android:padding="8dp"
android:paddingHorizontal="8dp"
......@@ -46,9 +49,10 @@
app:layout_constraintBottom_toBottomOf="@+id/ivBack"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/ivBack"
app:shapeBg="@{0x26f00000}"
app:shapeBg="@{0x26000000}"
app:shapeRadius="@{15}"
app:shapeStrokeColor="@{0xFFFFFF}" />
app:shapeStrokeWidth="@{1}"
app:shapeStrokeColor="@{0xFFFFFFFF}" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
......@@ -5,7 +5,7 @@
android:id="@+id/rl_confide_title_layout"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/confide_common_bg"
android:background="@color/white"
android:orientation="horizontal">
<androidx.constraintlayout.widget.ConstraintLayout
......@@ -20,7 +20,7 @@
android:layout_height="0dp"
android:layout_gravity="center_vertical"
android:scaleType="center"
android:src="@drawable/confide_back"
android:src="@drawable/platform_common_back"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
......@@ -32,7 +32,7 @@
android:layout_weight="1"
android:gravity="center"
android:text="@string/confide_title"
android:textColor="#FFFFFF"
android:textColor="@color/black"
android:textSize="17dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
......
......@@ -35,6 +35,15 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/vDisableClick"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/tvName" />
<SeekBar
android:id="@+id/seekbar"
android:layout_width="0dp"
......@@ -42,7 +51,9 @@
android:layout_marginBottom="23dp"
android:maxHeight="4dp"
android:paddingStart="0dp"
android:paddingTop="4dp"
android:paddingEnd="0dp"
android:paddingBottom="4dp"
android:progressDrawable="@drawable/confide_seekbar_style"
android:splitTrack="false"
android:thumb="@drawable/confide_seekbar_thumb"
......@@ -116,6 +127,8 @@
android:layout_marginRight="18dp"
android:layout_marginBottom="56dp"
android:drawableTop="@drawable/ic_video_share"
android:drawablePadding="6dp"
android:gravity="center_horizontal"
android:text="分享"
android:textColor="@color/white"
android:textSize="11sp"
......@@ -129,6 +142,8 @@
android:layout_marginRight="18dp"
android:layout_marginBottom="20dp"
android:drawableTop="@drawable/ic_video_eval"
android:drawablePadding="6dp"
android:gravity="center_horizontal"
android:text="评价"
android:textColor="@color/white"
android:textSize="11sp"
......@@ -141,7 +156,9 @@
android:layout_height="wrap_content"
android:layout_marginRight="18dp"
android:layout_marginBottom="20dp"
android:drawableTop="@drawable/ic_chat"
android:drawableTop="@drawable/ic_video_chat"
android:drawablePadding="6dp"
android:gravity="center_horizontal"
android:text="私聊"
android:textColor="@color/white"
android:textSize="11sp"
......@@ -152,6 +169,8 @@
android:layout_width="46dp"
android:layout_height="46dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="20dp"
app:imageUrl="@{item.avatar}"
app:layout_constraintBottom_toTopOf="@+id/btnChat"
app:layout_constraintRight_toRightOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
......
......@@ -90,6 +90,7 @@ class YDLShareDialog : DialogFragment {
const val TYPE5 = 5
const val TYPE6 = 6
const val TYPE7 = 7
const val TYPE8 = 8
/**
* 点击事件类型 1.动态 2.删除 3.举报 4.返回首页 5:生成海报 6:保存本地 7:分享纯图片
*/
......@@ -142,6 +143,11 @@ class YDLShareDialog : DialogFragment {
typeStyle = TYPE7
return YDLShareDialog(activity, shareTitle, shareUrl, shareContent, shareHead, minProgramPath, minProgramId)
}
//只有微信和朋友圈
fun style8(activity: Activity, shareTitle: String?, shareUrl: String?, shareContent: String?, shareHead: String?): YDLShareDialog {
typeStyle = TYPE8
return YDLShareDialog(activity, shareTitle, shareUrl, shareContent, shareHead)
}
}
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View {
......@@ -229,6 +235,12 @@ class YDLShareDialog : DialogFragment {
ll_layout2.visibility = View.GONE
ll_dynamic.visibility = View.GONE
}
TYPE8 -> {
ll_layout2.visibility = View.GONE
ll_dynamic.visibility = View.GONE
ll_qq.visibility = View.GONE
ll_qqzone.visibility = View.GONE
}
}
showPictureView()
......
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