Explorar o código

修改im群投诉pad适配效果

Pq hai 1 ano
pai
achega
e3d69c96ed

+ 21 - 1
chatModule/src/main/java/com/cooleshow/chatmodule/adapter/AddPhotoListAdapter.java

@@ -1,18 +1,25 @@
 package com.cooleshow.chatmodule.adapter;
 
 import android.view.View;
+import android.view.ViewGroup;
 import android.widget.ImageView;
 
 import com.chad.library.adapter.base.BaseQuickAdapter;
 import com.chad.library.adapter.base.viewholder.BaseViewHolder;
 import com.cooleshow.base.utils.GlideImageLoaderUtils;
 import com.cooleshow.base.utils.GlideUtils;
+import com.cooleshow.base.utils.SizeUtils;
+import com.cooleshow.base.utils.Utils;
+import com.cooleshow.base.utils.helper.QMUIDeviceHelper;
 import com.cooleshow.chatmodule.R;
 import com.cooleshow.chatmodule.utils.helper.IMThemManager;
 import com.luck.picture.lib.entity.LocalMedia;
 
 import java.util.List;
 
+import androidx.constraintlayout.widget.ConstraintLayout;
+import androidx.recyclerview.widget.RecyclerView;
+
 /**
  * 创建日期:2022/6/13 14:22
  *
@@ -21,9 +28,12 @@ import java.util.List;
  */
 public class AddPhotoListAdapter extends BaseQuickAdapter<LocalMedia, BaseViewHolder> {
 
+    private final boolean isTablet;
+
     public AddPhotoListAdapter(List<LocalMedia> data) {
         super(R.layout.tc_photo_list_item, data);
         addChildClickViewIds(R.id.iv_del);
+        isTablet = QMUIDeviceHelper.isTablet(Utils.getApp());
     }
 
     @Override
@@ -36,9 +46,19 @@ public class AddPhotoListAdapter extends BaseQuickAdapter<LocalMedia, BaseViewHo
             ivIcon.setImageResource(addPicDefaultImgRes != -1 ? addPicDefaultImgRes : R.drawable.tc_ic_update_photo);
         } else {
             iv_del.setVisibility(View.VISIBLE);
-            GlideImageLoaderUtils.getInstance().loadCustRoundCircleImage(getContext(),item.getPath(), ivIcon,10);
+            GlideImageLoaderUtils.getInstance().loadCustRoundCircleImage(getContext(), item.getPath(), ivIcon, 10);
         }
 
+        ConstraintLayout cs_root = helper.getView(R.id.cs_root);
+        RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) cs_root.getLayoutParams();
+        if (isTablet) {
+            layoutParams.width = RecyclerView.LayoutParams.WRAP_CONTENT;
+            cs_root.setPadding(0, 0, SizeUtils.dp2px(16), 0);
+        } else {
+            layoutParams.width = RecyclerView.LayoutParams.MATCH_PARENT;
+            cs_root.setPadding(0, 0, 0, 0);
+        }
+        cs_root.setLayoutParams(layoutParams);
     }
 
 }

+ 9 - 2
chatModule/src/main/java/com/cooleshow/chatmodule/ui/ImAppealActivity.java

@@ -23,6 +23,7 @@ import com.cooleshow.base.router.RouterPath;
 import com.cooleshow.base.ui.activity.BaseMVPActivity;
 import com.cooleshow.base.utils.ToastUtil;
 import com.cooleshow.base.utils.helper.GlideEngine;
+import com.cooleshow.base.utils.helper.QMUIDeviceHelper;
 import com.cooleshow.base.utils.helper.QMUIStatusBarHelper;
 import com.cooleshow.base.utils.helper.upload.UploadHelper;
 import com.cooleshow.chatmodule.R;
@@ -46,6 +47,7 @@ import java.util.Locale;
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 import androidx.recyclerview.widget.GridLayoutManager;
+import androidx.recyclerview.widget.LinearLayoutManager;
 import androidx.recyclerview.widget.RecyclerView;
 
 /**
@@ -115,8 +117,13 @@ public class ImAppealActivity extends BaseMVPActivity<TcActivityImAppealBinding,
         btn_commit = viewBinding.btnCommit;
         IMThemManager.getInstance().setMainButtonStyles(btn_commit);
         recyclerView = viewBinding.recyclerView;
-        GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 3);
-        recyclerView.setLayoutManager(gridLayoutManager);
+        RecyclerView.LayoutManager layoutManager;
+        if(QMUIDeviceHelper.isTablet(this)){
+            layoutManager = new LinearLayoutManager(this,RecyclerView.HORIZONTAL,false);
+        }else{
+            layoutManager = new GridLayoutManager(this, 3);
+        }
+        recyclerView.setLayoutManager(layoutManager);
         addNewEmpty();
         addPhotoListAdapter = new AddPhotoListAdapter(selectList);
         recyclerView.setAdapter(addPhotoListAdapter);

+ 2 - 1
chatModule/src/main/res/layout/tc_photo_list_item.xml

@@ -1,7 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
 <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:layout_width="match_parent"
+    android:layout_width="wrap_content"
+    android:id="@+id/cs_root"
     android:layout_height="wrap_content">
 
     <ImageView