tongmengxiao преди 6 месеца
родител
ревизия
b74ae9f34c

+ 10 - 0
baseswago/src/main/java/com/swago/glide.kt

@@ -8,6 +8,7 @@ import android.widget.ImageView
 import androidx.annotation.DrawableRes
 import androidx.annotation.RequiresApi
 import com.bumptech.glide.Glide
+import com.bumptech.glide.load.engine.DiskCacheStrategy
 import com.bumptech.glide.request.RequestOptions
 import com.swago.baseswago.R
 import jp.wasabeef.glide.transformations.BlurTransformation
@@ -35,6 +36,15 @@ fun ImageView.loadUrl(context: Context,url:String){
         .into(this)
 }
 
+fun ImageView.loadUrlCache(context: Context,url:String){
+    Glide.with(context)
+        .load(url)
+        .centerCrop()
+        .diskCacheStrategy(DiskCacheStrategy.ALL)
+        .placeholder(R.mipmap.default_avatar)
+        .error(R.mipmap.default_avatar)
+        .into(this)
+}
 fun ImageView.loadUrlNoPlaceHolder(context: Context,url:String){
     Glide.with(context)
         .load(url)

+ 9 - 2
home/src/main/java/com/swago/home/innerhome/FollowFragment.kt

@@ -14,6 +14,7 @@ import com.swago.baseswago.fragment.BaseListFragment
 import com.swago.baseswago.fragment.BaseXFragment
 import com.swago.baseswago.model.MomentModel
 import com.swago.baseswago.model.home.HomeModel
+import com.swago.baseswago.util.SpUtil
 import com.swago.home.databinding.FragmentFollowBinding
 import com.swago.home.databinding.FragmentHotBinding
 
@@ -25,6 +26,8 @@ class FollowFragment : BaseListFragment<FragmentHotBinding, MomentModel>(){
 
     private val homeVm  by viewModels<HomeVm>()
     private var isFirstLoadData = true
+    //点击position
+    private var mCurrentPosition = 0
     override val smartRecyclerView: SwagoRecyclerView<MomentModel> by lazy {
         binding.rv as SwagoRecyclerView<MomentModel>
     }
@@ -39,10 +42,12 @@ class FollowFragment : BaseListFragment<FragmentHotBinding, MomentModel>(){
     }
 
     override fun initViewData() {
+        SpUtil.putInt("followCloseRoomed" , 0)
         binding.rvLabel.visibility = View.GONE
         smartRecyclerView.recyclerView?.addItemDecoration(ComGridItemDecoration())
         adapter.setOnItemClickListener { _, _, position ->
             if (adapter.data.size>position){
+                mCurrentPosition = position
                 ARouter.getInstance()
                     .build(ARouteConstant.Room.user)
                     .withInt("position",position)
@@ -75,8 +80,10 @@ class FollowFragment : BaseListFragment<FragmentHotBinding, MomentModel>(){
 
     override fun onResume() {
         super.onResume()
-        if (!isFirstLoadData){
-            smartRecyclerView.startRefresh()
+        if (SpUtil.readInt("followCloseRoomed") == 1 && adapter.data.size > mCurrentPosition){
+            adapter.data.removeAt(mCurrentPosition)
+            adapter.notifyDataSetChanged()
+            SpUtil.putInt("followCloseRoomed" , 0)
         }
         isFirstLoadData = false
     }

+ 10 - 2
home/src/main/java/com/swago/home/innerhome/HotFragment.kt

@@ -13,6 +13,7 @@ import com.swago.baseswago.cusview.SwagoRecyclerView
 import com.swago.baseswago.fragment.BaseListFragment
 import com.swago.baseswago.model.MomentModel
 import com.swago.baseswago.model.home.BannerModel
+import com.swago.baseswago.util.SpUtil
 import com.swago.baseswago.util.SwagoInfo
 import com.swago.home.databinding.FragmentHotBinding
 import com.swago.home.databinding.LayoutViewHeaderBinding
@@ -43,6 +44,9 @@ class HotFragment : BaseListFragment<FragmentHotBinding, MomentModel>() {
     //印尼,马来默认印尼;阿拉伯语默认阿拉伯语;其他语默认打开是展示全球
     private var matchLanguageId = 0
 
+    //点击position
+    private var mCurrentPosition = 0
+
     override val loadData: (page: Int) -> Unit = {
         homeVm.getHotList(1, it + 1,labelValue)
     }
@@ -60,6 +64,7 @@ class HotFragment : BaseListFragment<FragmentHotBinding, MomentModel>() {
 
 
     override fun initViewData() {
+        SpUtil.putInt("hotCloseRoomed" , 0)
         UrlConstant.getConfigModel()?.let {
             if (!it.language_lables.isNullOrEmpty()){
                 matchLanguageId = when(SwagoInfo.languageId){
@@ -117,6 +122,7 @@ class HotFragment : BaseListFragment<FragmentHotBinding, MomentModel>() {
 
         smartRecyclerView.recyclerView?.addItemDecoration(HomeGridItemDecoration())
         adapter.setOnItemClickListener { _, _, position ->
+            mCurrentPosition = position
             ARouter.getInstance()
                 .build(ARouteConstant.Room.user)
                 .withInt("position", position)
@@ -159,8 +165,10 @@ class HotFragment : BaseListFragment<FragmentHotBinding, MomentModel>() {
 
     override fun onResume() {
         super.onResume()
-        if (!isFirstLoadData){
-            smartRecyclerView.startRefresh()
+        if (SpUtil.readInt("hotCloseRoomed") == 1 && adapter.data.size > mCurrentPosition){
+            adapter.data.removeAt(mCurrentPosition)
+            adapter.notifyDataSetChanged()
+            SpUtil.putInt("hotCloseRoomed" , 0)
         }
         isFirstLoadData = false
     }

+ 10 - 2
home/src/main/java/com/swago/home/innerhome/NewFragment.kt

@@ -13,6 +13,7 @@ import com.swago.baseswago.fragment.BaseListFragment
 import com.swago.baseswago.fragment.BaseXFragment
 import com.swago.baseswago.model.MomentModel
 import com.swago.baseswago.model.home.HomeModel
+import com.swago.baseswago.util.SpUtil
 import com.swago.baseswago.util.SwagoInfo
 import com.swago.home.databinding.FragmentHotBinding
 import com.swago.home.databinding.FragmentNewBinding
@@ -43,11 +44,15 @@ class NewFragment  : BaseListFragment<FragmentHotBinding, MomentModel>(){
     //印尼,马来默认印尼;阿拉伯语默认阿拉伯语;其他语默认打开是展示全球
     private var matchLanguageId = 0
 
+    //点击position
+    private var mCurrentPosition = 0
+
     override val loadData: (page: Int) -> Unit = {
         homeVm.getHomeList(2, it+1,labelValue)
     }
 
     override fun initViewData() {
+        SpUtil.putInt("newCloseRoomed" , 0)
         UrlConstant.getConfigModel()?.let {
             if (!it.language_lables.isNullOrEmpty()){
                 matchLanguageId = when(SwagoInfo.languageId){
@@ -91,6 +96,7 @@ class NewFragment  : BaseListFragment<FragmentHotBinding, MomentModel>(){
 
         smartRecyclerView.recyclerView?.addItemDecoration(ComGridItemDecoration())
         adapter.setOnItemClickListener { _, _, position ->
+            mCurrentPosition = position
             ARouter.getInstance()
                 .build(ARouteConstant.Room.user)
                 .withInt("position",position)
@@ -117,8 +123,10 @@ class NewFragment  : BaseListFragment<FragmentHotBinding, MomentModel>(){
 
     override fun onResume() {
         super.onResume()
-        if (!isFirstLoadData){
-            smartRecyclerView.startRefresh()
+        if (SpUtil.readInt("newCloseRoomed") == 1 && adapter.data.size > mCurrentPosition){
+            adapter.data.removeAt(mCurrentPosition)
+            adapter.notifyDataSetChanged()
+            SpUtil.putInt("newCloseRoomed" , 0)
         }
         isFirstLoadData = false
     }

+ 3 - 0
room/src/main/java/com/swago/room/vm/RoomVm.kt

@@ -103,6 +103,9 @@ class RoomVm(application: Application) : AbsRoomVm(application) {
             requestError {
                 if (it is SwagoException) {
                     if (it.code == 504) {
+                        SpUtil.putInt("hotCloseRoomed",1)
+                        SpUtil.putInt("newCloseRoomed",1)
+                        SpUtil.putInt("followCloseRoomed",1)
                         Toast.makeText(AppContext.getContext(), it.message, Toast.LENGTH_SHORT)
                             .show()
                         if (SwagoRoomManager.iRoomInfo == null){