|
@@ -14,18 +14,24 @@ import com.swago.baseswago.baseroom.IRoomInfo
|
|
import com.swago.baseswago.baseroom.SwagoRoomManager
|
|
import com.swago.baseswago.baseroom.SwagoRoomManager
|
|
import com.swago.baseswago.dialog.BaseXDFragment
|
|
import com.swago.baseswago.dialog.BaseXDFragment
|
|
import com.swago.baseswago.dialog.PayDialog
|
|
import com.swago.baseswago.dialog.PayDialog
|
|
|
|
+import com.swago.baseswago.im.IMGroupNewMsgListener
|
|
|
|
+import com.swago.baseswago.im.ImConstant
|
|
|
|
+import com.swago.baseswago.model.im.CusNewMsgBean
|
|
|
|
+import com.swago.baseswago.model.im.FollowSuccessMsgBean
|
|
|
|
+import com.swago.baseswago.model.im.GameData
|
|
import com.swago.baseswago.model.live.game.GameInfoModel
|
|
import com.swago.baseswago.model.live.game.GameInfoModel
|
|
import com.swago.baseswago.util.DpPxUtil
|
|
import com.swago.baseswago.util.DpPxUtil
|
|
import com.swago.baseswago.util.SwagoInfo
|
|
import com.swago.baseswago.util.SwagoInfo
|
|
import com.swago.baseswago.util.UserInfo
|
|
import com.swago.baseswago.util.UserInfo
|
|
import com.swago.room.bean.UserRoomModel
|
|
import com.swago.room.bean.UserRoomModel
|
|
import com.swago.room.databinding.DialogGamePlayBinding
|
|
import com.swago.room.databinding.DialogGamePlayBinding
|
|
|
|
+import org.json.JSONObject
|
|
|
|
|
|
/**
|
|
/**
|
|
*@date 2022/1/19 20:41
|
|
*@date 2022/1/19 20:41
|
|
*description:
|
|
*description:
|
|
*/
|
|
*/
|
|
-class GamePlayDialog : BaseXDFragment<DialogGamePlayBinding>(),IRoomActiveListener {
|
|
|
|
|
|
+class GamePlayDialog : BaseXDFragment<DialogGamePlayBinding>(), IRoomActiveListener {
|
|
|
|
|
|
private var url = ""
|
|
private var url = ""
|
|
|
|
|
|
@@ -37,6 +43,8 @@ class GamePlayDialog : BaseXDFragment<DialogGamePlayBinding>(),IRoomActiveListen
|
|
Gson()
|
|
Gson()
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private val imGroupNewMsgListener = IMGroupNewMsgListener()
|
|
|
|
+
|
|
companion object {
|
|
companion object {
|
|
private const val URL = "url"
|
|
private const val URL = "url"
|
|
fun newInstance(url: String): GamePlayDialog {
|
|
fun newInstance(url: String): GamePlayDialog {
|
|
@@ -56,6 +64,7 @@ class GamePlayDialog : BaseXDFragment<DialogGamePlayBinding>(),IRoomActiveListen
|
|
|
|
|
|
|
|
|
|
override fun initOther() {
|
|
override fun initOther() {
|
|
|
|
+ imGroupNewMsgListener.attach()
|
|
SwagoRoomManager.addListener(this)
|
|
SwagoRoomManager.addListener(this)
|
|
arguments?.let {
|
|
arguments?.let {
|
|
url = it.getString(URL, "")
|
|
url = it.getString(URL, "")
|
|
@@ -97,6 +106,25 @@ class GamePlayDialog : BaseXDFragment<DialogGamePlayBinding>(),IRoomActiveListen
|
|
webView?.loadUrl(url)
|
|
webView?.loadUrl(url)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ imGroupNewMsgListener.handleMsgType<CusNewMsgBean<GameData>>(
|
|
|
|
+ ImConstant.fruit_game
|
|
|
|
+ ) {
|
|
|
|
+ it.data?.let { gameData ->
|
|
|
|
+ convertToJson(gameData,ImConstant.fruit_game)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ imGroupNewMsgListener.handleMsgType<CusNewMsgBean<GameData>>(
|
|
|
|
+ ImConstant.beauty_game
|
|
|
|
+ ) {
|
|
|
|
+ it.data?.let { gameData ->
|
|
|
|
+ convertToJson(gameData,ImConstant.beauty_game)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
override fun initLiveData() {}
|
|
override fun initLiveData() {}
|
|
@@ -110,7 +138,7 @@ class GamePlayDialog : BaseXDFragment<DialogGamePlayBinding>(),IRoomActiveListen
|
|
UserInfo.getUserInfo()?.let { userInfoModel ->
|
|
UserInfo.getUserInfo()?.let { userInfoModel ->
|
|
UserInfo.getLoginModel()?.let { loginModel ->
|
|
UserInfo.getLoginModel()?.let { loginModel ->
|
|
val gameInfoModel = GameInfoModel(
|
|
val gameInfoModel = GameInfoModel(
|
|
- (it as UserRoomModel).roomModel?.broadcast_id?:"",
|
|
|
|
|
|
+ (it as UserRoomModel).roomModel?.broadcast_id ?: "",
|
|
userInfoModel.id,
|
|
userInfoModel.id,
|
|
it.getAnchorId(),
|
|
it.getAnchorId(),
|
|
it.getAnchorType(),
|
|
it.getAnchorType(),
|
|
@@ -132,18 +160,42 @@ class GamePlayDialog : BaseXDFragment<DialogGamePlayBinding>(),IRoomActiveListen
|
|
|
|
|
|
@JavascriptInterface
|
|
@JavascriptInterface
|
|
fun recharge() {
|
|
fun recharge() {
|
|
- PayDialog.newInstance().show(childFragmentManager,"PayDialog")
|
|
|
|
|
|
+ PayDialog.newInstance().apply {
|
|
|
|
+ this.noticeGameDialog = {
|
|
|
|
+ val jsonObject = JSONObject()
|
|
|
|
+ jsonObject.put("type", 1000)
|
|
|
|
+ val dataJsonObject = JSONObject()
|
|
|
|
+ dataJsonObject.put("userAmount", it)
|
|
|
|
+ jsonObject.put("data", dataJsonObject)
|
|
|
|
+ webView?.loadUrl("javascript:onMessage(${jsonObject.toString()})")
|
|
|
|
+ }
|
|
|
|
+ }.show(childFragmentManager, "PayDialog")
|
|
}
|
|
}
|
|
|
|
|
|
@JavascriptInterface
|
|
@JavascriptInterface
|
|
- fun closeGame(){
|
|
|
|
|
|
+ fun closeGame() {
|
|
dismissAllowingStateLoss()
|
|
dismissAllowingStateLoss()
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ private fun convertToJson(gameData: GameData,type:Int){
|
|
|
|
+ val jsonObject = JSONObject()
|
|
|
|
+ jsonObject.put("type", type)
|
|
|
|
+ val dataJsonObject = JSONObject()
|
|
|
|
+ dataJsonObject.put("userId", gameData.userId)
|
|
|
|
+ dataJsonObject.put("betsCamp", gameData.betsCamp)
|
|
|
|
+ dataJsonObject.put("betsAmount", gameData.betsAmount)
|
|
|
|
+ dataJsonObject.put("campTotalAmount", gameData.campTotalAmount)
|
|
|
|
+ jsonObject.put("data", dataJsonObject)
|
|
|
|
+ webView?.loadUrl("javascript:onMessage(${jsonObject.toString()})")
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
override fun onDestroyView() {
|
|
override fun onDestroyView() {
|
|
try {
|
|
try {
|
|
|
|
+ imGroupNewMsgListener.detach()
|
|
webView?.apply {
|
|
webView?.apply {
|
|
webChromeClient = null
|
|
webChromeClient = null
|
|
parent?.let {
|
|
parent?.let {
|