Parcourir la source

1.添加游戏是否全屏功能

王鹏鹏 il y a 2 ans
Parent
commit
52304c3884

+ 5 - 6
home/src/main/java/com/yingyangfly/home/activity/HomeActivity.kt

@@ -70,7 +70,7 @@ class HomeActivity : BaseMVVMActivity<ActivityHomeBinding, HomeViewModel>() {
                         .leftBtnText("确定")
                         .rightBtnText("取消")
                         .leftClick({
-                            jumpWebView(it)
+                            jumpWebView(it, true)
                             null
                         }, true)
                         .rightClick({
@@ -79,7 +79,7 @@ class HomeActivity : BaseMVVMActivity<ActivityHomeBinding, HomeViewModel>() {
                         .outCancel(true)
                         .show(supportFragmentManager)
                 } else {
-                    jumpWebView(it)
+                    jumpWebView(it, false)
                 }
             }
         }
@@ -145,8 +145,7 @@ class HomeActivity : BaseMVVMActivity<ActivityHomeBinding, HomeViewModel>() {
             btnTask.setOnSingleClickListener {
                 if (currentTaskRecord != null) {
                     currentTaskRecord.let {
-                        val str =
-                            it?.gameUrl + "?gameCode=" + it?.gameCode + "&playClass=A" + "&userToken=" + User.getToken()
+                        val str = it?.gameUrl + "?gameCode=" + it?.gameCode + "&isFull=true&isSound=true&playClass=A" + "&userToken=" + User.getToken()
                         JumpUtil.jumpActivityWithUrl(
                             RouterUrlCommon.WEB_VIEW_INTERACTION_JS,
                             str,
@@ -411,9 +410,9 @@ class HomeActivity : BaseMVVMActivity<ActivityHomeBinding, HomeViewModel>() {
     /**
      * 跳转游戏列表
      */
-    private fun jumpWebView(bean: Record) {
+    private fun jumpWebView(bean: Record, isFull: Boolean) {
         val str =
-            bean.gameUrl + "?gameCode=" + bean.gameCode + "&isFull=true&isSound=true&playClass=" + bean.playClass +
+            bean.gameUrl + "?gameCode=" + bean.gameCode + "&isFull=" + isFull + "&isSound=true&playClass=" + bean.playClass +
                     "&userToken=" + User.getToken()
         JumpUtil.jumpActivityWithUrl(RouterUrlCommon.WEB_VIEW_INTERACTION_JS, str, this)
     }

+ 27 - 25
livebroadcast/src/main/java/com/yingyang/livebroadcast/activity/list/LiveBroadcastListActivity.kt

@@ -52,8 +52,11 @@ class LiveBroadcastListActivity :
     private val liveBroadcastAdapter by lazy { LiveBroadcastAdapter() }
 
     override fun initViews() {
-        enableLoadMore(true)
-        enableRefresh(true)
+        binding {
+            liveSwipe.setEnableLoadMore(true)
+            liveSwipe.setEnableRefresh(true)
+        }
+
         binding {
             gridLayoutManager = GridLayoutManager(mContext, 2)
             rvLiveBroadcast.layoutManager = gridLayoutManager
@@ -87,35 +90,23 @@ class LiveBroadcastListActivity :
                     R.id.rdb_appointment -> {
                         method = "1"
                         liveBroadcastAdapter.setType("预约直播")
-                        loadData(true)
+                        loadData(true, true)
                     }
                     R.id.rdb_live -> {
                         method = "2"
                         liveBroadcastAdapter.setType("直播中")
-                        loadData(true)
+                        loadData(true, true)
                     }
                     else -> {
                         method = "3"
                         liveBroadcastAdapter.setType("直播回放")
-                        loadData(true)
+                        loadData(true, true)
                     }
                 }
             }
         }
     }
 
-    override fun onRefresh(refreshLayout: RefreshLayout) {
-        super.onRefresh(refreshLayout)
-        loadData(true)
-        liveBroadcastAdapter.clearData()
-        liveBroadcastAdapter.showEmptyView = false
-    }
-
-    override fun onLoadMore(refreshLayout: RefreshLayout) {
-        super.onLoadMore(refreshLayout)
-        loadData(false)
-    }
-
     /**
      * 预约直播
      */
@@ -123,7 +114,7 @@ class LiveBroadcastListActivity :
         viewModel.reservationLive(method, fail = {
             it.show()
         }, success = {
-            loadData(true)
+            loadData(true, true)
         })
     }
 
@@ -133,6 +124,15 @@ class LiveBroadcastListActivity :
                 JumpUtil.jumpActivity(RouterUrlCommon.home, mContext)
                 finish()
             }
+
+            liveSwipe.setOnRefreshListener {
+                liveBroadcastAdapter.clearData()
+                liveBroadcastAdapter.showEmptyView = false
+                loadData(true, false)
+            }
+            liveSwipe.setOnLoadMoreListener {
+                loadData(false, false)
+            }
         }
     }
 
@@ -140,22 +140,22 @@ class LiveBroadcastListActivity :
         liveBroadcastAdapter.setType("预约直播")
         liveBroadcastAdapter.clearData()
         liveBroadcastAdapter.showEmptyView = false
-        loadData(true)
+        loadData(true, true)
     }
 
     /**
      * 获取直播列表
      */
-    private fun loadData(isRefresh: Boolean) {
+    private fun loadData(isRefresh: Boolean, showLoading: Boolean) {
         if (isRefresh) {
             liveBroadcastList.clear()
             liveBroadcastAdapter.clearData()
-            resetNoMoreData()
+            binding.liveSwipe.resetNoMoreData()
             page = 1
         } else {
             page++
         }
-        viewModel.getLiveList(method, page, fail = {
+        viewModel.getLiveList(showLoading, method, page, fail = {
             endRefresh()
             it.toast()
         }, success = {
@@ -165,7 +165,7 @@ class LiveBroadcastListActivity :
                     liveBroadcastList.addAll(it.records)
                 }
                 if (page >= it.pages) {
-                    finishLoadMoreWithNoMoreData()
+                    binding.liveSwipe.finishLoadMoreWithNoMoreData()
                 }
             }
             if (liveBroadcastList.isNullOrEmpty()) {
@@ -182,8 +182,10 @@ class LiveBroadcastListActivity :
      * 结束刷新状态
      */
     private fun endRefresh() {
-        finishRefresh()
-        finishLoadMore()
+        binding {
+            liveSwipe.finishRefresh()
+            liveSwipe.finishLoadMore()
+        }
     }
 
     /**

+ 2 - 1
livebroadcast/src/main/java/com/yingyang/livebroadcast/activity/list/LiveBroadcastListViewModel.kt

@@ -18,11 +18,12 @@ class LiveBroadcastListViewModel : BaseViewModel() {
      * 获取直播列表
      */
     fun getLiveList(
+        showLoading: Boolean,
         method: String,
         pageStr: Int,
         fail: ((msg: String) -> Unit)? = null,
         success: ((success: LiveBroadcastListBean?) -> Unit)? = null,
-    ) = launchFlow(true) {
+    ) = launchFlow(showLoading) {
         val requestBean = LiveBroadcastListRequestBodyBean().apply {
             page = pageStr.toString()
             limit = "10"

+ 14 - 9
livebroadcast/src/main/res/layout/activity_live_broadcast_list.xml

@@ -48,8 +48,8 @@
             android:layout_marginTop="@dimen/divider_36px"
             android:gravity="center"
             android:orientation="horizontal"
-            app:layout_constraintStart_toStartOf="parent"
             app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
             app:layout_constraintTop_toTopOf="parent">
 
             <RadioButton
@@ -72,18 +72,23 @@
                 android:text="@string/live_playback" />
         </RadioGroup>
 
-        <androidx.recyclerview.widget.RecyclerView
-            android:id="@+id/rvLiveBroadcast"
+        <com.scwang.smartrefresh.layout.SmartRefreshLayout
+            android:id="@+id/liveSwipe"
             android:layout_width="match_parent"
             android:layout_height="0dp"
-            android:layout_marginLeft="@dimen/divider_60px"
-            android:layout_marginTop="@dimen/divider_47px"
-            android:layout_marginRight="@dimen/divider_60px"
             app:layout_constraintBottom_toBottomOf="parent"
-            app:layout_constraintStart_toStartOf="parent"
             app:layout_constraintEnd_toEndOf="parent"
-            app:layout_constraintTop_toBottomOf="@+id/radioLive" />
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/radioLive">
 
-    </androidx.constraintlayout.widget.ConstraintLayout>
+            <androidx.recyclerview.widget.RecyclerView
+                android:id="@+id/rvLiveBroadcast"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_marginLeft="@dimen/divider_60px"
+                android:layout_marginTop="@dimen/divider_47px"
+                android:layout_marginRight="@dimen/divider_60px" />
 
+        </com.scwang.smartrefresh.layout.SmartRefreshLayout>
+    </androidx.constraintlayout.widget.ConstraintLayout>
 </layout>

+ 1 - 1
workbenches/src/main/java/com/yingyang/workbenches/freetraining/FreeTrainActivity.kt

@@ -64,7 +64,7 @@ class FreeTrainActivity : BaseMVVMActivity<ActivityFreeTrainBinding, FreeTrainVi
             freeTrainListAdapter.setType(type)
             freeTrainListAdapter.onGameClickListener = { bean ->
                 val str =
-                    bean.gameUrl + "?gameCode=" + bean.gameCode + "&isFull=true&isSound=true&playClass=" + bean.playClass +
+                    bean.gameUrl + "?gameCode=" + bean.gameCode + "&isFull=false&isSound=true&playClass=" + bean.playClass +
                             "&userToken=" + User.getToken()
                 JumpUtil.jumpActivityWithUrl(RouterUrlCommon.WEB_VIEW_INTERACTION_JS, str, mContext)
             }