王鹏鹏 2 лет назад
Родитель
Сommit
15eb7d5e54

+ 2 - 3
baselib/build.gradle

@@ -38,7 +38,7 @@ android {
             buildConfigField "String", "BAIDU_SECRETKEY", "\"41Fzb2ZIuKRGNtrVcQOHxEI3vFM4Rkxi\""
             buildConfigField "Boolean", "SINGLE_MODULE", "${singleModule}"
             buildConfigField "String", "BUGLY_APPID", "\"d400f20398\""
-            buildConfigField "String", "API_URL", "\"http://60.205.201.7:7111\""
+            buildConfigField "String", "API_URL", "\"http://60.205.201.7:8110\""
             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
         }
 
@@ -52,7 +52,7 @@ android {
             buildConfigField "String", "BAIDU_SECRETKEY", "\"41Fzb2ZIuKRGNtrVcQOHxEI3vFM4Rkxi\""
             buildConfigField "Boolean", "SINGLE_MODULE", "${singleModule}"
             buildConfigField "String", "BUGLY_APPID", "\"ad3db4d529\""
-            buildConfigField "String", "API_URL", "\"http://60.205.201.7:7110\""
+            buildConfigField "String", "API_URL", "\"http://60.205.201.7:8110\""
             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
         }
     }
@@ -131,5 +131,4 @@ dependencies {
     debugApi(rootProject.ext.dependencies.leakcanary)
     api(rootProject.ext.dependencies.rxbus)
     api(rootProject.ext.dependencies.retrofit2_adapter_rxjava2)
-    api 'com.alibaba:fastjson:1.1.70.android'
 }

+ 13 - 7
workbenches/src/main/java/com/yingyang/workbenches/leisurebrain/LeisureBrainActivity.kt

@@ -3,6 +3,7 @@ package com.yingyang.workbenches.leisurebrain
 import androidx.recyclerview.widget.GridLayoutManager
 import com.alibaba.android.arouter.facade.annotation.Route
 import com.alibaba.android.arouter.launcher.ARouter
+import com.yingyang.workbenches.R
 import com.yingyang.workbenches.adapter.LeisureBrainListAdapter
 import com.yingyang.workbenches.adapter.LeisureBrainTypeAdapter
 import com.yingyang.workbenches.databinding.ActivityLeisureBrainBinding
@@ -32,6 +33,7 @@ class LeisureBrainActivity :
     /**
      * 休闲健脑列表
      */
+    private var gridLayoutManager: GridLayoutManager? = null
     private var leisureBrainList = mutableListOf<LeisureBrainBean>()
     private val leisureBrainListAdapter by lazy { LeisureBrainListAdapter() }
 
@@ -53,21 +55,22 @@ class LeisureBrainActivity :
                 videoType = bean.dictValue
                 binding {
                     rvLeisureBrain.show(true)
-                    emptyLayout.show(false)
                 }
+                leisureBrainListAdapter.showEmptyView = false
                 getLeisureBrainList()
             }
 
             //休闲健脑列表
-            rvLeisureBrain.layoutManager = GridLayoutManager(this@LeisureBrainActivity, 4)
+            gridLayoutManager = GridLayoutManager(this@LeisureBrainActivity, 4)
+            rvLeisureBrain.layoutManager = gridLayoutManager
             rvLeisureBrain.adapter = leisureBrainListAdapter
             leisureBrainListAdapter.onLeisureBrainTypeClickListener = { bean ->
                 ARouter.getInstance().build(RouterUrlCommon.videoPlayer)
                     .withString("url", bean.videoUrl)
                     .withString("title", bean.videoName)
                     .withTransition(
-                        com.yingyangfly.baselib.R.anim.leftin,
-                        com.yingyangfly.baselib.R.anim.leftout
+                        R.anim.leftin,
+                        R.anim.leftout
                     )
                     .navigation(mContext)
             }
@@ -106,7 +109,6 @@ class LeisureBrainActivity :
         })
     }
 
