|
@@ -1,232 +0,0 @@
|
|
|
-package com.swago.room.black
|
|
|
-
|
|
|
-import android.view.View
|
|
|
-import android.view.ViewGroup
|
|
|
-import android.view.WindowManager
|
|
|
-import android.widget.FrameLayout
|
|
|
-import android.widget.ImageView
|
|
|
-import android.widget.Toast
|
|
|
-import androidx.activity.viewModels
|
|
|
-import androidx.constraintlayout.widget.ConstraintLayout
|
|
|
-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.bumptech.glide.Glide
|
|
|
-import com.bumptech.glide.request.RequestOptions
|
|
|
-import com.gyf.immersionbar.ImmersionBar
|
|
|
-import com.swago.baseswago.SwagoAdapter
|
|
|
-import com.swago.baseswago.agora.AgoraManager
|
|
|
-import com.swago.baseswago.baseroom.IRoomInfo
|
|
|
-import com.swago.baseswago.baseroom.SwagoRoomManager
|
|
|
-import com.swago.baseswago.baseroom.ui.AbsUserActivity
|
|
|
-import com.swago.baseswago.constant.ARouteConstant
|
|
|
-import com.swago.baseswago.databinding.ActivityAbsRoomUserBinding
|
|
|
-import com.swago.baseswago.model.MomentModel
|
|
|
-import com.swago.baseswago.util.*
|
|
|
-import com.swago.room.R
|
|
|
-import com.swago.room.audio.AudioRoomManager
|
|
|
-import com.swago.room.base.NoContentFragment
|
|
|
-import com.swago.room.bean.UserRoomModel
|
|
|
-import com.swago.room.data.RoomDataManager
|
|
|
-import com.swago.room.enum.RoomType
|
|
|
-import com.swago.room.lianmai.LianMaiManager
|
|
|
-import com.swago.room.pk.PKStateManager
|
|
|
-import com.swago.room.user.UserRoomFragment
|
|
|
-import com.swago.room.vm.MsgVm
|
|
|
-import com.swago.room.vm.RoomVm
|
|
|
-import com.swago.room.widget.ChoiceViewPager
|
|
|
-import com.swago.room.widget.UserShowAnchorCloseView
|
|
|
-import jp.wasabeef.glide.transformations.BlurTransformation
|
|
|
-import java.util.concurrent.CopyOnWriteArrayList
|
|
|
-
|
|
|
-@Route(path = ARouteConstant.Room.black)
|
|
|
-class BlackRoomActivity : AbsUserActivity<ActivityAbsRoomUserBinding, UserRoomModel>(){
|
|
|
-
|
|
|
- private val roomVm by viewModels<RoomVm>()
|
|
|
- private val msgVm by viewModels<MsgVm>()
|
|
|
-
|
|
|
- private val fragments by lazy{
|
|
|
- listOf(NoContentFragment(), UserRoomFragment())
|
|
|
- }
|
|
|
-
|
|
|
- @Autowired
|
|
|
- @JvmField
|
|
|
- var position: Int = 0
|
|
|
-
|
|
|
- @Autowired
|
|
|
- @JvmField
|
|
|
- var data: ArrayList<MomentModel>? = null
|
|
|
-
|
|
|
- private var userRoomFragment: UserRoomFragment? = null
|
|
|
-
|
|
|
- private var ivClose: ImageView? = null
|
|
|
- private var ivCover: ImageView? = null
|
|
|
- private var userShowAnchorCloseView: UserShowAnchorCloseView? = null
|
|
|
- private var flRoot: FrameLayout? = null
|
|
|
- private var peerFl: FrameLayout? = null
|
|
|
- private var choiceViewPager:ChoiceViewPager? = null
|
|
|
-
|
|
|
- override val roomCoverView: ViewGroup by lazy {
|
|
|
- val userRoomView = layoutInflater.inflate(R.layout.layout_user_room, null) as ViewGroup
|
|
|
- choiceViewPager = userRoomView.findViewById<ChoiceViewPager>(R.id.viewPager)
|
|
|
- ivClose = userRoomView.findViewById(R.id.ivClose)
|
|
|
- userShowAnchorCloseView = userRoomView.findViewById(R.id.userShowAnchorCloseView)
|
|
|
-// ivCover = userRoomView.findViewById(R.id.ivCover)
|
|
|
- flRoot = userRoomView.findViewById(R.id.flRoot)
|
|
|
- peerFl = userRoomView.findViewById(R.id.peerFl)
|
|
|
- choiceViewPager?.adapter = SwagoAdapter(fragments, supportFragmentManager)
|
|
|
- choiceViewPager?.currentItem = 1
|
|
|
- userRoomView
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- override var mCurrentPosition: Int = position
|
|
|
- override var iRoomInfos: CopyOnWriteArrayList<UserRoomModel> = RoomDataManager.data
|
|
|
-
|
|
|
- override fun initUserRoomView() {
|
|
|
- ARouter.getInstance().inject(this)
|
|
|
- mCurrentPosition = position
|
|
|
- RoomDataManager.initData(data)
|
|
|
- userRoomFragment = fragments[1] as UserRoomFragment
|
|
|
-
|
|
|
- roomVm.init()
|
|
|
- msgVm.init()
|
|
|
- initPeerAnchorLayoutParams()
|
|
|
- window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
|
|
-
|
|
|
- ivClose?.setOnClickListener(object : NoDoubleClickListener() {
|
|
|
- override fun onClick() {
|
|
|
-
|
|
|
- finish()
|
|
|
-
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- override fun initLiveData() {
|
|
|
- msgVm.anchorRoomClosed = {
|
|
|
- userShowAnchorCloseView?.visibility = View.VISIBLE
|
|
|
- it?.let { userShowAnchorCloseView?.setData(it) }
|
|
|
- SwagoRoomManager.receiveStopLive()
|
|
|
- }
|
|
|
-
|
|
|
- msgVm.kickFromRoom = {
|
|
|
- Toast.makeText(
|
|
|
- AppContext.getContext(),
|
|
|
- AppContext.getContext().resources.getString(R.string.be_kick_out),
|
|
|
- Toast.LENGTH_SHORT
|
|
|
- ).show()
|
|
|
- SwagoRoomManager.closeRoom()
|
|
|
- }
|
|
|
-
|
|
|
- roomVm.roomClosedLiveData.observe(this) {
|
|
|
- userShowAnchorCloseView?.visibility = View.VISIBLE
|
|
|
- it?.let { userShowAnchorCloseView?.setData(it) }
|
|
|
- }
|
|
|
-
|
|
|
- roomVm.momentModelLiveData.observe(this) {
|
|
|
- val userRoomModel = UserRoomModel()
|
|
|
- userRoomModel.momentModel = it
|
|
|
- iRoomInfos.add(userRoomModel)
|
|
|
- scrollToPosition(iRoomInfos.lastIndex)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- override fun changeRoom(iRoomInfo: IRoomInfo) {
|
|
|
- isRobot = iRoomInfo.getIsRobot()
|
|
|
- ivCover?.let {
|
|
|
- Glide.with(this)
|
|
|
- .load(iRoomInfo.getRoomCover())
|
|
|
- .dontAnimate()
|
|
|
- .apply(RequestOptions.bitmapTransform(BlurTransformation(5, 100)))
|
|
|
- .into(it)
|
|
|
- }
|
|
|
- ivCover?.visibility = View.VISIBLE
|
|
|
- userShowAnchorCloseView?.visibility = View.INVISIBLE
|
|
|
-
|
|
|
- when(iRoomInfo.getRoomType()){
|
|
|
- RoomType.VIDEO.type -> {
|
|
|
- choiceViewPager?.setCanScroll(true)
|
|
|
- AgoraManager.setVideoAudio(
|
|
|
- pullVideo = true,
|
|
|
- pullAudio = true,
|
|
|
- pushVideo = false,
|
|
|
- pushAudio = false
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
- RoomType.AUDIO.type -> {
|
|
|
- choiceViewPager?.setCanScroll(false)
|
|
|
- AgoraManager.setVideoAudio(
|
|
|
- pullVideo = false,
|
|
|
- pullAudio = true,
|
|
|
- pushVideo = false,
|
|
|
- pushAudio = false
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
- RoomType.NULL.type -> {}
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- override fun leaveRoom(iRoomInfo: IRoomInfo) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- override fun joinedRoom(iRoomInfo: IRoomInfo) {
|
|
|
- ivCover?.visibility = View.GONE
|
|
|
- }
|
|
|
-
|
|
|
- override fun receiveStopLive() {
|
|
|
- AudioRoomManager.resetData()
|
|
|
- SwagoRoomManager.iRoomInfo?.let {
|
|
|
- if (it.getRoomType() == RoomType.AUDIO.type){
|
|
|
- AgoraManager.setVideoAudio(
|
|
|
- pullVideo = false,
|
|
|
- pullAudio = false,
|
|
|
- pushVideo = false,
|
|
|
- pushAudio = false
|
|
|
- )
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- override fun endRoom(iRoomInfo: IRoomInfo?) {
|
|
|
- }
|
|
|
-
|
|
|
- override fun closeRoomed() {
|
|
|
- }
|
|
|
-
|
|
|
- override fun onBackPressed() {
|
|
|
- SwagoRoomManager.closeRoom()
|
|
|
- }
|
|
|
-
|
|
|
- override fun onDestroy() {
|
|
|
- super.onDestroy()
|
|
|
- }
|
|
|
-
|
|
|
- private var isRobot = false
|
|
|
-
|
|
|
-
|
|
|
- private val marginTopValue by lazy {
|
|
|
- ImmersionBar.getStatusBarHeight(this) + DpPxUtil.dip2px(78f)
|
|
|
- }
|
|
|
-
|
|
|
- private fun initPeerAnchorLayoutParams() {
|
|
|
- val x = DpPxUtil.getScreenWidth() / 2
|
|
|
- val y = DpPxUtil.getScreenWidth() * 275 / 360
|
|
|
- val params = ConstraintLayout.LayoutParams(x, y)
|
|
|
- params.topToTop = R.id.rootUserView
|
|
|
- params.endToEnd = R.id.rootUserView
|
|
|
- params.width = x
|
|
|
- params.height = y
|
|
|
- params.topMargin = marginTopValue
|
|
|
- peerFl?.layoutParams = params
|
|
|
- }
|
|
|
-
|
|
|
- override fun moveTaskToBack(nonRoot: Boolean): Boolean {
|
|
|
- return super.moveTaskToBack(true)
|
|
|
- }
|
|
|
-}
|