Commit fda5f9f1 by 万齐军

feat: bug修改

parent 5713bcfa
...@@ -397,7 +397,7 @@ class WebJavascriptHandler : IJavascriptHandler{ ...@@ -397,7 +397,7 @@ class WebJavascriptHandler : IJavascriptHandler{
val topActivity = BaseActivityMgr.INST.getTopActivity() val topActivity = BaseActivityMgr.INST.getTopActivity()
if (topActivity is FragmentActivity && doctorId != null && confideId != null) { if (topActivity is FragmentActivity && doctorId != null && confideId != null) {
val url = HttpConfig.MH5_URL + ConfideRoute.h5ConfideIntro(confideId) val url = HttpConfig.MH5_URL + ConfideRoute.h5ConfideIntro(confideId)
findRouteService(IConfideService::class.java)?.showExpertDetailDialog(topActivity, url, doctorId) findRouteService(IConfideService::class.java).showExpertDetailDialog(topActivity, url, doctorId)
} }
} }
} }
......
...@@ -28,6 +28,8 @@ import com.ydl.webview.TellData ...@@ -28,6 +28,8 @@ import com.ydl.webview.TellData
import com.ydl.webview.WebModularServiceUtils import com.ydl.webview.WebModularServiceUtils
import com.ydl.ydlcommon.modular.findRouteService import com.ydl.ydlcommon.modular.findRouteService
import com.ydl.ydlcommon.utils.TimeUtil import com.ydl.ydlcommon.utils.TimeUtil
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.view.dialog.CommonDialog
import com.ydl.ydlnet.YDLHttpUtils import com.ydl.ydlnet.YDLHttpUtils
import com.yidianling.common.tools.ToastUtil import com.yidianling.common.tools.ToastUtil
import com.yidianling.im.api.service.IImService import com.yidianling.im.api.service.IImService
...@@ -94,6 +96,7 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() { ...@@ -94,6 +96,7 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
ActionCountUtils.record("ydl_experts_detail_popupwindows_page", "ydl_experts_detail_popupwindows_page_visit")
jumpUrl = arguments?.getString(KEY_JUMP_URL) ?: "" jumpUrl = arguments?.getString(KEY_JUMP_URL) ?: ""
doctorId = arguments?.getString(KEY_DOCTOR_ID) ?: "" doctorId = arguments?.getString(KEY_DOCTOR_ID) ?: ""
shouldShow = arguments?.getBoolean(KEY_SHOULD_SHOW) ?: false shouldShow = arguments?.getBoolean(KEY_SHOULD_SHOW) ?: false
...@@ -144,12 +147,28 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() { ...@@ -144,12 +147,28 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
tvCall = itemView.findViewById<TextView>(R.id.tvCall) tvCall = itemView.findViewById<TextView>(R.id.tvCall)
tvTime = itemView.findViewById<TextView>(R.id.tvTime) tvTime = itemView.findViewById<TextView>(R.id.tvTime)
first_order = itemView.findViewById<TextView>(R.id.first_order) first_order = itemView.findViewById<TextView>(R.id.first_order)
val isLogin = findRouteService(IUserService::class.java)?.isLogin() ?: false val userService = findRouteService(IUserService::class.java)
val isLogin = userService.isLogin()
first_order.visibility = if (isLogin) View.GONE else View.VISIBLE first_order.visibility = if (isLogin) View.GONE else View.VISIBLE
layoutCall.setOnClickListener { layoutCall.setOnClickListener {
ActionCountUtils.record("ydl_experts_detail_popupwindows_page", "ydl_experts_detail_popupwindows_page_visit")
if (!PhoneCallIn.loginByOneKeyLogin(requireContext(), true)) { if (!PhoneCallIn.loginByOneKeyLogin(requireContext(), true)) {
return@setOnClickListener return@setOnClickListener
} }
//判断是否绑定手机号
if (!userService.isBindPhone()) {
CommonDialog(requireContext())
.setMessage("为了您的账号安全,请绑定手机号")
.setLeftOnclick("取消") {
}
.setRightClick("确定") {
//跳转绑定手机号页面
userService.wxBindToInputhonePage(requireActivity())
}
.setCancelAble(false)
.show()
return@setOnClickListener
}
callJsFun(wv_content, "listenCallClick()") callJsFun(wv_content, "listenCallClick()")
} }
layoutChange.setOnClickListener { layoutChange.setOnClickListener {
......
...@@ -218,8 +218,8 @@ class ConfideHomeActivity : BaseLceActivity<IConfideHomeContract.View,IConfideHo ...@@ -218,8 +218,8 @@ class ConfideHomeActivity : BaseLceActivity<IConfideHomeContract.View,IConfideHo
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
//登录了回来之后就不显示了 //登录了回来之后就不显示了
val isLogin = (findRouteService(IUserService::class.java)?.isLogin()) ?: false val isLogin = (findRouteService(IUserService::class.java).isLogin())
findViewById<View>(R.id.confide_Free).visibility = if (isLogin) View.GONE else View.INVISIBLE findViewById<View>(R.id.confide_Free).visibility = if (isLogin) View.GONE else View.VISIBLE
} }
...@@ -304,7 +304,7 @@ class ConfideHomeActivity : BaseLceActivity<IConfideHomeContract.View,IConfideHo ...@@ -304,7 +304,7 @@ class ConfideHomeActivity : BaseLceActivity<IConfideHomeContract.View,IConfideHo
findViewById<View>(R.id.img_customer)?.setOnClickListener { findViewById<View>(R.id.img_customer)?.setOnClickListener {
ActionCountUtils.record("listen_counselor_list_page", "topright_corner_icon_click","2") ActionCountUtils.record("listen_counselor_list_page", "topright_corner_icon_click","2")
val imService = findRouteService(IImService::class.java) val imService = findRouteService(IImService::class.java)
imService?.startP2PXiaoYi(this) imService.startP2PXiaoYi(this)
} }
findViewById<View>(R.id.img_help)?.setOnClickListener { findViewById<View>(R.id.img_help)?.setOnClickListener {
ActionCountUtils.record("listen_counselor_list_page", "topright_corner_icon_click","3") ActionCountUtils.record("listen_counselor_list_page", "topright_corner_icon_click","3")
......
package com.ydl.confide.home.widget package com.ydl.confide.home.widget
import android.content.Context import android.content.Context
import android.graphics.Color
import android.text.TextUtils import android.text.TextUtils
import android.util.TypedValue
import android.view.Gravity
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.FrameLayout import android.widget.FrameLayout
import android.widget.LinearLayout
import android.widget.TextView
import com.blankj.utilcode.util.SpanUtils import com.blankj.utilcode.util.SpanUtils
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.load.engine.DiskCacheStrategy
...@@ -246,11 +241,7 @@ class ConfideHomeRecommendView(var view: IConfideHomeContract.View, context: Con ...@@ -246,11 +241,7 @@ class ConfideHomeRecommendView(var view: IConfideHomeContract.View, context: Con
// tv_price.text = sb.toString() // tv_price.text = sb.toString()
// } // }
/**
* 设置标签 todo 待优化
*/
private fun setConfideTag(bodyBean: ConfideHomeBodyBean) { private fun setConfideTag(bodyBean: ConfideHomeBodyBean) {
flowlayout_tag.removeAllViews()
if (null == bodyBean.confidedTag || bodyBean.confidedTag.isEmpty()) { if (null == bodyBean.confidedTag || bodyBean.confidedTag.isEmpty()) {
return return
} }
...@@ -261,16 +252,10 @@ class ConfideHomeRecommendView(var view: IConfideHomeContract.View, context: Con ...@@ -261,16 +252,10 @@ class ConfideHomeRecommendView(var view: IConfideHomeContract.View, context: Con
sb.append(tag).append(" | ") sb.append(tag).append(" | ")
i++ i++
} }
sb.setLength(sb.length - 3) if (sb.length > 3) {
val params = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, dp16) sb.setLength(sb.length - 3)
params.setMargins(0, 0, dp4, 0) }
val textView = TextView(context) flowlayout_tag.text = sb.toString()
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12f)
textView.setTextColor(Color.parseColor("#9495A0"))
textView.gravity = Gravity.CENTER
textView.layoutParams = params
textView.text = sb.toString()
flowlayout_tag.addView(textView)
} }
/** /**
......
...@@ -73,7 +73,7 @@ class ExpertIntroActivity : AppCompatActivity() { ...@@ -73,7 +73,7 @@ class ExpertIntroActivity : AppCompatActivity() {
} }
if (initData != null) { if (initData != null) {
val beans = JSON.parseArray(initData, ConfideHomeBodyBean::class.java) val beans = JSON.parseArray(initData, ConfideHomeBodyBean::class.java)
val isLogin = findRouteService(IUserService::class.java)?.isLogin() ?: false val isLogin = findRouteService(IUserService::class.java).isLogin()
val vms = beans.map { val vms = beans.map {
VideoViewModel().mapOf(it).apply { showFreeTag.set(!isLogin) } VideoViewModel().mapOf(it).apply { showFreeTag.set(!isLogin) }
} }
...@@ -122,7 +122,7 @@ class ExpertIntroActivity : AppCompatActivity() { ...@@ -122,7 +122,7 @@ class ExpertIntroActivity : AppCompatActivity() {
if (resp.code == "200") { if (resp.code == "200") {
page++ page++
val body = resp.data.body val body = resp.data.body
val isLogin = findRouteService(IUserService::class.java)?.isLogin() ?: false val isLogin = findRouteService(IUserService::class.java).isLogin() ?: false
val map = body?.map { VideoViewModel().mapOf(it).apply { showFreeTag.set(!isLogin) } } val map = body?.map { VideoViewModel().mapOf(it).apply { showFreeTag.set(!isLogin) } }
map?.let { map?.let {
data.addAll(it) data.addAll(it)
......
...@@ -3,6 +3,7 @@ package com.ydl.confide.intro ...@@ -3,6 +3,7 @@ package com.ydl.confide.intro
import android.app.Activity import android.app.Activity
import android.content.Context import android.content.Context
import android.net.Uri import android.net.Uri
import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
import androidx.databinding.DataBindingUtil import androidx.databinding.DataBindingUtil
...@@ -16,6 +17,7 @@ import com.ydl.confide.R ...@@ -16,6 +17,7 @@ import com.ydl.confide.R
import com.ydl.confide.databinding.ItemExpertIntroBinding import com.ydl.confide.databinding.ItemExpertIntroBinding
import com.ydl.confide.home.http.ConfideHomeApi import com.ydl.confide.home.http.ConfideHomeApi
import com.ydl.confide.home.util.ConfideNetworkUtil import com.ydl.confide.home.util.ConfideNetworkUtil
import com.ydl.ydlcommon.ui.Loading
import com.ydl.ydlcommon.utils.TimeUtil import com.ydl.ydlcommon.utils.TimeUtil
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.view.dialog.CommonDialog import com.ydl.ydlcommon.view.dialog.CommonDialog
...@@ -24,6 +26,7 @@ import com.yidianling.common.tools.ToastUtil ...@@ -24,6 +26,7 @@ import com.yidianling.common.tools.ToastUtil
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import tv.danmaku.ijk.media.player.IMediaPlayer
internal class IntroAdapter( internal class IntroAdapter(
private val context: Context, private val context: Context,
...@@ -33,6 +36,8 @@ internal class IntroAdapter( ...@@ -33,6 +36,8 @@ internal class IntroAdapter(
private val videoViews = hashMapOf<Int, IjkVideoView>() private val videoViews = hashMapOf<Int, IjkVideoView>()
private val onInfoListener = OnVideoInfo()
private var hasAgreePlayWithoutWiFi = false private var hasAgreePlayWithoutWiFi = false
private var curPos = 0 private var curPos = 0
...@@ -76,6 +81,7 @@ internal class IntroAdapter( ...@@ -76,6 +81,7 @@ internal class IntroAdapter(
videoView.tag = playUrl videoView.tag = playUrl
} }
} }
videoView.setOnInfoListener(onInfoListener)
videoViews.put(adapterPosition, videoView) videoViews.put(adapterPosition, videoView)
holder.onAttach(videoView) holder.onAttach(videoView)
} }
...@@ -217,4 +223,17 @@ internal class IntroAdapter( ...@@ -217,4 +223,17 @@ internal class IntroAdapter(
} }
} }
private inner class OnVideoInfo : IMediaPlayer.OnInfoListener {
override fun onInfo(mp: IMediaPlayer?, what: Int, extra: Int): Boolean {
Log.d("OnVideoInfo", "OnInfo:${what},${extra},${curPos}")
if (videoViews[curPos]?.mMediaPlayer == mp && data[curPos].isVideo) {
if (what == IMediaPlayer.MEDIA_INFO_BUFFERING_START) {
Loading.show(context)
} else if (what == IMediaPlayer.MEDIA_INFO_BUFFERING_END) {
Loading.close()
}
}
return true
}
}
} }
\ No newline at end of file
...@@ -69,7 +69,7 @@ internal class ItemIntroHolder(binding: ItemExpertIntroBinding) : ...@@ -69,7 +69,7 @@ internal class ItemIntroHolder(binding: ItemExpertIntroBinding) :
if (item.isVideo) "1" else "2", if (item.isVideo) "1" else "2",
"7" "7"
) )
findRouteService(IImService::class.java)?.startChat(aty, item.uid!!, 0, 0) findRouteService(IImService::class.java).startChat(aty, item.uid!!, 0, 0)
} }
} }
binding.btnEvaluate.setOnClickListener { binding.btnEvaluate.setOnClickListener {
...@@ -84,7 +84,7 @@ internal class ItemIntroHolder(binding: ItemExpertIntroBinding) : ...@@ -84,7 +84,7 @@ internal class ItemIntroHolder(binding: ItemExpertIntroBinding) :
ConfideBottomSheetDialogFragment() ConfideBottomSheetDialogFragment()
.showBottomSheetDialog( .showBottomSheetDialog(
itemView.context as FragmentActivity, itemView.context as FragmentActivity,
HttpConfig.MH5_URL + ConfideRoute.h5ExpertEval(it), HttpConfig.MH5_URL + ConfideRoute.h5ExpertEval(it, item.confideId ?: ""),
it it
) )
} }
...@@ -227,10 +227,6 @@ internal class ItemIntroHolder(binding: ItemExpertIntroBinding) : ...@@ -227,10 +227,6 @@ internal class ItemIntroHolder(binding: ItemExpertIntroBinding) :
binding.seekbar.visibility = View.GONE binding.seekbar.visibility = View.GONE
} }
} }
video?.setOnInfoListener { mp, what, extra ->
Log.d(TAG, "OnInfo:${what},${extra}")
return@setOnInfoListener true
}
video?.setOnCompletionListener { video?.setOnCompletionListener {
video?.seekTo(0) video?.seekTo(0)
video?.start() video?.start()
...@@ -317,7 +313,7 @@ internal fun VideoViewModel.mapOf(bean: ConfideHomeBodyBean): VideoViewModel { ...@@ -317,7 +313,7 @@ internal fun VideoViewModel.mapOf(bean: ConfideHomeBodyBean): VideoViewModel {
title.set(bean.title) title.set(bean.title)
val sb = StringBuilder() val sb = StringBuilder()
bean.confidedTag?.forEach { sb.append(it).append(" | ") } bean.confidedTag?.forEach { sb.append(it).append(" | ") }
if (sb.isNotEmpty()) { if (sb.length > 3) {
sb.setLength(sb.length - 3) sb.setLength(sb.length - 3)
} }
tag.set(sb.toString()) tag.set(sb.toString())
......
...@@ -7,5 +7,6 @@ object ConfideRoute { ...@@ -7,5 +7,6 @@ object ConfideRoute {
fun h5ConfideIntro(id: String) = "jy/listenMask?listenerId=${id}" fun h5ConfideIntro(id: String) = "jy/listenMask?listenerId=${id}"
fun h5ExpertEval(id: String) = "comment/evaList/${id}?listenerId=${id}&fromVideo=1" fun h5ExpertEval(doctorId: String, confideId: String) =
"comment/evaList/${doctorId}?listenerId=${confideId}&fromVideo=1"
} }
\ No newline at end of file
...@@ -147,15 +147,18 @@ ...@@ -147,15 +147,18 @@
/> />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<LinearLayout
<TextView
android:id="@+id/flowlayout_tag" android:id="@+id/flowlayout_tag"
android:orientation="horizontal" android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="16dp" android:layout_height="16dp"
app:layout_constraintStart_toEndOf="@id/img_bg"
android:layout_marginStart="14dp" android:layout_marginStart="14dp"
app:layout_constraintBottom_toBottomOf="@id/img_bg" android:layout_marginEnd="12dp"
/> android:textColor="#9495A0"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="@+id/img_bg"
app:layout_constraintEnd_toStartOf="@+id/price_content"
app:layout_constraintStart_toEndOf="@+id/img_bg" />
<TextView <TextView
android:id="@+id/price_content" android:id="@+id/price_content"
......
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
android:id="@+id/vDisableClick" android:id="@+id/vDisableClick"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:background="@drawable/bg_expert_video_bottom_cover"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
...@@ -163,6 +164,7 @@ ...@@ -163,6 +164,7 @@
android:layout_marginLeft="12dp" android:layout_marginLeft="12dp"
android:layout_marginRight="40dp" android:layout_marginRight="40dp"
android:layout_marginBottom="60dp" android:layout_marginBottom="60dp"
android:maxLines="1"
android:text="@{item.tag}" android:text="@{item.tag}"
android:textColor="#99FFFFFF" android:textColor="#99FFFFFF"
android:textSize="13sp" android:textSize="13sp"
...@@ -177,6 +179,7 @@ ...@@ -177,6 +179,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="40dp" android:layout_marginRight="40dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:maxLines="3"
android:text="@{item.intro}" android:text="@{item.intro}"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="15sp" android:textSize="15sp"
...@@ -202,11 +205,11 @@ ...@@ -202,11 +205,11 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="8dp" android:layout_marginLeft="8dp"
android:layout_marginBottom="1dp"
android:text="@{item.count}" android:text="@{item.count}"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="13sp" android:textSize="13sp"
app:layout_constraintBottom_toBottomOf="@+id/tvName" app:layout_constraintBottom_toBottomOf="@+id/tvName"
android:layout_marginBottom="1dp"
app:layout_constraintLeft_toRightOf="@+id/tvName" app:layout_constraintLeft_toRightOf="@+id/tvName"
tools:text="tag|tag|tag" /> tools:text="tag|tag|tag" />
......
...@@ -5,6 +5,7 @@ import android.os.Bundle ...@@ -5,6 +5,7 @@ import android.os.Bundle
import android.os.Parcelable import android.os.Parcelable
import com.alibaba.android.arouter.facade.template.IProvider import com.alibaba.android.arouter.facade.template.IProvider
import com.alibaba.android.arouter.launcher.ARouter import com.alibaba.android.arouter.launcher.ARouter
import com.ydl.ydlcommon.BuildConfig
import com.ydl.ydlcommon.utils.LogUtil import com.ydl.ydlcommon.utils.LogUtil
...@@ -12,8 +13,14 @@ import com.ydl.ydlcommon.utils.LogUtil ...@@ -12,8 +13,14 @@ import com.ydl.ydlcommon.utils.LogUtil
* Created by haorui on 2019-09-21 . * Created by haorui on 2019-09-21 .
* Des:查找 Arouter 服务封装类 * Des:查找 Arouter 服务封装类
*/ */
fun <T> findRouteService(clz: Class<T>): T? = fun <T> findRouteService(clz: Class<T>): T {
ARouter.getInstance().navigation(clz) val service = ARouter.getInstance().navigation(clz)
if (service != null) return service
if (BuildConfig.DEBUG) {
throw IllegalStateException("check module dependency by [${clz.simpleName}]")
}
return service
}
fun route(context: Context?, route: String, vararg params: Pair<String, Any?>) { fun route(context: Context?, route: String, vararg params: Pair<String, Any?>) {
......
...@@ -7,18 +7,25 @@ import androidx.fragment.app.FragmentActivity ...@@ -7,18 +7,25 @@ import androidx.fragment.app.FragmentActivity
object Loading { object Loading {
private var loadingDialogFragment: DialogFragment? = null private var loadingDialogFragment: DialogFragment? = null
fun show(context: Context?) {
fun show(context: Context?, msg: String? = null) {
if (context !is FragmentActivity) return if (context !is FragmentActivity) return
if (loadingDialogFragment == null) { if (loadingDialogFragment == null) {
loadingDialogFragment = LoadingDialogFragment.newInstance(null) loadingDialogFragment = LoadingDialogFragment2.newInstance(msg)
} }
if (loadingDialogFragment?.isAdded!!) { if (loadingDialogFragment?.isAdded!!) {
return return
} }
loadingDialogFragment?.show(context.supportFragmentManager, Loading::class.java.simpleName) // if (Looper.myLooper() == Looper.getMainLooper()) {
loadingDialogFragment?.show(context.supportFragmentManager, Loading::class.java.simpleName)
// } else
// context.runOnUiThread {
// loadingDialogFragment?.show(context.supportFragmentManager, Loading::class.java.simpleName)
// }
} }
fun close() { fun close() {
loadingDialogFragment?.dismissAllowingStateLoss() loadingDialogFragment?.dismissAllowingStateLoss()
} }
......
package com.ydl.ydlcommon.ui
import android.animation.ObjectAnimator
import android.animation.ValueAnimator
import android.os.Bundle
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.Window
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import com.ydl.ydlcommon.R
import kotlinx.android.synthetic.main.platform_fragment_loading_dialog.view.*
/**
* A simple [Fragment] subclass.
* Use the [LoadingDialogFragment2.newInstance] factory method to
* create an instance of this fragment.
*/
class LoadingDialogFragment2 : DialogFragment() {
private var msg: String? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
msg = arguments?.getString(ARG_MSG)
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
dialog?.requestWindowFeature(Window.FEATURE_NO_TITLE)
return inflater.inflate(R.layout.platform_fragment_loading_dialog2, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
startAnim(view)
if (!TextUtils.isEmpty(msg)) {
view.tvMsg.text = msg
} else {
view.tvMsg.visibility = View.GONE
}
}
override fun onStart() {
super.onStart()
dialog?.window?.setBackgroundDrawable(null)
val dp100 = (resources.displayMetrics.density * 100).toInt()
dialog?.window?.setLayout(dp100, dp100)
dialog?.window?.setDimAmount(0F)
}
private fun startAnim(view: View) {
val ivLoading = view.findViewById<View>(R.id.ivLoading)
val anim = ObjectAnimator.ofFloat(ivLoading, "rotation", 0F, 360F)
anim.duration = 1000
anim.repeatMode = ValueAnimator.RESTART
anim.repeatCount = ValueAnimator.INFINITE
anim.start()
}
companion object {
private val ARG_MSG = "arg_msg"
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param msg 要显示的信息.
* @return LoadingDialogFragment 实例
*/
fun newInstance(msg: String?): LoadingDialogFragment2 {
val fragment = LoadingDialogFragment2()
val args = Bundle()
args.putString(ARG_MSG, msg)
fragment.arguments = args
return fragment
}
}
override fun show(manager: FragmentManager, tag: String?) {
try {
//在每个add事务前增加一个remove事务,防止连续的add
manager.beginTransaction().remove(this).commitAllowingStateLoss()
super.show(manager, tag)
} catch (e: Exception) {
//同一实例使用不同的tag会异常,这里捕获一下
e.printStackTrace()
}
}
fun hide() {
dismissAllowingStateLoss()
}
}
<?xml version="1.0" encoding="utf-8" ?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="100dp"
android:layout_height="100dp"
app:cardBackgroundColor="#66000000"
app:cardElevation="0dp"
app:contentPadding="0dp"
app:cardCornerRadius="8dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/ivLoading"
android:layout_width="32dp"
android:layout_height="32dp"
android:src="@drawable/ic_loading" />
<TextView
android:id="@+id/tvMsg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:textColor="@color/white"
android:textSize="17sp"
tools:text="@string/platform_dialog_loading" />
</LinearLayout>
</androidx.cardview.widget.CardView>
\ 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