Commit f2923d7a by 万齐军

feat: 倾诉视频播放页修改

parent a5be67ab
......@@ -6,6 +6,7 @@ import android.app.Dialog
import android.os.Bundle
import android.view.*
import android.widget.FrameLayout
import androidx.fragment.app.FragmentActivity
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
......@@ -17,17 +18,20 @@ import com.ydl.webview.WebModularServiceUtils
import com.ydl.ydlcommon.base.BaseActivity
import com.yidianling.common.tools.RxImageTool
class ConfideBottomSheetDialogFragment:BottomSheetDialogFragment() {
lateinit var activity:BaseActivity;
class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
companion object {
private const val KEY_JUMP_URL = "jumpUrl"
}
lateinit var wv_content:ProgressWebView;
lateinit var text_title:View;
lateinit var line:View;
lateinit var rl_title:View;
lateinit var close_webview_Icon:View
lateinit var jumpUrl:String
fun showBottomSheetDialog(activity: BaseActivity,jumpUrl:String) {
this.activity=activity
this.jumpUrl=jumpUrl
fun showBottomSheetDialog(activity: FragmentActivity,jumpUrl:String) {
arguments = Bundle().apply {
putString(KEY_JUMP_URL, jumpUrl)
}
show(activity.supportFragmentManager, "confide_bottom_showdialog")
}
......@@ -38,10 +42,6 @@ class ConfideBottomSheetDialogFragment:BottomSheetDialogFragment() {
}
override fun onStart() {
super.onStart()
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
......@@ -51,6 +51,11 @@ class ConfideBottomSheetDialogFragment:BottomSheetDialogFragment() {
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
jumpUrl = arguments?.getString(KEY_JUMP_URL) ?: ""
if (jumpUrl.isBlank()) {
dismiss()
return
}
wv_content = view.findViewById<ProgressWebView>(com.ydl.webview.R.id.wv_content)
close_webview_Icon = view.findViewById<View>(R.id.close_webview_Icon)
text_title = view.findViewById<View>(R.id.text_title)
......@@ -92,7 +97,7 @@ class ConfideBottomSheetDialogFragment:BottomSheetDialogFragment() {
val dialog = super.onCreateDialog(savedInstanceState) as BottomSheetDialog
dialog.setOnShowListener {
val itemView = LayoutInflater.from(activity).inflate(R.layout.confide_bottom_two,null,false)
val itemView = LayoutInflater.from(context).inflate(R.layout.confide_bottom_two,null,false)
val layoutCall=itemView.findViewById<View>(R.id.layoutCall)
val layoutChange=itemView.findViewById<View>(R.id.layoutChange)
val layout_change_text=itemView.findViewById<View>(R.id.layout_change_text)
......@@ -163,7 +168,7 @@ class ConfideBottomSheetDialogFragment:BottomSheetDialogFragment() {
//设置字符编码
setting.setDefaultTextEncodingName("GBK")
setting.setDomStorageEnabled(true)
val appCachePath: String = activity?.getCacheDir()?.getAbsolutePath().toString()
val appCachePath: String = context?.getCacheDir()?.getAbsolutePath().toString()
setting.setAppCachePath(appCachePath)
setting.setAllowFileAccessFromFileURLs(true)
setting.setAppCacheEnabled(true)
......@@ -173,8 +178,8 @@ class ConfideBottomSheetDialogFragment:BottomSheetDialogFragment() {
setting.setBlockNetworkImage(false)
wv_content!!.scrollBarStyle = View.SCROLLBARS_INSIDE_OVERLAY //滚动条风格,为0指滚动条不占用空间,直接覆盖在网页上
var jtoJHandle = WebModularServiceUtils.getWebService()
.getJavascripHandler(activity as Activity, tellData = TellData())
val jtoJHandle = WebModularServiceUtils.getWebService()
.getJavascripHandler(requireActivity(), tellData = TellData())
wv_content!!.addJavascriptInterface(jtoJHandle, "javascriptHandler")
wv_content.loadUrl("https://m.ydl.com/jy/experts/23035?v=4.0.99&uid=9404770&ts=1652787528&toConfide=1&" +
......
......@@ -35,6 +35,7 @@ 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.findRouteService
import com.ydl.ydlcommon.mvp.lce.BaseLceActivity
import com.ydl.ydlcommon.utils.BuryPointUtils
import com.ydl.ydlcommon.utils.remind.ToastHelper
......@@ -272,11 +273,8 @@ class ConfideHomeActivity : BaseLceActivity<IConfideHomeContract.View,IConfideHo
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)
val imService = findRouteService(IImService::class.java)
imService?.startP2PXiaoYi(this)
}
findViewById<View>(R.id.img_help)?.setOnClickListener {
val params = H5Params(H5_URL + "help/", "")
......
......@@ -72,7 +72,7 @@ class ItemVideoShowViewModel {
internal fun ItemVideoShowViewModel.mapOf(bean: ConfideHomeBodyBean): ItemVideoShowViewModel {
name.set(bean.confidedName)
coverUrl.set(bean.coverPicture)
coverUrl.set(bean.confidedIcon)
videoCoverUrl.set(bean.coverVideoPicture)
state.set(bean.confideLine ?: 0)
linkUrl = bean.linkUrl
......
......@@ -39,7 +39,8 @@ data class ConfideHomeBodyBean(
//副标题(底部更多文案)
val subTitle : String?,
//咨询师标题
val confidedTitle:String?,
val confidedTitle: String?,
val title: String?,
//副标题点击事件
val subLinkUrl : String?,
//咨询师背景图片
......
......@@ -2,4 +2,11 @@ package com.ydl.confide.home.bean
class DialStatus {
var confideLine: Int? = null
var remainingTime: RemainingTime? = null
}
class RemainingTime {
var remainingTime: Long? = null//秒
var listenerUid: String? = null
var listenOrderId: String? = null
}
\ No newline at end of file
......@@ -36,6 +36,7 @@ interface ConfideHomeApi {
fun connectJava(@QueryMap params: Map<String, String>): Observable<BaseAPIResponse<ConfideConnectResponse>>
// 1=在线 3-通话中 2-离线
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
@GET("auth/listen/dialchangestatus")
fun getDialStatus(@Query("doctorId") doctorId: String): Observable<BaseAPIResponse<DialStatus>>
......
......@@ -16,6 +16,9 @@ fun TextView.confideLineText(line: Int) {
3 -> {
text = "通话中"
}
4->{
text = "继续倾诉"
}
}
}
......
......@@ -21,10 +21,12 @@ import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydlcommon.base.config.HttpConfig
import com.ydl.ydlcommon.base.config.HttpConfig.Companion.YDL_H5
import com.ydl.ydlcommon.modular.findRouteService
import com.ydl.ydlcommon.utils.BuryPointUtils
import com.ydl.ydlcommon.utils.LogUtil
import com.ydl.ydlnet.YDLHttpUtils
import com.yidianling.common.tools.ToastUtil
import com.yidianling.user.api.service.IUserService
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
......@@ -56,6 +58,8 @@ class ExpertIntroActivity : AppCompatActivity() {
private val data = mutableListOf<VideoViewModel>()
private var noMoreData = false
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
ARouter.getInstance().inject(this)
......@@ -69,7 +73,10 @@ class ExpertIntroActivity : AppCompatActivity() {
}
if (initData != null) {
val beans = JSON.parseArray(initData, ConfideHomeBodyBean::class.java)
val vms = beans.map { VideoViewModel().mapOf(it) }
val isLogin = findRouteService(IUserService::class.java)?.isLogin() ?: false
val vms = beans.map {
VideoViewModel().mapOf(it).apply { showFreeTag.set(!isLogin) }
}
data.addAll(vms)
}
binding.ivBack.setOnClickListener { onBackPressed() }
......@@ -97,9 +104,14 @@ class ExpertIntroActivity : AppCompatActivity() {
}
})
adapter.checkNetwork()
binding.viewPager.currentItem = initPos
}
private fun loadMore() {
if (disposable != null && !disposable!!.isDisposed) {
return
}
if (noMoreData) return
disposable = confideApi.recommendDoctor(HttpConfig.JAVA_BASE_URL + "auth/listen/nsearch?", page, SOURCE_VIDEO)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
......@@ -107,11 +119,15 @@ class ExpertIntroActivity : AppCompatActivity() {
if (resp.code == "200") {
page++
val body = resp.data.body
val map = body?.map { VideoViewModel().mapOf(it) }
val isLogin = findRouteService(IUserService::class.java)?.isLogin() ?: false
val map = body?.map { VideoViewModel().mapOf(it).apply { showFreeTag.set(!isLogin) } }
map?.let {
data.addAll(it)
adapter.notifyItemRangeInserted(data.size - it.size, it.size)
}
if (body == null || body.size == 0) {
noMoreData = true
}
} else {
ToastUtil.toastShort(resp.msg)
}
......
......@@ -16,6 +16,7 @@ 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.utils.TimeUtil
import com.ydl.ydlcommon.view.dialog.CommonDialog
import com.ydl.ydlnet.YDLHttpUtils
import com.yidianling.common.tools.ToastUtil
......@@ -65,6 +66,9 @@ internal class IntroAdapter(
if (!playUrl.isNullOrBlank()) {
if (hasAgreePlayWithoutWiFi || ConfideNetworkUtil.isWifi(context)) {
videoView.setVideoURI(Uri.parse(playUrl))
if (curPos == adapterPosition) {
videoView.start()
}
} else {
videoView.tag = playUrl
}
......@@ -148,9 +152,10 @@ internal class IntroAdapter(
}
for (entry in videoViews.entries) {
if (entry.key == position) {
entry.value.seekTo(0)
// entry.value.seekTo(0)
entry.value.start()
} else {
entry.value.seekTo(0)
entry.value.pause()
}
}
......@@ -167,6 +172,18 @@ internal class IntroAdapter(
.subscribe({ resp ->
if (resp.code == "200") {
val lineStatus = resp.data?.confideLine ?: 2
if (lineStatus == 4) {//继续倾诉
val t = resp?.data?.remainingTime?.remainingTime
if (t != null) {
val remain = TimeUtil.getElapseTimeForShow(t * 1000)
data[position].remainingTime.set(
context.getString(
R.string.confide_tip_remain_time,
remain
)
)
}
}
data[position].lineStatus.set(lineStatus)
} else {
if (!resp.msg.isNullOrEmpty()) {
......
......@@ -4,14 +4,18 @@ import android.app.Activity
import android.util.Log
import android.view.View
import android.widget.SeekBar
import androidx.databinding.ObservableBoolean
import androidx.databinding.ObservableField
import androidx.databinding.ObservableInt
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.FragmentActivity
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.ConfideBottomSheetDialogFragment
import com.ydl.confide.home.bean.ConfideHomeBodyBean
import com.ydl.ydlcommon.base.config.HttpConfig
import com.ydl.ydlcommon.modular.findRouteService
import com.ydl.ydlcommon.utils.LogUtil
import com.ydl.ydlcommon.view.dialog.YDLShareDialog
import com.yidianling.im.api.service.IImService
......@@ -20,6 +24,7 @@ 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.net.URLEncoder
import java.util.concurrent.TimeUnit
internal class ItemIntroHolder(binding: ItemExpertIntroBinding) :
......@@ -42,19 +47,32 @@ internal class ItemIntroHolder(binding: ItemExpertIntroBinding) :
fun onBind(item: VideoViewModel) {
vm = item
binding.layoutCall.setOnClickListener { }
binding.layoutCall.setOnClickListener {
ConfideBottomSheetDialogFragment()
.showBottomSheetDialog(itemView.context as FragmentActivity, item.linkUrl!!)
}
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)
findRouteService(IImService::class.java)?.startChat(aty, item.uid!!, 0, 0)
}
}
binding.btnEvaluate.setOnClickListener {
ConfideBottomSheetDialogFragment()
.showBottomSheetDialog(itemView.context as FragmentActivity, item.linkUrl!!)
}
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")
if (aty != null && !item.linkUrl.isNullOrBlank()) {
var shareUrl = "${HttpConfig.MH5_URL}experts/${item.doctorId}"
if (!item.confideId.isNullOrBlank()) {
shareUrl += "?id=${item.confideId}"
}
val dialog = YDLShareDialog.style8(
aty, "${item.name.get()}_${item.title.get()}", shareUrl, "壹点灵心理服务平台让天下人更快乐", item.avatar.get(),
genMinProgramPath(shareUrl), "gh_25b90294ddcc"
)
dialog.show(aty.fragmentManager, "share")
}
}
......@@ -76,6 +94,16 @@ internal class ItemIntroHolder(binding: ItemExpertIntroBinding) :
binding.voicePlay.start()
}
}
binding.voicePlay.setOnClickListener {
if (video?.isPlaying == true) {
video?.pause()
binding.voicePlay.stop()
} else if (video?.isPlaying == false) {
video?.start()
binding.voicePlay.start()
}
}
binding.seekbar.progress = 0
binding.seekbar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
......@@ -94,7 +122,8 @@ internal class ItemIntroHolder(binding: ItemExpertIntroBinding) :
}
}
})
binding.voicePlay.visibility = if (item.isVideo) View.GONE else View.VISIBLE
binding.voicePlay.visibility =
if (item.isVideo) View.GONE else if (item.playUrl.isNullOrBlank()) View.GONE else View.VISIBLE
}
fun onAttach(videoView: IjkVideoView) {
......@@ -122,7 +151,7 @@ internal class ItemIntroHolder(binding: ItemExpertIntroBinding) :
return@setOnErrorListener true
}
startTiming()
if (binding.voicePlay.visibility == View.VISIBLE) {
if (vm?.isVideo == false && !vm?.playUrl.isNullOrBlank()) {
binding.voicePlay.start()
}
}
......@@ -140,6 +169,9 @@ internal class ItemIntroHolder(binding: ItemExpertIntroBinding) :
if (!isTouch) {
binding.seekbar.progress = pos.toInt()// video.bufferPercentage
}
if (vm?.isVideo == false && video?.isPlaying == false) {
binding.voicePlay.start()
}
}
}
}
......@@ -151,30 +183,42 @@ internal class ItemIntroHolder(binding: ItemExpertIntroBinding) :
class VideoViewModel {
val name = ObservableField<String>("")
val title = ObservableField<String>("")
val avatar = ObservableField<String>("")
val count = ObservableField<String>("")
val lineStatus = ObservableInt()
var remainingTime = ObservableField<String>("")
val intro = ObservableField<String>("")
val tag = ObservableField<String>("")
var playUrl: String? = null
var coverUrl = ObservableField<String>("")
val coverUrl = ObservableField<String>("")
val showFreeTag = ObservableBoolean(false)
var isVideo = false
var uid: String? = null
var doctorId: String? = null
var confideId: String? = null
var linkUrl: String? = null
}
private fun genMinProgramPath(url: String): String {
val pathPrefix = "/pages/web/web?load_url="
val encode = URLEncoder.encode(url, "UTF-8")
return pathPrefix + encode
}
internal fun VideoViewModel.mapOf(bean: ConfideHomeBodyBean): VideoViewModel {
name.set(bean.confidedName)
avatar.set(bean.confidedIcon)
count.set(bean.confideHearNum)
count.set("倾听人次 "+bean.confideNum)
intro.set(bean.confideContent)
title.set(bean.title)
val sb = StringBuilder()
bean.confidedTag?.forEach { sb.append(it).append(" | ") }
if (sb.isNotEmpty()) {
sb.setLength(sb.length - 3)
}
tag.set(sb.toString())
if (bean.videoUrl != null) {
if (!bean.videoUrl.isNullOrEmpty()) {
playUrl = bean.videoUrl
isVideo = true
coverUrl.set(bean.coverVideoPicture)
......@@ -184,6 +228,8 @@ internal fun VideoViewModel.mapOf(bean: ConfideHomeBodyBean): VideoViewModel {
coverUrl.set(bean.coverPicture)
}
uid = bean.uid?.toString()
doctorId = bean.doctorId
confideId = bean.confidedId
linkUrl = bean.linkUrl
return this
}
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomRightRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp" />
<solid android:color="#FF4A4A" />
<stroke
android:width="1dp"
android:color="@color/white" />
</shape>
\ No newline at end of file
......@@ -7,6 +7,8 @@
<import type="android.view.View" />
<import type="android.text.TextUtils" />
<variable
name="item"
type="com.ydl.confide.intro.VideoViewModel" />
......@@ -52,6 +54,7 @@
android:layout_width="76dp"
android:layout_height="76dp"
android:padding="24dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
......@@ -86,12 +89,10 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layoutCall"
android:layout_width="wrap_content"
android:layout_width="160dp"
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"
......@@ -105,6 +106,7 @@
android:src="@drawable/ic_confide_call"
android:visibility="@{item.lineStatus==2?View.GONE:View.VISIBLE}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/tvCall"
app:layout_constraintTop_toTopOf="parent" />
......@@ -113,18 +115,47 @@
android:id="@+id/tvCall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@color/white"
android:textSize="17sp"
android:textSize="16sp"
app:confideLineText="@{item.lineStatus}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toTopOf="@+id/tvTime"
app:layout_constraintLeft_toRightOf="@+id/ivCall"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="通话中" />
<TextView
android:id="@+id/tvTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{item.remainingTime}"
android:textColor="@color/white"
android:textSize="10sp"
android:visibility="@{TextUtils.isEmpty(item.remainingTime)?View.GONE:View.VISIBLE}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="@+id/tvCall"
app:layout_constraintRight_toRightOf="@+id/tvCall"
app:layout_constraintTop_toBottomOf="@+id/tvCall"
tools:text="剩余1分40秒" />
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bg_confide_free"
android:paddingLeft="5dp"
android:paddingTop="2dp"
android:paddingRight="5dp"
android:paddingBottom="2dp"
android:text="首单免费"
android:textColor="@color/white"
android:textSize="11sp"
android:visibility="@{item.showFreeTag?View.VISIBLE:View.GONE}"
app:layout_constraintCircle="@+id/layoutCall"
app:layout_constraintCircleAngle="70"
app:layout_constraintCircleRadius="70dp" />
<TextView
android:id="@+id/tvTag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......
......@@ -2,4 +2,5 @@
<string name="confide_title">即时倾诉</string>
<string name="confide_video_wifi_tip">当前处于非wifi环境下,播放会消耗流量,确定继续播放?</string>
<string name="confide_tip">提示</string>
<string name="confide_tip_remain_time">(剩余%s)</string>
</resources>
package com.ydl.ydlcommon.modular
import android.content.Context
import android.os.Bundle
import android.os.Parcelable
import com.alibaba.android.arouter.facade.template.IProvider
import com.alibaba.android.arouter.launcher.ARouter
import com.ydl.ydlcommon.utils.LogUtil
......@@ -9,6 +12,55 @@ import com.ydl.ydlcommon.utils.LogUtil
* Created by haorui on 2019-09-21 .
* Des:查找 Arouter 服务封装类
*/
fun <T> findRouteService(clz: Class<T>): T? =
ARouter.getInstance().navigation(clz)
fun route(context: Context, route: String, vararg params: Pair<String, Any>) {
val build = ARouter.getInstance().build(route)
params.forEach {
when (val value = it.second) {
is Boolean -> {
build.withBoolean(it.first, value)
}
is Char -> {
build.withChar(it.first, value)
}
is Int -> {
build.withInt(it.first, value)
}
is Long -> {
build.withLong(it.first, value)
}
is Float -> {
build.withFloat(it.first, value)
}
is Double -> {
build.withDouble(it.first, value)
}
is Short -> {
build.withShort(it.first, value)
}
is Byte -> {
build.withByte(it.first, value)
}
is String -> {
build.withString(it.first, value)
}
is Bundle -> {
build.withBundle(it.first, value)
}
is CharSequence -> {
build.withCharSequence(it.first, value)
}
is Parcelable -> {
build.withParcelable(it.first, value)
}
}
}
build.navigation(context)
}
object ModularServiceManager {
private val routerMap: HashMap<String, IProvider> = HashMap()
......
......@@ -293,21 +293,21 @@ public class TimeUtil {
return retStr;
}
public static String getElapseTimeForShow(int milliseconds) {
public static String getElapseTimeForShow(long milliseconds) {
StringBuilder sb = new StringBuilder();
int seconds = milliseconds / 1000;
long seconds = milliseconds / 1000;
if (seconds < 1) {
seconds = 1;
}
int hour = seconds / (60 * 60);
long hour = seconds / (60 * 60);
if (hour != 0) {
sb.append(hour).append("小时");
}
int minute = (seconds - 60 * 60 * hour) / 60;
long minute = (seconds - 60 * 60 * hour) / 60;
if (minute != 0) {
sb.append(minute).append("分");
}
int second = (seconds - 60 * 60 * hour - 60 * minute);
long second = (seconds - 60 * 60 * hour - 60 * minute);
if (second != 0) {
sb.append(second).append("秒");
}
......
......@@ -144,9 +144,17 @@ class YDLShareDialog : DialogFragment {
return YDLShareDialog(activity, shareTitle, shareUrl, shareContent, shareHead, minProgramPath, minProgramId)
}
//只有微信和朋友圈
fun style8(activity: Activity, shareTitle: String?, shareUrl: String?, shareContent: String?, shareHead: String?): YDLShareDialog {
fun style8(
activity: Activity,
shareTitle: String?,
shareUrl: String?,
shareContent: String?,
shareHead: String?,
minProgramPath: String?,
minProgramId: String?
): YDLShareDialog {
typeStyle = TYPE8
return YDLShareDialog(activity, shareTitle, shareUrl, shareContent, shareHead)
return YDLShareDialog(activity, shareTitle, shareUrl, shareContent, shareHead, minProgramPath, minProgramId)
}
}
......
......@@ -18,7 +18,7 @@ import java.util.List;
import java.util.Random;
public class VoicePlayingIcon extends View {
public class VoicePlayingIcon extends View implements Runnable {
//画笔
private Paint paint;
......@@ -141,10 +141,8 @@ public class VoicePlayingIcon extends View {
*/
public void start() {
if (!isPlaying) {
if (myThread == null) {//开启子线程
myThread = new Thread(new MyRunnable());
myThread.start();
}
removeCallbacks(this);
postOnAnimation(this);
isPlaying = true;//控制子线程中的循环
}
}
......@@ -154,46 +152,28 @@ public class VoicePlayingIcon extends View {
*/
public void stop() {
isPlaying = false;
removeCallbacks(this);
invalidate();
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
if (myThread != null) {
myThread.interrupt();
myThread = null;
}
removeCallbacks(this);
isPlaying = false;
}
/**
* 子线程,循环改变每个指针的高度
*/
public class MyRunnable implements Runnable {
private float i = 0F;
@Override
public void run() {
for (float i = 0; i < Integer.MAX_VALUE; ) {//创建一个死循环,每循环一次i+0.1
try {
for (int j = 0; j < pointers.size(); j++) { //循环改变每个指针高度
float rate = (float) Math.abs(Math.sin(i + j));//利用正弦有规律的获取0~1的数。
pointers.get(j).height = (basePointY - getPaddingTop()) * rate; //rate 乘以 可绘制高度,来改变每个指针的高度
}
Thread.sleep(pointerSpeed);//休眠一下下,可自行调节
if (isPlaying) { //控制开始/暂停
postInvalidate();
invalidate();
i += 0.1;
postOnAnimationDelayed(this, pointerSpeed);
}
} catch (InterruptedException e) {
//ignore
break;
}
}
}
}
/**
* 指针对象
......
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