-
     override fun onResume() {
         super.onResume()
         getLeisureBrainList()
@@ -125,8 +127,12 @@ class LeisureBrainActivity :
             if (it.isNullOrEmpty().not()) {
                 leisureBrainList.addAll(it!!)
             }
-            binding.rvLeisureBrain.show(leisureBrainList.isNullOrEmpty().not())
-            binding.emptyLayout.show(leisureBrainList.isNullOrEmpty())
+            if (leisureBrainList.isNullOrEmpty()) {
+                gridLayoutManager?.spanCount = 1
+            } else {
+                gridLayoutManager?.spanCount = 4
+            }
+            leisureBrainListAdapter.showEmptyView = leisureBrainList.isNullOrEmpty()
             leisureBrainListAdapter.setData(leisureBrainList)
         })
     }

+ 8 - 0
workbenches/src/main/res/anim/leftin.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+    <translate
+        android:duration="500"
+        android:fromXDelta="100%p"
+        android:toXDelta="0" />
+</set> 
+

+ 8 - 0
workbenches/src/main/res/anim/leftout.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+    <translate
+        android:duration="500"
+        android:fromXDelta="0"
+        android:toXDelta="-100%p" />
+</set> 
+

+ 9 - 0
workbenches/src/main/res/anim/rightin.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+    <translate
+        android:duration="500"
+        android:fromXDelta="-100%p"
+        android:toXDelta="0" />
+</set> 
+
+

+ 10 - 0
workbenches/src/main/res/anim/rightout.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+    <translate
+        android:duration="500"
+        android:fromXDelta="0"
+        android:toXDelta="100%p" />
+</set> 
+
+
+

+ 12 - 0
workbenches/src/main/res/anim/scale_anim.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<scale xmlns:android="http://schemas.android.com/apk/res/android"
+    android:duration="1000"
+    android:fillBefore="true"
+    android:fromXScale="0.8"
+    android:fromYScale="0.8"
+    android:pivotX="50%"
+    android:pivotY="50%"
+    android:repeatCount="800"
+    android:repeatMode="reverse"
+    android:toXScale="1.5"
+    android:toYScale="1.5" />

+ 3 - 17
workbenches/src/main/res/layout/activity_leisure_brain.xml

@@ -57,8 +57,8 @@
             android:background="@android:color/white"
             app:cardCornerRadius="@dimen/divider_38px"
             app:layout_constraintBottom_toBottomOf="parent"
-            app:layout_constraintStart_toEndOf="@id/rvLeisureBrainType"
             app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toEndOf="@id/rvLeisureBrainType"
             app:layout_constraintTop_toTopOf="parent">
 
             <androidx.constraintlayout.widget.ConstraintLayout
@@ -74,8 +74,8 @@
                     android:textColor="@color/color_FF4A76FF"
                     android:textSize="@dimen/divider_42px"
                     android:textStyle="bold"
-                    app:layout_constraintStart_toStartOf="parent"
                     app:layout_constraintEnd_toEndOf="parent"
+                    app:layout_constraintStart_toStartOf="parent"
                     app:layout_constraintTop_toTopOf="parent" />
 
                 <androidx.recyclerview.widget.RecyclerView
@@ -85,23 +85,9 @@
                     android:layout_margin="@dimen/divider_28px"
                     android:layout_marginTop="@dimen/divider_8px"
                     app:layout_constraintBottom_toBottomOf="parent"
-                    app:layout_constraintStart_toStartOf="parent"
                     app:layout_constraintEnd_toEndOf="parent"
+                    app:layout_constraintStart_toStartOf="parent"
                     app:layout_constraintTop_toBottomOf="@+id/tvTitle" />
-
-                <LinearLayout
-                    android:id="@+id/emptyLayout"
-                    style="@style/empty_linear_layout_style"
-                    android:visibility="gone"
-                    app:layout_constraintTop_toBottomOf="@+id/tvTitle"
-                    tools:ignore="MissingConstraints">
-
-                    <androidx.appcompat.widget.AppCompatImageView style="@style/empty_image_view_style" />
-
-                    <androidx.appcompat.widget.AppCompatTextView style="@style/empty_text_view_style" />
-
-                </LinearLayout>
-
             </androidx.constraintlayout.widget.ConstraintLayout>
         </androidx.cardview.widget.CardView>
     </androidx.constraintlayout.widget.ConstraintLayout>