Commit 7dcfd45a by 万齐军

Merge branch 'feat/qj/confide_2.0' into 'd/v_confide_2.0'

confide 2.0

See merge request app_android_lib/YDL-Component!7
parents 9291e1d9 53610264
......@@ -170,6 +170,9 @@ android {
packagingOptions {
exclude 'META-INF/proguard/coroutines.pro'
}
dataBinding {
enabled true
}
}
......@@ -249,4 +252,6 @@ dependencies {
implementation rootProject.ext.dependencies["retrofit-url-manager"]
kapt 'com.alibaba:arouter-compiler:1.2.2'
implementation "androidx.fragment:fragment:1.2.4"
implementation 'tv.danmaku.ijk.media:ijkplayer-java:0.8.8'
}
......@@ -31,8 +31,6 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
//bugly 符号表
classpath 'com.tencent.bugly:symtabfileuploader:2.2.1'
classpath 'com.ydl.plugins:modular:1.0.3'
classpath 'com.ydl:notracepoint-gradle-plugin:0.0.3'
classpath 'com.ydl.plugins:restools:1.0.1'
......
......@@ -9,7 +9,7 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m
org.gradle.jvmargs=-Xmx4096m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
......
......@@ -50,6 +50,9 @@ android {
buildConfigField "String", "AGORA_APPID", '"3387e9b251f3491e9221a9877e8f7830"'
}
}
dataBinding {
enabled true
}
publishNonDefault true
productFlavors {
......@@ -89,6 +92,7 @@ dependencies {
api project(':m-audioim')
api project(":ydl-pay")
api project(':ydl-webview')
api project(':ydl-utils')
implementation modularPublication('com.ydl:m-im-api')
implementation modularPublication('com.ydl:m-user-api')
implementation modularPublication('com.ydl:m-confide-api')
......
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ydl.confide" >
package="com.ydl.confide">
<application>
<activity android:name=".home.ConfideHomeActivity"
<activity
android:name=".home.ConfideHomeActivity"
android:screenOrientation="portrait"
android:theme="@style/confide_NoTitleTheme"
>
</activity>
android:theme="@style/confide_NoTitleTheme"/>
<activity
android:name=".intro.ExpertIntroActivity"
android:screenOrientation="portrait" />
</application>
</manifest>
......@@ -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
......@@ -27,21 +29,23 @@ import com.ydl.confide.home.listener.ConfideHomeRecycleViewListener
import com.ydl.confide.home.listener.ConfideHomeRecyleSuspendListener
import com.ydl.confide.home.presenter.ConfideHomePresenterImpl
import com.ydl.confide.home.util.ConfideHomeUtils
import com.ydl.confide.home.widget.FilterItemDecoration
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 +191,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 +204,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 +260,18 @@ class ConfideHomeActivity : BaseLceActivity<IConfideHomeContract.View,IConfideHo
val h5Paramsqing = H5Params(YDL_H5 + "confideOrderList", null)
NewH5Activity.start(this, h5Paramsqing)
}
findViewById<View>(R.id.img_customer)?.setOnClickListener {
if (!PhoneCallIn.loginByOneKeyLogin(this, true)) {
return@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 {
}
......@@ -283,6 +298,7 @@ class ConfideHomeActivity : BaseLceActivity<IConfideHomeContract.View,IConfideHo
if (null == mConfideAdapter) {
mConfideAdapter = ConfideHomeAdapter(ConfideHomeActivity@ this, mConfideEvent!!, this)
}
rv_list.addItemDecoration(FilterItemDecoration())
val layoutManager = WrapContentLinearLayoutManager(this, WrapContentLinearLayoutManager.VERTICAL, false)
rv_list.layoutManager = layoutManager
rv_list.setRefreshProgressStyle(ProgressStyle.BallSpinFadeLoader)
......
......@@ -4,12 +4,14 @@ import android.content.Context
import androidx.recyclerview.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.ydl.confide.R
import com.ydl.confide.home.bean.ConfideHomeDataBean
import com.ydl.confide.home.config.IConfideHomeConfig
import com.ydl.confide.home.contract.IConfideHomeContract
import com.ydl.confide.home.event.IConfideHomeEvent
import com.ydl.confide.home.widget.*
import com.ydl.ydlcommon.utils.DisplayUtils
/**
* @author yuanwai
......@@ -73,17 +75,26 @@ class ConfideHomeAdapter(private val mContext: Context,
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
when (viewType) {
//banner
IConfideHomeConfig.TYPE_BANNER -> {
return BannerViewHolder(ConfideHomeBannerView(parent.context, confideHomeEvent))
}
// IConfideHomeConfig.TYPE_BANNER -> {
// return BannerViewHolder(ConfideHomeBannerView(parent.context, confideHomeEvent))
// }
//最近倾诉
IConfideHomeConfig.TYPE_RECENTLY_CONFIDED -> {
return ConsultViewHolder(ConfideHomeRecentView(parent.context, confideHomeEvent))
// return ConsultViewHolder(ConfideHomeRecentView(parent.context, confideHomeEvent))
val recyclerView = RecyclerView(parent.context)
recyclerView.layoutParams = ViewGroup.MarginLayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
).apply {
leftMargin = DisplayUtils.dip2px(parent.context, 4F)
rightMargin = DisplayUtils.dip2px(parent.context, 4F)
}
return RecentConfideHolder(recyclerView)
}
//分类
IConfideHomeConfig.TYPE_CATEGORY -> {
return CategoryViewHolder(ConfideHomeCategoryView(parent.context, confideHomeEvent, confideHomeView))
}
// IConfideHomeConfig.TYPE_CATEGORY -> {
// return CategoryViewHolder(ConfideHomeCategoryView(parent.context, confideHomeEvent, confideHomeView))
// }
//筛选模块
IConfideHomeConfig.TYPE_RECOMMEND_FILTER -> {
return FilterViewHolder(ConfideHomeFilterView(parent.context, confideHomeView))
......@@ -92,6 +103,17 @@ class ConfideHomeAdapter(private val mContext: Context,
IConfideHomeConfig.TYPE_RECOMMEND -> {
return RecommendViewHolder(ConfideHomeRecommendView(confideHomeView, parent.context, confideHomeEvent))
}
IConfideHomeConfig.TYPE_VIDEO_SHOW -> {
val recyclerView = RecyclerView(parent.context)
recyclerView.layoutParams = ViewGroup.MarginLayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
).apply {
leftMargin = DisplayUtils.dip2px(parent.context, 6F)
rightMargin = DisplayUtils.dip2px(parent.context, 6F)
}
return VideoShowHolder(recyclerView)
}
// //听声寻人
// IConfideHomeConfig.TYPE_SOUND -> {
//// return ConfideHomeListenAndFoundViewHolder(ConfideHomeListenAndFoundView(parent.context, confideHomeEvent))
......@@ -103,25 +125,35 @@ class ConfideHomeAdapter(private val mContext: Context,
}
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) =
if (holder is BannerViewHolder && null != holder.bannerView) {
/*if (holder is BannerViewHolder && null != holder.bannerView) {
//banner
holder.bannerView!!.initData(mListData!![position])
} else if (holder is CategoryViewHolder && null != holder.categoryView) {
//分类
holder.categoryView!!.initData(mListData!![position])
} else if (holder is FilterViewHolder && null != holder.filterView) {
} else */if (holder is FilterViewHolder && null != holder.filterView) {
mFilterViewHolder = holder
//筛选模块
holder.filterView.initData(mListData!![position])
} else if (holder is ConfideHomeListenAndFoundViewHolder) {
//听声寻人
// holder.confideHomeListenAndFoundView!!.initData(mListData!![position])
} else if (holder is ConsultViewHolder && null != holder.consultView) {
//最近倾诉
holder.consultView!!.initData(mListData!![position])
} else if (holder is RecentConfideHolder) {
//最近倾诉
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 = RecentConfideAdapter(data, confideHomeEvent)
// holder.consultView!!.initData(mListData!![position])
} else if (holder is RecommendViewHolder && null != mListData!![position] && null != mListData!![position].body && !mListData!![position].body!!.isEmpty()) {
//为你推荐
holder.confideHomeRecommendView.initData(mListData!![position].body!![0], position, mListData!![position].recommendId)
} else if (holder is VideoShowHolder) {
holder.rv.layoutManager =
LinearLayoutManager(holder.itemView.context, RecyclerView.HORIZONTAL, false)
val recentBody = mListData!![position].body
holder.rv.adapter = VideoShowAdapter(recentBody, confideHomeEvent)
} else if (holder is EmptyViewHolder) {
} else {
......@@ -184,4 +216,6 @@ class ConfideHomeAdapter(private val mContext: Context,
view = itemView
}
}
class VideoShowHolder(val rv: RecyclerView) : RecyclerView.ViewHolder(rv)
class RecentConfideHolder(val rv: RecyclerView) : RecyclerView.ViewHolder(rv)
}
\ No newline at end of file
package com.ydl.confide.home.adapter
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.databinding.ObservableField
import androidx.databinding.ObservableInt
import androidx.recyclerview.widget.RecyclerView
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.event.IConfideHomeEvent
import com.ydl.confide.intro.BindingViewHolder
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
): BindingViewHolder<ItemVideoShowBinding> {
val layoutInflater = LayoutInflater.from(parent.context)
val binding =
DataBindingUtil.inflate<ItemVideoShowBinding>(layoutInflater, R.layout.item_video_show, parent, false)
return BindingViewHolder(binding)
}
override fun onBindViewHolder(holder: BindingViewHolder<ItemVideoShowBinding>, position: Int) {
val itemVideoShowViewModel = dataList[position]
holder.binding.item = itemVideoShowViewModel
holder.itemView.setOnClickListener { /*event.videoShowClick(position, data)*/ }
}
override fun getItemCount() = dataList.size
}
class RecentConfideAdapter(val data: List<ItemVideoShowViewModel>, private val event: IConfideHomeEvent) :
RecyclerView.Adapter<BindingViewHolder<ItemConfideHomeRecentBinding>>() {
override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int
): BindingViewHolder<ItemConfideHomeRecentBinding> {
val layoutInflater = LayoutInflater.from(parent.context)
val binding =
DataBindingUtil.inflate<ItemConfideHomeRecentBinding>(
layoutInflater,
R.layout.item_confide_home_recent,
parent,
false
)
return BindingViewHolder(binding)
}
override fun onBindViewHolder(holder: BindingViewHolder<ItemConfideHomeRecentBinding>, position: Int) {
val itemVideoShowViewModel = data[position]
holder.binding.item = itemVideoShowViewModel
holder.itemView.setOnClickListener { event.consultantClick(itemVideoShowViewModel.linkUrl) }
}
override fun getItemCount() = data.size
}
class ItemVideoShowViewModel {
var linkUrl: String? = null
val name = ObservableField<String>("")
val coverUrl = ObservableField<String>("")
val videoCoverUrl = ObservableField<String>("")
val state = ObservableInt()
}
internal fun ItemVideoShowViewModel.mapOf(bean: ConfideHomeBodyBean): ItemVideoShowViewModel {
name.set(bean.confidedName)
coverUrl.set(bean.coverPicture)
videoCoverUrl.set(bean.coverVideoPicture)
state.set(bean.confideLine?:0)
linkUrl = bean.linkUrl
return this
}
......@@ -50,6 +50,9 @@ data class ConfideHomeBodyBean(
val couponMoney : String?,
//新用户优惠文案
val couponText : String?,
val videoUrl: String?,
val coverVideoPicture: String?,
val coverPicture: String?,
/**
* banner数据
*/
......
......@@ -30,8 +30,4 @@ data class ConfideHomeDataBean(
/**
* 为你推荐Id 本地使用 用于区分音频播放区域
*/
var recommendId : Int,
/**
* 是否显示分割线 0.不显示 1.显示
*/
val diviLine : Int?)
\ No newline at end of file
var recommendId : Int)
\ No newline at end of file
package com.ydl.confide.home.bean
class DialStatus {
var confideLine: Int? = null
}
\ No newline at end of file
......@@ -19,7 +19,7 @@ interface IConfideHomeConfig{
const val TYPE_RECOMMEND_FILTER = 4
const val TYPE_RECOMMEND = 5
const val TYPE_SOUND = 6
const val TYPE_CONSULTANT = 7
const val TYPE_VIDEO_SHOW = 7
const val TYPE_FOOTER = 999
/**
* section id. 与上面相对应
......
......@@ -5,15 +5,16 @@ import android.app.Activity
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.text.TextUtils
import android.view.MotionEvent
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.google.android.material.bottomsheet.BottomSheetBehavior
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
import com.ydl.confide.home.bean.ConfideHomeAllFiltersBean
......@@ -186,6 +187,12 @@ class ConfideHomeEventImpl(context: Context, var confideHomeView: IConfideHomeCo
// link(linkUrl)
}
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()
}
/**
* 最佳倾诉榜单--更多情感恋爱专家
* @param linkUrl 跳转地址
......@@ -272,9 +279,6 @@ class ConfideHomeEventImpl(context: Context, var confideHomeView: IConfideHomeCo
//听声寻人
IConfideHomeConfig.TYPE_SOUND -> {
}
//咨询师推荐
IConfideHomeConfig.TYPE_CONSULTANT -> {
}
}
}
......
......@@ -75,6 +75,8 @@ interface IConfideHomeEvent {
*/
fun consultantClick(linkUrl: String?)
fun videoShowClick(index: Int, data: List<ConfideHomeBodyBean>?)
/**
* 咨询师推荐--更多情感恋爱专家
* @param linkUrl 跳转地址
......
......@@ -2,6 +2,7 @@ package com.ydl.confide.home.http
import com.ydl.confide.home.bean.ConfideConnectResponse
import com.ydl.confide.home.bean.ConfideHomeDataBean
import com.ydl.confide.home.bean.DialStatus
import com.ydl.ydlcommon.base.config.YDL_DOMAIN
import com.ydl.ydlcommon.base.config.YDL_DOMAIN_JAVA
import com.ydl.ydlcommon.data.http.BaseAPIResponse
......@@ -33,4 +34,8 @@ interface ConfideHomeApi {
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA, "Content-Type:application/json")
@GET("auth/listen/dial")
fun connectJava(@QueryMap params: Map<String, String>): Observable<BaseAPIResponse<ConfideConnectResponse>>
// 1=在线 3-通话中 2-离线
@GET("auth/listen/dialchangestatus")
fun getDialStatus(@Query("doctorId") doctorId: String): Observable<BaseAPIResponse<DialStatus>>
}
\ No newline at end of file
......@@ -101,7 +101,7 @@ class ConfideHomeUtils {
}
//移除听声寻人数据 放在最后
if (dataBean.type == IConfideHomeConfig.TYPE_SOUND) {
soundDataBean = ConfideHomeDataBean(dataBean.type, dataBean.body, dataBean.head, dataBean.footer, dataBean.recommendId, dataBean.diviLine)
soundDataBean = ConfideHomeDataBean(dataBean.type, dataBean.body, dataBean.head, dataBean.footer, dataBean.recommendId)
list.removeAt(index)
}
}
......@@ -124,7 +124,7 @@ class ConfideHomeUtils {
for (bodyBean in dataBean.body) {
val bodyList: MutableList<ConfideHomeBodyBean> = ArrayList()
bodyList.add(bodyBean)
val recommendDataBean = ConfideHomeDataBean(dataBean.type, bodyList, dataBean.head, dataBean.footer, dataBean.recommendId, dataBean.diviLine)
val recommendDataBean = ConfideHomeDataBean(dataBean.type, bodyList, dataBean.head, dataBean.footer, dataBean.recommendId)
list.add(recommendDataBean)
}
return list
......@@ -174,12 +174,6 @@ class ConfideHomeUtils {
section.setData(resultBean)
mConfideAdapter?.addSection(section)
}
//最佳倾诉榜单 todo 产品说先隐藏掉
IConfideHomeConfig.TYPE_CONSULTANT -> {
// var section = ConfideHomeRecommendExpertSection(context,mConfideEvent)
// section.setData(resultBean)
// mConfideAdapter?.addSection(section)
}
//为你推荐筛选模块
IConfideHomeConfig.TYPE_RECOMMEND_FILTER -> {
var section = ConfideHomeFilterSection(context, view)
......@@ -254,10 +248,6 @@ class ConfideHomeUtils {
IConfideHomeConfig.TYPE_SOUND -> {
listenAndFoundData = resultBean
}
//最佳倾听榜单
IConfideHomeConfig.TYPE_CONSULTANT -> {
recommendExpertData = resultBean
}
}
}
......
package com.ydl.confide.home.util
import android.widget.TextView
import androidx.databinding.BindingAdapter
import com.ydl.confide.R
@BindingAdapter("confideLineText")
fun TextView.confideLineText(line: Int) {
when (line) {
1 -> {
text = "立即拨打"
}
2 -> {
text = "已离线"
}
3 -> {
text = "通话中"
}
}
}
@BindingAdapter("confideLineRecentText")
fun TextView.confideLineRecentText(line: Int) {
when (line) {
1 -> {
text = "空闲"
setBackgroundResource(R.drawable.confide_bg_main_color)
}
2 -> {
text = "离线"
setBackgroundResource(R.drawable.confide_bg_color_666666)
}
3 -> {
text = "通话中"
setBackgroundResource(R.drawable.confide_bg_color_ff8f38)
}
else ->{
text = ""
background = null
}
}
}
\ No newline at end of file
......@@ -153,7 +153,7 @@ class ConfideHomeRecommendExpertItemView(mContext: Context, private var confideH
if (confideIsPlay) {
confideHomeEvent.pauseVoice()
} else {
confideHomeEvent.playVoice(IConfideHomeConfig.TYPE_CONSULTANT, position, bodyBean.confideVoice)
confideHomeEvent.playVoice(IConfideHomeConfig.TYPE_VIDEO_SHOW, position, bodyBean.confideVoice)
}
}
}
......
package com.ydl.confide.home.widget
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.graphics.Rect
import android.view.View
import androidx.recyclerview.widget.RecyclerView
class FilterItemDecoration : RecyclerView.ItemDecoration() {
private val bounds = Rect()
private val paint = Paint().apply {
color = Color.parseColor("#EFEFF1")
strokeWidth = 1F
}
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
if (view is ConfideHomeFilterView) {
outRect.set(0, 0, 0, 1)
}
}
override fun onDraw(c: Canvas, parent: RecyclerView, state: RecyclerView.State) {
val count = parent.childCount
for (i in 0 until count) {
val child = parent.getChildAt(i)
if (child is ConfideHomeFilterView) {
parent.getDecoratedBoundsWithMargins(child, bounds)
c.drawLine(
bounds.left.toFloat(),
bounds.top.toFloat(),
bounds.right.toFloat(),
bounds.top.toFloat(),
paint
)
c.drawLine(
bounds.left.toFloat(),
bounds.bottom.toFloat(),
bounds.right.toFloat(),
bounds.bottom.toFloat(),
paint
)
}
}
}
}
\ No newline at end of file
package com.ydl.confide.intro
import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
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
@Route(path = ConfideRoute.R_VIDEO_SHOW)
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
private val data = mutableListOf<VideoViewModel>()
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
val option = (View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
or View.SYSTEM_UI_FLAG_LAYOUT_STABLE)
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())
data.add(VideoViewModel())
data.add(VideoViewModel())
binding.viewPager.orientation = ViewPager2.ORIENTATION_VERTICAL
binding.viewPager.offscreenPageLimit = 1
adapter = IntroAdapter(this, data, this)
binding.viewPager.adapter = adapter
binding.viewPager.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
override fun onPageSelected(position: Int) {
adapter.onSelect(position)
if (position == data.size - 1 && lastSelectPos < position) {
loadMore()
}
lastSelectPos = position
}
})
adapter.checkNetwork()
}
private fun loadMore() {
data.add(VideoViewModel())
data.add(VideoViewModel())
data.add(VideoViewModel())
data.add(VideoViewModel())
data.add(VideoViewModel())
adapter.notifyItemRangeInserted(data.size - 5, 5)
}
}
\ No newline at end of file
package com.ydl.confide.intro
import android.app.Activity
import android.content.Context
import android.net.Uri
import android.util.Log
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.OnLifecycleEvent
import androidx.recyclerview.widget.RecyclerView
import com.dou361.ijkplayer.widget.IjkVideoView
import com.ydl.confide.R
import com.ydl.confide.databinding.ItemExpertIntroBinding
import com.ydl.confide.home.http.ConfideHomeApi
import com.ydl.confide.home.util.ConfideNetworkUtil
import com.ydl.ydlcommon.view.dialog.CommonDialog
import com.ydl.ydlnet.YDLHttpUtils
import com.yidianling.common.tools.ToastUtil
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
internal class IntroAdapter(
private val context: Context,
private val data: List<VideoViewModel>,
private val lifecycleOwner: LifecycleOwner
) : RecyclerView.Adapter<ItemIntroHolder>(), LifecycleObserver {
private val videoViews = hashMapOf<Int, IjkVideoView>()
private var hasAgreePlayWithoutWiFi = false
private var curPos = 0
private var dispose: Disposable? = null
init {
lifecycleOwner.lifecycle.addObserver(this)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemIntroHolder {
val binding = DataBindingUtil.inflate<ItemExpertIntroBinding>(
LayoutInflater.from(parent.context),
R.layout.item_expert_intro,
parent,
false
)
val holder = ItemIntroHolder(binding)
return holder
}
override fun onBindViewHolder(holder: ItemIntroHolder, position: Int) {
val item = data[position]
holder.onBind(item)
holder.binding.item = item
}
override fun onViewAttachedToWindow(holder: ItemIntroHolder) {
val adapterPosition = holder.adapterPosition
val videoView = IjkVideoView(context)
if (hasAgreePlayWithoutWiFi || ConfideNetworkUtil.isWifi(context)) {
videoView.setVideoURI(Uri.parse("https://video.ydlcdn.com/2020/04/01/ac2e4bb4e3ac8e2f0eca41e2d49c8484.mp4"))
} else {
data[adapterPosition].playUrl?.let { videoView.tag = it }
}
videoViews.put(adapterPosition, videoView)
holder.onAttach(videoView)
}
internal fun checkNetwork() {
if (!ConfideNetworkUtil.isWifi(context)) {
val dialog = CommonDialog.create(context)
.setTitle(context.getString(R.string.confide_tip))
.setMessage(context.getString(R.string.confide_video_wifi_tip))
.setLeftOnclick("继续播放") {
hasAgreePlayWithoutWiFi = true
for (entry in videoViews.entries) {
val value = entry.value
(value.tag as? String)?.let {
value.setVideoURI(Uri.parse(it))
if (curPos == entry.key) {
value.start()
}
}
}
}
.setLeftButton_color(R.color.platform_but_text_color_selected)
.setRightButton_color(R.color.platform_text_bright_color)
.setRightClick("取消") {
if (context is Activity) {
context.onBackPressed()
}
}
.setCancelAble(true)
dialog.setOnCancelListener {
if (context is Activity) {
context.onBackPressed()
}
}
dialog.show()
}
}
override fun onViewDetachedFromWindow(holder: ItemIntroHolder) {
super.onViewDetachedFromWindow(holder)
val adapterPosition = holder.adapterPosition
val video = videoViews.get(adapterPosition)
video?.release(true)
videoViews.remove(adapterPosition)
holder.onDetach()
}
override fun getItemCount(): Int {
return data.size
}
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
private fun onDestroy() {
for (entry in videoViews.entries) {
entry.value.release(true)
}
}
@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
val confideApi = YDLHttpUtils.obtainApi(ConfideHomeApi::class.java)
val curUid = data[position].uid
if (curUid != null) {
dispose?.dispose()
dispose = confideApi.getDialStatus(curUid)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ resp ->
if (resp.code == "200") {
val lineStatus = resp.data?.confideLine ?: 2
data[position].lineStatus.set(lineStatus)
} else {
if (!resp.msg.isNullOrEmpty()) {
ToastUtil.toastShort(resp.msg)
}
}
}, { throwable -> throwable.printStackTrace() })
}
if (!ConfideNetworkUtil.isWifi(context) && !hasAgreePlayWithoutWiFi) {
return
}
for (entry in videoViews.entries) {
if (entry.key == position) {
entry.value.seekTo(0)
entry.value.start()
} else {
entry.value.pause()
}
}
}
}
\ No newline at end of file
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.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
import io.reactivex.schedulers.Schedulers
import tv.danmaku.ijk.media.player.IjkMediaPlayer
import java.util.concurrent.TimeUnit
internal class ItemIntroHolder(binding: ItemExpertIntroBinding) :
BindingViewHolder<ItemExpertIntroBinding>(binding) {
companion object {
private const val TAG = "ItemIntroHolder"
}
private var disposable: Disposable? = null
private var video: IjkVideoView? = null
fun onDetach() {
stopTiming()
video?.release(true)
}
fun onBind(item: VideoViewModel) {
binding.layoutCall.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.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
}
binding.ivPlay.setOnClickListener {
video?.start()
binding.ivPlay.visibility = View.GONE
}
binding.seekbar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
}
override fun onStartTrackingTouch(seekBar: SeekBar?) {
}
override fun onStopTrackingTouch(seekBar: SeekBar?) {
if (seekBar != null) {
video?.seekTo(seekBar.progress)
video?.start()
binding.ivPlay.visibility = View.GONE
}
}
})
}
fun onAttach(videoView: IjkVideoView) {
this.video = videoView
binding.videoView.addView(videoView)
video?.setOnPreparedListener { player ->
Log.d(TAG, "${player.videoHeight},${player.videoWidth},${player.duration}")
val duration = player.duration.toInt()
if (duration > 0) {
binding.seekbar.max = duration
} else {
binding.seekbar.visibility = View.GONE
}
}
video?.setOnInfoListener { mp, what, extra ->
Log.d(TAG, "${what},${extra}")
return@setOnInfoListener false
}
video?.setOnCompletionListener { stopTiming() }
startTiming()
}
private fun startTiming() {
disposable = Observable.interval(300, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.computation())
.subscribe {
val pos = (video?.mMediaPlayer as IjkMediaPlayer?)?.currentPosition ?: 0
if (pos > 0) {
binding.seekbar.progress = pos.toInt()// video.bufferPercentage
}
}
}
private fun stopTiming() {
disposable?.dispose()
}
}
class VideoViewModel {
val name = ObservableField<String>("")
val avatar = ObservableField<String>("")
val count = ObservableInt()
val lineStatus = ObservableInt()
val intro = ObservableField<String>("")
val tag = ObservableField<String>("")
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
package com.ydl.confide.api
object ConfideRoute{
const val R_VIDEO_SHOW = "/confide/expert_video"
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="26dp" />
<gradient
android:endColor="#48CC95"
android:startColor="#61CEAC" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="26dp" />
<gradient
android:endColor="#BBC1CD"
android:startColor="#D5D6D7" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="26dp" />
<gradient
android:endColor="#FF994B"
android:startColor="#F6B37F" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<corners android:radius="4dp" />
<solid android:color="#59FFFFFF" />
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<corners android:radius="4dp" />
<solid android:color="@color/white" />
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="4dp" />
<solid android:color="@color/white" />
</shape>
</clip>
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="oval">
<solid android:color="@color/white" />
<size android:width="6dp" android:height="6dp" />
</shape>
</item>
<item>
<shape android:shape="oval">
<solid android:color="@color/white" />
<size android:width="6dp" android:height="6dp" />
</shape>
</item>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout 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">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black">
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/viewPager"
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="parent" />
<ImageView
android:id="@+id/ivBack"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_marginLeft="12dp"
android:layout_marginTop="24dp"
android:padding="12dp"
android:src="@drawable/confide_back"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:shape="@{1}"
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"
android:paddingVertical="5dp"
android:text="倾诉记录"
android:textColor="@color/white"
android:textSize="13sp"
app:layout_constraintBottom_toBottomOf="@+id/ivBack"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/ivBack"
app:shapeBg="@{0x26000000}"
app:shapeRadius="@{15}"
app:shapeStrokeWidth="@{1}"
app:shapeStrokeColor="@{0xFFFFFFFF}" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:orientation="horizontal"
android:id="@+id/rl_confide_title_layout"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/confide_common_bg"
android:id="@+id/rl_confide_title_layout"
>
android:background="@color/white"
android:orientation="horizontal">
<LinearLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/ll_bar_root"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="48dp">
android:layout_height="48dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/img_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="40dp"
android:layout_height="0dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="@drawable/confide_back"/>
android:scaleType="center"
android:src="@drawable/platform_common_back"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_title"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/confide_title"
android:textColor="@color/black"
android:textSize="17dp"
android:textColor="#FFFFFF"
android:text="@string/confide_title"/>
<ImageView
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
<TextView
android:id="@+id/img_mine"
android:layout_width="wrap_content"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="@drawable/confide_mine"/>
</LinearLayout>
android:drawableTop="@drawable/ic_action_confide_order"
android:drawablePadding="4dp"
android:gravity="center"
android:text="订单"
android:textColor="@color/_9"
android:textSize="7sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toLeftOf="@+id/img_customer"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/img_customer"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:drawableTop="@drawable/ic_action_confide_customer"
android:drawablePadding="4dp"
android:gravity="center"
android:text="客服"
android:textColor="@color/_9"
android:textSize="7sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toLeftOf="@+id/img_help"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/img_help"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:drawableTop="@drawable/ic_action_confide_help"
android:drawablePadding="4dp"
android:gravity="center"
android:text="帮助"
android:textColor="@color/_9"
android:textSize="7sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="item"
type="com.ydl.confide.home.adapter.ItemVideoShowViewModel" />
</data>
<androidx.cardview.widget.CardView
android:layout_width="52dp"
android:layout_height="52dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="10dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="10dp"
app:cardCornerRadius="6dp"
app:cardElevation="0dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:imageUrl="@{item.coverUrl}" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:layout_marginBottom="2dp"
android:maxLines="1"
android:text="@{item.name}"
android:textColor="@color/white"
android:textSize="10sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|left"
android:layout_marginBottom="2dp"
android:maxLines="1"
android:paddingLeft="4dp"
android:paddingTop="2dp"
android:paddingRight="4dp"
android:paddingBottom="2dp"
android:textColor="@color/white"
android:textSize="7sp"
app:confideLineRecentText="@{item.state}" />
</androidx.cardview.widget.CardView>
</layout>
<?xml version="1.0" encoding="utf-8"?>
<layout 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">
<data>
<import type="android.view.View" />
<variable
name="item"
type="com.ydl.confide.intro.VideoViewModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black">
<FrameLayout
android:id="@+id/videoView"
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="parent" />
<ImageView
android:id="@+id/ivPlay"
android:layout_width="76dp"
android:layout_height="76dp"
android:src="@drawable/ic_video_play"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
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"
tools:visibility="gone" />
<SeekBar
android:id="@+id/seekbar"
android:layout_width="0dp"
android:layout_height="wrap_content"
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"
app:layout_constraintBottom_toTopOf="@+id/layoutCall"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layoutCall"
android:layout_width="wrap_content"
android:layout_height="42dp"
android:layout_marginBottom="32dp"
android:background="@{item.lineStatus==3?@drawable/confide_line_bg_3:(item.lineStatus==2?@drawable/confide_line_bg_2:@drawable/confide_line_bg_1)}"
android:paddingLeft="28dp"
android:paddingRight="28dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
tools:background="@drawable/confide_line_bg_1">
<ImageView
android:id="@+id/ivCall"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginRight="4dp"
android:src="@drawable/ic_confide_call"
android:visibility="@{item.lineStatus==2?View.GONE:View.VISIBLE}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/tvCall"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvCall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@color/white"
android:textSize="17sp"
app:confideLineText="@{item.lineStatus}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/ivCall"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="通话中" />
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:id="@+id/tvTag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginBottom="60dp"
android:text="@{item.tag}"
android:textColor="#99FFFFFF"
android:textSize="13sp"
app:layout_constraintBottom_toTopOf="@+id/layoutCall"
app:layout_constraintLeft_toLeftOf="parent"
tools:text="tag|tag|tag" />
<TextView
android:id="@+id/tvIntro"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:text="@{item.intro}"
android:textColor="@color/white"
android:textSize="15sp"
app:layout_constraintBottom_toTopOf="@+id/tvTag"
app:layout_constraintLeft_toLeftOf="@+id/tvTag"
tools:text="tag|tag|tag" />
<TextView
android:id="@+id/tvName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:text="@{item.name}"
android:textColor="@color/white"
android:textSize="19sp"
app:layout_constraintBottom_toTopOf="@+id/tvIntro"
app:layout_constraintLeft_toLeftOf="@+id/tvTag"
tools:text="tag|tag|tag" />
<TextView
android:id="@+id/tvConfideCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textSize="13sp"
app:layout_constraintBottom_toBottomOf="@+id/tvName"
app:layout_constraintLeft_toRightOf="@+id/tvName"
tools:text="tag|tag|tag" />
<TextView
android:id="@+id/btnShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
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"
app:layout_constraintBottom_toTopOf="@+id/layoutCall"
app:layout_constraintRight_toRightOf="parent" />
<TextView
android:id="@+id/btnEvaluate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
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"
app:layout_constraintBottom_toTopOf="@+id/btnShare"
app:layout_constraintRight_toRightOf="parent" />
<TextView
android:id="@+id/btnChat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="18dp"
android:layout_marginBottom="20dp"
android:drawableTop="@drawable/ic_video_chat"
android:drawablePadding="6dp"
android:gravity="center_horizontal"
android:text="私聊"
android:textColor="@color/white"
android:textSize="11sp"
app:layout_constraintBottom_toTopOf="@+id/btnEvaluate"
app:layout_constraintRight_toRightOf="parent" />
<ImageView
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>
</layout>
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="item"
type="com.ydl.confide.home.adapter.ItemVideoShowViewModel" />
</data>
<androidx.cardview.widget.CardView
android:layout_width="180dp"
android:layout_height="140dp"
android:layout_marginLeft="6dp"
android:layout_marginTop="20dp"
android:layout_marginRight="6dp"
android:layout_marginBottom="10dp"
app:cardCornerRadius="8dp"
app:cardElevation="0dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
app:imageUrl="@{item.videoCoverUrl}" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|left"
android:layout_marginLeft="10dp"
android:layout_marginBottom="10dp"
android:text="@{item.name}"
android:textColor="@color/white"
android:textSize="15sp" />
<ImageView
android:layout_width="33dp"
android:layout_height="33dp"
android:layout_gravity="center"
android:src="@drawable/ic_video_play" />
</androidx.cardview.widget.CardView>
</layout>
<resources>
<string name="confide_title">即时倾诉</string>
<string name="confide_video_wifi_tip">当前处于非wifi环境下,播放会消耗流量,确定继续播放?</string>
<string name="confide_tip">提示</string>
</resources>
......@@ -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()
......
......@@ -29,6 +29,10 @@ android {
abortOnError false
}
dataBinding {
enabled true
}
buildTypes {
release {
minifyEnabled false
......@@ -65,4 +69,5 @@ dependencies {
implementation(rootProject.ext.dependencies["arouter"])
kapt(rootProject.ext.dependencies["arouter-compiler"])
compileOnly(rootProject.ext.dependencies["systembartint"])
implementation "com.ydl:ydl-image:1.0.10-SNAPSHOT"
}
package com.yidianling.common.binding
import android.graphics.Color
import android.graphics.drawable.GradientDrawable
import android.view.View
import android.widget.ImageView
import androidx.databinding.BindingAdapter
import com.ydl.ydl_image.module.GlideApp
@BindingAdapter("imageUrl")
fun setImageUrl(imageView: ImageView, url: String?) {
if (url.isNullOrEmpty()) return
GlideApp.with(imageView).load(url).into(imageView)
}
@BindingAdapter(
value = [
"shapeBg",
"shapeStrokeColor",
"shapeStrokeWidth",
"shapeRadius",
"shape"
],
requireAll = false
)
fun View.setCustomStyle(
shapeBg: Int = Color.TRANSPARENT, // 背景颜色
shapeStrokeColor: Int = Color.TRANSPARENT, // 边框颜色
shapeStrokeWidth: Float = 0f, // 边框宽度
shapeRadius: Float = 0f, // 圆角宽度
shape: Int = GradientDrawable.RECTANGLE // Shape样式 默认矩形
) {
val gradientDrawable: GradientDrawable = if (background as? GradientDrawable == null) {
GradientDrawable()
} else {
background as GradientDrawable
}
val density = resources.displayMetrics.density
gradientDrawable.setColor(shapeBg)
gradientDrawable.setStroke(
(shapeStrokeWidth * density).toInt(),
shapeStrokeColor
)
val radius = density * shapeRadius
gradientDrawable.cornerRadius = radius
when (shape) {
GradientDrawable.RECTANGLE -> gradientDrawable.shape = GradientDrawable.RECTANGLE
GradientDrawable.OVAL -> gradientDrawable.shape = GradientDrawable.OVAL
GradientDrawable.LINE -> gradientDrawable.shape = GradientDrawable.LINE
GradientDrawable.RING -> gradientDrawable.shape = GradientDrawable.RING
else -> gradientDrawable.shape = GradientDrawable.RECTANGLE
}
background = gradientDrawable
}
\ 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