From 06a80d5c4b3a971cdc1ca3d91717ec3f6e03a443 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期一, 17 五月 2021 18:59:39 +0800
Subject: [PATCH] 特价完善

---
 app/src/main/java/com/tejia/lijin/app/ui/recommend/RecommendFragment.java |   62 ++++++++++++++-----------------
 1 files changed, 28 insertions(+), 34 deletions(-)

diff --git a/app/src/main/java/com/tejia/lijin/app/ui/recommend/RecommendFragment.java b/app/src/main/java/com/tejia/lijin/app/ui/recommend/RecommendFragment.java
index aae5d9c..e28be84 100644
--- a/app/src/main/java/com/tejia/lijin/app/ui/recommend/RecommendFragment.java
+++ b/app/src/main/java/com/tejia/lijin/app/ui/recommend/RecommendFragment.java
@@ -93,6 +93,7 @@
  */
 
 public class RecommendFragment extends RetainViewFragment implements View.OnClickListener {
+    private static final String TAG = "RecommendFragment";
     private LinearLayout ll_fragment_activity, ll_special_offer, ll_limit_time_buy, ll_jinbi_exchange_buy;
     private MyGridView gv_limit_time_goods, gv_jinbi_exchange_goods;
     private SwipeRefreshLayout rl_first_page;
@@ -216,25 +217,19 @@
             super.getItemOffsets(outRect, view, parent, state);
             int index = parent.getChildAdapterPosition(view);
             int total = parent.getAdapter().getItemCount();
-            int minWidth = DimenUtils.dipToPixels(6, view.getContext());
-            if (index % 4 == 0) {
-                outRect.left = 0; //绗竴鍒楀乏杈硅创杈�
-                outRect.right = minWidth * 3;
-            } else if (index % 4 == 1) {
-                outRect.left = minWidth * 1;
-                outRect.right = minWidth * 2;
-            } else if (index % 4 == 2) {
-                outRect.left = minWidth * 2;
-                outRect.right = minWidth * 1;
+            int space = RecommendCircleSpecialAdapter.SPCAE_DP;
+
+            if (index % 2 == 0) {
+                outRect.bottom = DimenUtils.dipToPixels(space, view.getContext());
+                Log.i(TAG, circleSpecials.get(index).getName());
+            } else
+                outRect.bottom = 0;
+
+
+            if ((index == total - 1) || (index == total - 2 && total % 2 == 0)) {
+                outRect.right = 0;
             } else {
-                outRect.right = 0; //绗竴鍒楀乏杈硅创杈�
-                outRect.left = minWidth * 3;
-            }
-
-            int lastRow = total / 4;
-
-            if (lastRow != index / 4) {
-                outRect.bottom = minWidth * 4;
+                outRect.right = DimenUtils.dipToPixels(space, view.getContext());
             }
         }
     };
@@ -329,7 +324,7 @@
                     if (last == total - 1 && mList.size() < count && isLoad) {
                         page++;
                         isLoad = false;
-                        tv_loading.setText("姝e湪鍔犺浇鏇村鏁版嵁");
+                        tv_loading.setText(getResources().getString(R.string.loading_more_text));
                         iv_loading.setVisibility(View.VISIBLE);
                         guessLikeByDevice();
                     }
@@ -359,12 +354,7 @@
         getAppPageNotification();
 
         //璁剧疆鍒楄〃鍙互姘村钩婊戝姩锛屼袱琛�
-        GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 4, GridLayoutManager.VERTICAL, false) {
-            @Override
-            public boolean canScrollVertically() {
-                return false;
-            }
-        };
+        GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 2, GridLayoutManager.HORIZONTAL, false);
         rv_special_offer.setLayoutManager(layoutManager);
         specialAdapter2 = new RecommendCircleSpecialAdapter(getActivity(), circleSpecials);
         rv_special_offer.setAdapter(specialAdapter2);
@@ -759,7 +749,7 @@
                             } else {
                                 fl_fragment_activity.setVisibility(View.VISIBLE);
                             }
-                            showActivity1(list3, url);
+                            showBigActivity(list3, url);
                         }
 
                     }
@@ -1000,7 +990,7 @@
                     String url = jsonObject.optJSONObject("data")
                             .optJSONObject("activityArea").optString("bottomPicture");
 
-                    showActivity1(list3, url);
+                    showBigActivity(list3, url);
                     if (list3 == null || list3.size() == 0) {
                         fl_fragment_activity.setVisibility(View.GONE);
                     } else {
@@ -1285,10 +1275,14 @@
         });
     }
 
-    /*
-    娲诲姩涓撻3
+
+    /**
+     * 澶ф椿鍔ㄤ笓棰�
+     *
+     * @param mList
+     * @param bottomPic
      */
-    private void showActivity1(final List<SpecialOffer2> mList, String bottomPic) {
+    private void showBigActivity(final List<SpecialOffer2> mList, String bottomPic) {
         if (mList.size() > 0) {
             float screenWidth = SystemCommon.getScreenWidth(vp_banner.getContext());
             float actTotalHeight = (screenWidth - DimenUtils.dip2px(getContext(), 20)) * 7 / 20;
@@ -1300,8 +1294,8 @@
             }
             FrameLayout.LayoutParams params0 = new FrameLayout.LayoutParams((int) (screenWidth -
                     DimenUtils.dip2px(getContext(), 20)), (int) actTotalHeight);
-            params0.leftMargin = DimenUtils.dip2px(getContext(), 10);
-            params0.rightMargin = DimenUtils.dip2px(getContext(), 10);
+            params0.leftMargin = DimenUtils.dip2px(getContext(), 0);
+            params0.rightMargin = DimenUtils.dip2px(getContext(), 0);
             params0.topMargin = DimenUtils.dip2px(getContext(), 15);
             params0.bottomMargin = DimenUtils.dip2px(getContext(), 10);
             ll_fragment_activity.setLayoutParams(params0);
@@ -1311,7 +1305,7 @@
 
             iv_activity_bg.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams
                     .MATCH_PARENT, (int) actTotalHeight + DimenUtils.dip2px(getContext(), 25)));
-            Glide.with(getContext()).load(bottomPic).into(iv_activity_bg);
+//            Glide.with(getContext()).load(bottomPic).into(iv_activity_bg);
 
             for (int i = 0; i < mList.size(); i++) {
                 if (i == 0) {
@@ -1322,7 +1316,7 @@
                             (int) (screenWidth - DimenUtils.dip2px(getContext(), 20)) * 7 / 20);
                     params.gravity = Gravity.TOP;
                     iv.setLayoutParams(params);
-                    iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
+                    iv.setScaleType(ImageView.ScaleType.FIT_XY);
 
                     Glide.with(getContext()).load(info.getPicture()).into(iv);
                     iv.setOnClickListener(new View.OnClickListener() {

--
Gitblit v1.8.0