From ddff7888bf7e754d12fb5fc85a58f3012f456490 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期六, 05 六月 2021 17:26:03 +0800 Subject: [PATCH] 特价完善 --- app/src/main/java/com/tejia/lijin/app/ui/recommend/RecommendFragment.java | 314 ++++++++++++++++++++++++++++----------------------- 1 files changed, 173 insertions(+), 141 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 3b488ec..8b8e147 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 @@ -5,22 +5,15 @@ import android.content.SharedPreferences; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Rect; import android.graphics.drawable.AnimationDrawable; import android.graphics.drawable.GradientDrawable; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.provider.Settings; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.viewpager.widget.PagerAdapter; -import androidx.viewpager.widget.ViewPager; -import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; -import androidx.recyclerview.widget.GridLayoutManager; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; @@ -40,21 +33,12 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; +import com.lzj.gallery.library.views.BannerViewPager; import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator; -import com.viewpagerindicator.LinePageIndicator; -import com.wpc.library.RetainViewFragment; -import com.wpc.library.content.ConnectivityChangeHelper; -import com.wpc.library.util.NetUtils; -import com.wpc.library.util.SystemCommon; -import com.wpc.library.util.cache.DiskLruCache; -import com.wpc.library.util.common.DimenUtils; -import com.wpc.library.util.common.StorageUtils; -import com.wpc.library.util.common.StringUtils; -import com.wpc.library.widget.MyGridView; -import com.wpc.library.widget.RatioLayout; import com.tejia.lijin.app.BasicTextHttpResponseHandler; import com.tejia.lijin.app.R; import com.tejia.lijin.app.ShoppingApi; +import com.tejia.lijin.app.ShoppingApplication; import com.tejia.lijin.app.entity.FirstCategory; import com.tejia.lijin.app.entity.HomeBanner; import com.tejia.lijin.app.entity.JumpDetail; @@ -68,8 +52,20 @@ import com.tejia.lijin.app.ui.timeLimitedSpike.TimeLimitedSpikeActivity; import com.tejia.lijin.app.util.FlowLayout; import com.tejia.lijin.app.util.JumpActivityUtil; +import com.tejia.lijin.app.util.ui.HomeUIUtil; import com.tejia.lijin.app.util.umengCustomEvent.MainCustomEvent; import com.tejia.lijin.app.util.user.UserUtil; +import com.wpc.library.RetainViewFragment; +import com.wpc.library.content.ConnectivityChangeHelper; +import com.wpc.library.util.NetUtils; +import com.wpc.library.util.ScreenUtils; +import com.wpc.library.util.SystemCommon; +import com.wpc.library.util.cache.DiskLruCache; +import com.wpc.library.util.common.DimenUtils; +import com.wpc.library.util.common.StorageUtils; +import com.wpc.library.util.common.StringUtils; +import com.wpc.library.widget.MyGridView; +import com.wpc.library.widget.RatioLayout; import org.apache.http.Header; import org.json.JSONException; @@ -82,6 +78,15 @@ import java.util.Iterator; import java.util.List; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; +import androidx.viewpager.widget.PagerAdapter; +import androidx.viewpager.widget.ViewPager; + import static android.content.Context.MODE_PRIVATE; /** @@ -90,26 +95,23 @@ */ public class RecommendFragment extends RetainViewFragment implements View.OnClickListener { - // private RecyclerView rv_first_page, rv_special_offer; + 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; private ImageView iv_activity_bg, iv_slid_top, iv_input; - // private MyScrollView sv_content; private FrameLayout fl_fragment_activity; private RatioLayout rl_recommend_activity2; - // private TextView tv_recommend_goods_hint; private RecyclerView rv_recommend_goods, rv_special_offer; private View v_divider; private FlowLayout flow_hot; - private RatioLayout rl_top_banner; ScrollView sv_hot; private View bottom; private ImageView iv_loading, iv_hot_img; private TextView tv_loading; - ViewPager vp_banner, vp_recommend_activity2; - private LinePageIndicator indicator_recommend; + com.lzj.gallery.library.views.BannerViewPager vp_banner; + ViewPager vp_recommend_activity2; private LinearLayout ll_no_net, ll_no_data, ll_request_failture; private List<HomeBanner> mBanners = new ArrayList<>(); @@ -120,9 +122,8 @@ private List<String> lList = new ArrayList<>(); private List<String> lList2 = new ArrayList<>(); - private RecommendTopAdapter bannerAdapter;//banner Adapter private RecommendActivityAdapter activityAdapter; - private HotCategoryAdapter specialAdapter2; + private RecommendCircleSpecialAdapter specialAdapter2; private RecommendGoodsAdapter goodsAdapter;//绮鹃�夊晢鍝� Adapter private LimitTimeBuyAdapter limitTimeBuyAdapter, jinbiExchangeAdapter; private DiskLruCache cache; @@ -201,13 +202,47 @@ int visibilyNum = -1; + + RecyclerView.ItemDecoration circleSpecialItemDecoration = new RecyclerView.ItemDecoration() { + @Override + public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { + super.onDraw(c, parent, state); + } + + @Override + public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) { + super.onDrawOver(c, parent, state); + } + + @Override + public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { + super.getItemOffsets(outRect, view, parent, state); + int index = parent.getChildAdapterPosition(view); + int total = parent.getAdapter().getItemCount(); + 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 = DimenUtils.dipToPixels(space, view.getContext()); + } + } + }; + private void init(View contentView) { rv_recommend_goods = contentView.findViewById(R.id.rv_recommend_goods); rl_first_page = contentView.findViewById(R.id.rl_first_page); iv_slid_top = contentView.findViewById(R.id.iv_slid_top); final View top = LayoutInflater.from(rv_recommend_goods.getContext()) .inflate(R.layout.item_recommend_top, null); - rl_top_banner = top.findViewById(R.id.rl_top_banner); + top.setBackground(HomeUIUtil.getHomeTopBg(getContext())); ll_fragment_activity = top.findViewById(R.id.ll_fragment_activity); ll_special_offer = top.findViewById(R.id.ll_special_offer); ll_limit_time_buy = top.findViewById(R.id.ll_limit_time_buy); @@ -215,13 +250,11 @@ fl_fragment_activity = top.findViewById(R.id.fl_fragment_activity); rl_recommend_activity2 = top.findViewById(R.id.rl_recommend_activity2); iv_activity_bg = top.findViewById(R.id.iv_activity_bg); - vp_banner = top.findViewById(R.id.vp_recommend); - indicator_recommend = top.findViewById(R.id.indicator_recommend); + vp_banner = top.findViewById(R.id.vp_banner); rv_special_offer = top.findViewById(R.id.rv_special_offer); flow_hot = top.findViewById(R.id.flow_hot); iv_input = top.findViewById(R.id.iv_input); vp_recommend_activity2 = top.findViewById(R.id.vp_recommend_activity2); -// tv_recommend_goods_hint = top.findViewById(R.id.tv_recommend_goods_hint); v_divider = top.findViewById(R.id.v_divider); tv_hour_1 = top.findViewById(R.id.tv_hour_1); tv_hour_2 = top.findViewById(R.id.tv_hour_2); @@ -293,7 +326,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(); } @@ -324,21 +357,22 @@ //璁剧疆鍒楄〃鍙互姘村钩婊戝姩锛屼袱琛� GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 2, GridLayoutManager.HORIZONTAL, false); -// mRecyclerView = new CustomeRecyclerView(this); rv_special_offer.setLayoutManager(layoutManager); - specialAdapter2 = new HotCategoryAdapter(getActivity(), circleSpecials); + specialAdapter2 = new RecommendCircleSpecialAdapter(getActivity(), circleSpecials); rv_special_offer.setAdapter(specialAdapter2); seekBar = top.findViewById(R.id.slide_indicator_point); seekBar.setPadding(0, 0, 0, 0); seekBar.setThumbOffset(0); - seekBar.setVisibility(View.GONE); +// seekBar.setVisibility(View.GONE); + + rv_special_offer.addItemDecoration(circleSpecialItemDecoration); rv_special_offer.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); -// //鏄剧ず鍖哄煙鐨勯珮搴︺�� +// //鏄剧ず鍖哄煙鐨勫銆� int extent = rv_special_offer.computeHorizontalScrollExtent(); //鏁翠綋鐨勯珮搴︼紝娉ㄦ剰鏄暣浣擄紝鍖呮嫭鍦ㄦ樉绀哄尯鍩熶箣澶栫殑銆� int range = rv_special_offer.computeHorizontalScrollRange(); @@ -383,19 +417,49 @@ } }); - vp_banner.setCurrentItem(0, true); vp_recommend_activity2.setCurrentItem(0, true); - bannerAdapter = new RecommendTopAdapter(mBanners, getActivity(), false); - vp_banner.setAdapter(bannerAdapter); activityAdapter = new RecommendActivityAdapter(mBanners2, getActivity()); vp_recommend_activity2.setAdapter(activityAdapter); rv_recommend_goods.setLayoutManager(new LinearLayoutManager(getContext())); - goodsAdapter = new RecommendGoodsAdapter(this, mList, "jingxuan"); + goodsAdapter = new RecommendGoodsAdapter(getContext(), mList, "jingxuan"); rv_recommend_goods.setAdapter(goodsAdapter); goodsAdapter.addFooterView(bottom); goodsAdapter.addHeaderView(top); initTimeHandle(); + setBannerData(); } + + + private void setBannerData() { + + List<String> urlList = new ArrayList<>(); + for (HomeBanner ad : mBanners) + urlList.add(ad.getSrc()); + if (urlList.size() > 0) { + if (!vp_banner.hasAdapter()) { + vp_banner.initBanner(urlList, false, 0.4375f)//寮�鍚�3D鐢诲粖鏁堟灉 + .addPageMargin(10, 10)//鍙傛暟1page涔嬮棿鐨勯棿璺�,鍙傛暟2涓棿item璺濈杈圭晫鐨勯棿璺� + .addStartTimer(3)//鑷姩杞挱3绉掗棿闅� + .addPointBottom(0)//搴曢儴闂磋窛 + .addPoint(5, R.drawable.shape_banner_indicator_highlight, R.drawable.shape_banner_indicator) + .addDefaultImg(R.drawable.shape_banner_default) + .addRoundCorners(DimenUtils.dip2px(getContext(), 10))//鍦嗚 + .finishConfig()//杩欏彞蹇呴』鍔� + .addBannerListener(new BannerViewPager.OnClickBannerListener() { + @Override + public void onBannerClick(int position) { + if (position >= mBanners.size()) + return; + JumpActivityUtil.jumpPage(getActivity(), mBanners.get(position).getJumpDetail(), mBanners.get(position).getParams()); + } + }); + } else { + vp_banner.notifyDataSetChanged(); + } + } + + } + private void addHot(final RecommendHot recommendHot) { if (recommendHot == null) { @@ -609,22 +673,9 @@ if (mBanners.size() > 0) { mBanners.clear(); } - float width = SystemCommon.getScreenWidth(getContext()); - indicator_recommend.setLineWidth((width - (DimenUtils.dip2px(getContext(), 30))) / list1.size()); - indicator_recommend.setGapWidth(0); - indicator_recommend.setSelectedColor(getResources().getColor(R.color.white)); - indicator_recommend.setUnselectedColor(getResources().getColor(R.color.transport_white3)); - indicator_recommend.setStrokeWidth(DimenUtils.dip2px(getContext(), 2)); - - if (list1 == null || list1.size() == 0) { - rl_top_banner.setVisibility(View.GONE); - } else { - rl_top_banner.setVisibility(View.VISIBLE); - } - mBanners.clear(); mBanners.addAll(list1); - bannerAdapter.notifyDataSetChanged(); + setBannerData(); } } catch (Exception e) { e.printStackTrace(); @@ -650,13 +701,7 @@ circleSpecials.addAll(list2); specialAdapter2.notifyDataSetChanged(); - if (circleSpecials.size() > 10) { - GradientDrawable gradientDrawable = (GradientDrawable) seekBar.getThumb(); - //鏍规嵁鍒楄〃鐨勪釜鏁帮紝鍔ㄦ�佽缃父鏍囩殑澶у皬锛岃缃父鏍囩殑鏃跺�欙紝progress杩涘害鐨勯鑹茶缃负鍜宻eekbar鐨勯鑹茶缃殑涓�鏍风殑锛屾墍浠ュ氨涓嶆樉绀鸿繘搴︿簡銆� - gradientDrawable.setSize(DimenUtils.dip2px(getContext(), 50) * 5 / (circleSpecials.size() / 2) - , DimenUtils.dip2px(getContext(), 4)); - } -// seekBar.setVisibility(mSpecial2s.size() <= 10 ? View.GONE : View.VISIBLE); + initSeekBar(); if (list2 == null || list2.size() == 0) { rv_special_offer.setVisibility(View.GONE); @@ -700,7 +745,7 @@ } else { fl_fragment_activity.setVisibility(View.VISIBLE); } - showActivity1(list3, url); + showBigActivity(list3, url); } } @@ -779,27 +824,16 @@ public void onResume() { super.onResume(); mChangeHelper.registerReceiver(); - indicator_recommend.setViewPager(vp_banner); - vp_banner.postDelayed(mAutoScroller, 2000); vp_recommend_activity2.postDelayed(mAutoScroller2, 2000); sv_hot.postDelayed(mAutoScroller3, 2000); - scanSpecial(System.currentTimeMillis()); } private void scanSpecial(Long curTime) { - long stayTime1 = curTime - bannerAdapter.clickTime; long stayTime2 = curTime - specialAdapter2.clickTime; long stayTime3 = curTime - activityAdapter.clickTime; long stayTime4 = curTime - clickTime4; - if (bannerAdapter.clickTime > 0 && stayTime1 > 15 * 1000) { - PushEventData info = new PushEventData(); - info.setId(bannerAdapter.clickId); - Gson gson = new GsonBuilder().serializeNulls().create(); - String data = gson.toJson(info); - bannerAdapter.clickTime = 0; - bannerAdapter.clickId = ""; - } + if (specialAdapter2.clickTime > 0 && stayTime2 > 15 * 1000) { PushEventData info = new PushEventData(); info.setId(specialAdapter2.clickId); @@ -825,19 +859,6 @@ clickId4 = ""; } } - - private Runnable mAutoScroller = new Runnable() { - - @Override - public void run() { - PagerAdapter adapter = vp_banner.getAdapter(); - if (adapter != null && adapter.getCount() != 0) { - vp_banner.setCurrentItem((vp_banner.getCurrentItem() + 1) - % adapter.getCount(), true); - } - vp_banner.postDelayed(this, 5000); - } - }; private Runnable mAutoScroller2 = new Runnable() { @@ -878,9 +899,18 @@ public void onPause() { super.onPause(); mChangeHelper.unregisterReceiver(); - vp_banner.removeCallbacks(mAutoScroller); vp_recommend_activity2.removeCallbacks(mAutoScroller2); sv_hot.removeCallbacks(mAutoScroller3); + } + + private void initSeekBar(){ + seekBar.setVisibility(circleSpecials.size() <= 8 ? View.GONE : View.VISIBLE); + if (circleSpecials.size() > 8) { + GradientDrawable gradientDrawable = (GradientDrawable) seekBar.getThumb(); + //鏍规嵁鍒楄〃鐨勪釜鏁帮紝鍔ㄦ�佽缃父鏍囩殑澶у皬锛岃缃父鏍囩殑鏃跺�欙紝progress杩涘害鐨勯鑹茶缃负鍜宻eekbar鐨勯鑹茶缃殑涓�鏍风殑锛屾墍浠ュ氨涓嶆樉绀鸿繘搴︿簡銆� + gradientDrawable.setSize(DimenUtils.dip2px(getContext(), 50) * 4 / (circleSpecials.size() / 2) + , DimenUtils.dip2px(getContext(), 4)); + } } @@ -893,8 +923,7 @@ && mList.size() == 0) { pd.show(); } - String uid = getContext().getSharedPreferences("user", MODE_PRIVATE).getString("uid", ""); - ShoppingApi.getRecommendIndex(vp_banner.getContext(), uid, new BasicTextHttpResponseHandler() { + ShoppingApi.getRecommendIndex(vp_banner.getContext(), UserUtil.getUid(ShoppingApplication.application), new BasicTextHttpResponseHandler() { @Override public void onFinish() { super.onFinish(); @@ -917,20 +946,8 @@ if (mBanners.size() > 0) { mBanners.clear(); } - float width = SystemCommon.getScreenWidth(getContext()); - indicator_recommend.setLineWidth((width - (DimenUtils.dip2px(getContext(), 30))) / list1.size()); - indicator_recommend.setGapWidth(0); - indicator_recommend.setSelectedColor(getResources().getColor(R.color.white)); - indicator_recommend.setUnselectedColor(getResources().getColor(R.color.transport_white3)); - indicator_recommend.setStrokeWidth(DimenUtils.dip2px(getContext(), 2)); - mBanners.addAll(list1); - bannerAdapter.notifyDataSetChanged(); - if (list1 == null || list1.size() == 0) { - rl_top_banner.setVisibility(View.GONE); - } else { - rl_top_banner.setVisibility(View.VISIBLE); - } + setBannerData(); DiskLruCache.Editor editor0 = cache .edit(getKey("BannerAd")); @@ -948,13 +965,7 @@ } circleSpecials.addAll(list2); specialAdapter2.notifyDataSetChanged(); -// seekBar.setVisibility(mSpecial2s.size() <= 10 ? View.GONE : View.VISIBLE); - if (circleSpecials.size() > 10) { - GradientDrawable gradientDrawable = (GradientDrawable) seekBar.getThumb(); - //鏍规嵁鍒楄〃鐨勪釜鏁帮紝鍔ㄦ�佽缃父鏍囩殑澶у皬锛岃缃父鏍囩殑鏃跺�欙紝progress杩涘害鐨勯鑹茶缃负鍜宻eekbar鐨勯鑹茶缃殑涓�鏍风殑锛屾墍浠ュ氨涓嶆樉绀鸿繘搴︿簡銆� - gradientDrawable.setSize(DimenUtils.dip2px(getContext(), 50) * 5 / (circleSpecials.size() / 2) - , DimenUtils.dip2px(getContext(), 4)); - } + initSeekBar(); if (list2 == null || list2.size() == 0) { rv_special_offer.setVisibility(View.GONE); } else { @@ -979,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 { @@ -1018,6 +1029,7 @@ .optJSONArray("list").toString(), new TypeToken<List<SpecialOffer2>>() { }.getType()); + list5.clear(); showActivity2(list5); if (list5 == null || list5.size() == 0) { @@ -1196,7 +1208,6 @@ // goodsAdapter.notifyItemRangeChanged(goodsAdapter.getItemCount(), list.size());//鍊掑簭鎵归噺鍒锋柊鍒楄〃 count = jsonObject.optJSONObject("data").optInt("count"); // tv_recommend_goods_hint.setVisibility(mList.size() > 0 ? View.VISIBLE : View.GONE); - v_divider.setVisibility(mList.size() > 0 ? View.VISIBLE : View.GONE); if (mList.size() == count) { bottom.setVisibility(View.VISIBLE); @@ -1264,44 +1275,57 @@ }); } - /* - 娲诲姩涓撻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; + int screenWidth = ScreenUtils.getScreenWidth(getContext()); + ViewGroup.MarginLayoutParams p1 = (ViewGroup.MarginLayoutParams) ((View) fl_fragment_activity.getParent()).getLayoutParams(); + + float bigratio = 0.35f; + float smallratio = 0.4571f; + int rowSpace = DimenUtils.dip2px(getContext(), 10); + int columnSpace = DimenUtils.dip2px(getContext(), 5); + int bigImageWidth = screenWidth - p1.leftMargin - p1.rightMargin; + int bigImageHeight = (int) (bigImageWidth * bigratio); + int smallImageWidth = (bigImageWidth - columnSpace) / 2; + int smallImageHeight = (int) (smallImageWidth * smallratio); + + + int actTotalHeight = bigImageHeight + rowSpace; for (int i = 0; i < mList.size(); i++) { if (i > 0 && i % 2 == 0) { - actTotalHeight += ((screenWidth / 2 - DimenUtils.dip2px(getContext(), 15)) - * 16 / 35 + DimenUtils.dip2px(getContext(), 10)); + actTotalHeight += smallImageHeight + rowSpace; } } - 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); + FrameLayout.LayoutParams params0 = new FrameLayout.LayoutParams(bigImageWidth, FrameLayout.LayoutParams.WRAP_CONTENT); + 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); if (ll_fragment_activity.getChildCount() > 0) { ll_fragment_activity.removeAllViews(); } - 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); +// 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); for (int i = 0; i < mList.size(); i++) { if (i == 0) { final SpecialOffer2 info = mList.get(i); ImageView iv = new ImageView(getContext()); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( - (int) (screenWidth - DimenUtils.dip2px(getContext(), 20)), - (int) (screenWidth - DimenUtils.dip2px(getContext(), 20)) * 7 / 20); + bigImageWidth, + bigImageHeight); 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() { @@ -1315,6 +1339,9 @@ } else { if (i % 2 == 1) { LinearLayout ll_img = new LinearLayout(getContext()); + LinearLayout.LayoutParams p2 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); + p2.topMargin = rowSpace; + ll_img.setLayoutParams(p2); ll_img.setOrientation(LinearLayout.HORIZONTAL); for (int j = i; j < (i + 2); j++) { if (j >= mList.size()) { @@ -1322,15 +1349,13 @@ } ImageView iv = new ImageView(getContext()); - LinearLayout.LayoutParams params = new LinearLayout.LayoutParams((int) screenWidth / 2 - - (DimenUtils.dip2px(getContext(), 15)), (int) ((screenWidth / 2 - - (DimenUtils.dip2px(getContext(), 15))) * 16 / 35)); - params.topMargin = DimenUtils.dip2px(getContext(), 10); - if (j % 2 == 1) { - params.rightMargin = DimenUtils.dip2px(getContext(), 3); - } else { - params.leftMargin = DimenUtils.dip2px(getContext(), 3); - } + LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(smallImageWidth, smallImageHeight); + +// if (j % 2 == 1) { +// params.rightMargin = columnSpace / 2; +// } else { +// params.leftMargin = columnSpace / 2; +// } iv.setLayoutParams(params); Glide.with(getContext()).load(mList.get(j).getPicture()).into(iv); final int k = j; @@ -1342,6 +1367,13 @@ } }); ll_img.addView(iv); + if (j % 2 == 1) { + View view = new View(getContext()); + LinearLayout.LayoutParams p3 = new LinearLayout.LayoutParams(0, 1); + p3.weight = 1; + view.setLayoutParams(p3); + ll_img.addView(view); + } } ll_fragment_activity.addView(ll_img); } -- Gitblit v1.8.0