| | |
| | | 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 com.tejia.lijin.app.entity.RecommendHot; |
| | | import com.tejia.lijin.app.entity.SpecialOffer2; |
| | | import com.tejia.lijin.app.entity.TaoBaoGoodsBrief; |
| | | import com.tejia.lijin.app.entity.hongbao.LijinSendInfo; |
| | | import com.tejia.lijin.app.ui.dialog.RecommendHbDialog; |
| | | import com.tejia.lijin.app.ui.dialog.ShapeLoadingDialog; |
| | | import com.tejia.lijin.app.ui.invite.ShareBrowserActivity; |
| | | import com.tejia.lijin.app.ui.timeLimitedSpike.TimeLimitedSpikeActivity; |
| | |
| | | import com.tejia.lijin.app.util.user.UserUtil; |
| | | import com.wpc.library.RetainViewFragment; |
| | | import com.wpc.library.content.ConnectivityChangeHelper; |
| | | import com.wpc.library.recyclerviewhelper.DividerItemDecoration; |
| | | 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; |
| | |
| | | private List<SpecialOffer2> mSpecial3s = new ArrayList<>(); |
| | | private List<HomeBanner> mBanners2 = new ArrayList<>(); |
| | | private List<TaoBaoGoodsBrief> mList = new ArrayList<>(); |
| | | private List<TaoBaoGoodsBrief> mHotGoodsList = new ArrayList<>(); |
| | | private List<String> lList = new ArrayList<>(); |
| | | private List<String> lList2 = new ArrayList<>(); |
| | | |
| | |
| | | private boolean isCache = false; |
| | | private boolean isLoad = false; |
| | | ShapeLoadingDialog pd = null; |
| | | |
| | | //热门商品 |
| | | private LinearLayout ll_hot_goods; |
| | | private RecyclerView rv_hot_goods; |
| | | private TextView tv_hot_goods_more; |
| | | private RecommendHotGoodsAdapter mRecommendHotGoodsAdapter; |
| | | |
| | | |
| | | TextView |
| | |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | init(contentView); |
| | | initCacheData(); |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | } else |
| | | outRect.bottom = 0; |
| | | |
| | | outRect.left = 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); |
| | | private View initHeader() { |
| | | final View top = LayoutInflater.from(rv_recommend_goods.getContext()) |
| | | .inflate(R.layout.item_recommend_top, null); |
| | | top.setBackground(HomeUIUtil.getHomeTopBg("#FF227B", "#FF2A3E")); |
| | | |
| | | |
| | | 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); |
| | |
| | | sv_hot = top.findViewById(R.id.sv_hot); |
| | | iv_hot_img = top.findViewById(R.id.iv_hot_img); |
| | | |
| | | //小黄条 |
| | | tv_notice_content = top.findViewById(R.id.tv_notice_content); |
| | | ll_notice = top.findViewById(R.id.ll_notice); |
| | | iv_close = top.findViewById(R.id.iv_close); |
| | | |
| | | seekBar = top.findViewById(R.id.slide_indicator_point); |
| | | seekBar.setPadding(0, 0, 0, 0); |
| | | seekBar.setThumbOffset(0); |
| | | |
| | | ll_hot_goods = top.findViewById(R.id.ll_hot_goods); |
| | | rv_hot_goods = top.findViewById(R.id.rv_hot_goods); |
| | | tv_hot_goods_more = top.findViewById(R.id.tv_hot_goods_more); |
| | | |
| | | rv_hot_goods.addItemDecoration(new RecyclerView.ItemDecoration() { |
| | | @Override |
| | | public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { |
| | | outRect.right = DimenUtils.dip2px(getContext(), 10); |
| | | int position = parent.getChildAdapterPosition(view); |
| | | if (position == mHotGoodsList.size() - 1) { |
| | | outRect.right = 0; |
| | | } |
| | | // super.getItemOffsets(outRect, view, parent, state); |
| | | } |
| | | }); |
| | | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext()); |
| | | linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); |
| | | rv_hot_goods.setLayoutManager(linearLayoutManager); |
| | | return top; |
| | | } |
| | | |
| | | |
| | | 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); |
| | | |
| | | View top = initHeader(); |
| | | |
| | | iv_hot_img.setOnClickListener(this); |
| | | |
| | | ll_no_net = contentView.findViewById(R.id.ll_no_net); |
| | | ll_no_data = contentView.findViewById(R.id.ll_no_data); |
| | | ll_request_failture = contentView.findViewById(R.id.ll_request_failture); |
| | | |
| | | |
| | | contentView.findViewById(R.id.tv_net_setting).setOnClickListener(this); |
| | | contentView.findViewById(R.id.tv_refresh).setOnClickListener(this); |
| | | iv_slid_top.setOnClickListener(this); |
| | | ll_limit_time_buy.setOnClickListener(this); |
| | | ll_jinbi_exchange_buy.setOnClickListener(this); |
| | | |
| | | |
| | | mChangeHelper = new ConnectivityChangeHelper(ll_no_data.getContext(), |
| | | new ConnectivityChangeHelper.OnConnectivityChangeListener() { |
| | |
| | | } |
| | | }); |
| | | |
| | | //小黄条 |
| | | tv_notice_content = top.findViewById(R.id.tv_notice_content); |
| | | ll_notice = top.findViewById(R.id.ll_notice); |
| | | iv_close = top.findViewById(R.id.iv_close); |
| | | |
| | | getAppPageNotification(); |
| | | |
| | | //设置列表可以水平滑动,两行 |
| | |
| | | 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); |
| | | |
| | |
| | | @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(); |
| | |
| | | goodsAdapter.addHeaderView(top); |
| | | initTimeHandle(); |
| | | setBannerData(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 初始化热门商品 |
| | | */ |
| | | private void setHotGoods() { |
| | | for (TaoBaoGoodsBrief goodsBrief : mHotGoodsList) { |
| | | goodsBrief.setHasCoupon(false); |
| | | } |
| | | if (mRecommendHotGoodsAdapter == null) { |
| | | mRecommendHotGoodsAdapter = new RecommendHotGoodsAdapter(getContext(), mHotGoodsList, "jingxuan"); |
| | | rv_hot_goods.setAdapter(mRecommendHotGoodsAdapter); |
| | | } else { |
| | | rv_hot_goods.getAdapter().notifyDataSetChanged(); |
| | | } |
| | | if (mHotGoodsList.size() == 0) { |
| | | ll_hot_goods.setVisibility(View.GONE); |
| | | } else { |
| | | ll_hot_goods.setVisibility(View.VISIBLE); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | circleSpecials.addAll(list2); |
| | | specialAdapter2.notifyDataSetChanged(); |
| | | |
| | | if (circleSpecials.size() > 10) { |
| | | GradientDrawable gradientDrawable = (GradientDrawable) seekBar.getThumb(); |
| | | //根据列表的个数,动态设置游标的大小,设置游标的时候,progress进度的颜色设置为和seekbar的颜色设置的一样的,所以就不显示进度了。 |
| | | 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); |
| | |
| | | } |
| | | } |
| | | } |
| | | { |
| | | //今日爆款 |
| | | |
| | | DiskLruCache.Snapshot snapshot = null; |
| | | try { |
| | | snapshot = cache.get(getKey("hotSales")); |
| | | if (snapshot != null) { |
| | | final Gson gson = new GsonBuilder().serializeNulls().create(); |
| | | final JSONObject hotSales = new JSONObject(snapshot.getString(0)); |
| | | List<TaoBaoGoodsBrief> list = gson.fromJson(hotSales. |
| | | optJSONArray("goodsList").toString(), new TypeToken<List<TaoBaoGoodsBrief>>() { |
| | | }.getType()); |
| | | mHotGoodsList.clear(); |
| | | mHotGoodsList.addAll(list); |
| | | tv_hot_goods_more.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | JumpDetail jumpDetail = gson.fromJson(hotSales.optJSONObject("jumpDetail").toString(), JumpDetail.class); |
| | | com.alibaba.fastjson.JSONObject params = com.alibaba.fastjson.JSONObject.parseObject(hotSales.optJSONObject("params").toString()); |
| | | JumpActivityUtil.jumpPage(getActivity(), jumpDetail, params); |
| | | } |
| | | }); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } catch (JSONException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | if (snapshot != null) { |
| | | snapshot.close(); |
| | | } |
| | | } |
| | | setHotGoods(); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | sv_hot.removeCallbacks(mAutoScroller3); |
| | | } |
| | | |
| | | private void initSeekBar() { |
| | | seekBar.setVisibility(circleSpecials.size() <= 10 ? View.GONE : View.VISIBLE); |
| | | if (circleSpecials.size() > 10) { |
| | | GradientDrawable gradientDrawable = (GradientDrawable) seekBar.getThumb(); |
| | | //根据列表的个数,动态设置游标的大小,设置游标的时候,progress进度的颜色设置为和seekbar的颜色设置的一样的,所以就不显示进度了。 |
| | | gradientDrawable.setSize(DimenUtils.dip2px(getContext(), 50) * 5 / (circleSpecials.size() / 2) |
| | | , DimenUtils.dip2px(getContext(), 4)); |
| | | } |
| | | } |
| | | |
| | | |
| | | private void setGoodsIndex() { |
| | | if (pd == null) { |
| | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | if (jsonObject.optString("code").equalsIgnoreCase("0")) { |
| | | JSONObject data = jsonObject.optJSONObject("data"); |
| | | isCache = false; |
| | | //顶部banner |
| | | Gson gson = new GsonBuilder().serializeNulls().create(); |
| | | List<HomeBanner> list1 = gson.fromJson(jsonObject.optJSONObject("data") |
| | | final Gson gson = new GsonBuilder().serializeNulls().create(); |
| | | List<HomeBanner> list1 = gson.fromJson(data |
| | | .optJSONArray("topPicList").toString(), |
| | | new TypeToken<List<HomeBanner>>() { |
| | | }.getType()); |
| | |
| | | |
| | | DiskLruCache.Editor editor0 = cache |
| | | .edit(getKey("BannerAd")); |
| | | editor0.set(0, jsonObject.optJSONObject("data").optJSONArray("topPicList").toString()); |
| | | editor0.set(0, data.optJSONArray("topPicList").toString()); |
| | | editor0.commit(); |
| | | |
| | | //圆形专题 |
| | | List<SpecialOffer2> list2 = gson.fromJson( |
| | | jsonObject.optJSONObject("data").optJSONObject("arcArea") |
| | | data.optJSONObject("arcArea") |
| | | .optJSONArray("list").toString(), |
| | | new TypeToken<List<SpecialOffer2>>() { |
| | | }.getType()); |
| | |
| | | } |
| | | circleSpecials.addAll(list2); |
| | | specialAdapter2.notifyDataSetChanged(); |
| | | // seekBar.setVisibility(mSpecial2s.size() <= 10 ? View.GONE : View.VISIBLE); |
| | | if (circleSpecials.size() > 10) { |
| | | GradientDrawable gradientDrawable = (GradientDrawable) seekBar.getThumb(); |
| | | //根据列表的个数,动态设置游标的大小,设置游标的时候,progress进度的颜色设置为和seekbar的颜色设置的一样的,所以就不显示进度了。 |
| | | 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 { |
| | |
| | | |
| | | DiskLruCache.Editor editor1 = cache |
| | | .edit(getKey("arcArea")); |
| | | editor1.set(0, jsonObject.optJSONObject("data").optJSONObject("arcArea") |
| | | editor1.set(0, data.optJSONObject("arcArea") |
| | | .optJSONArray("list").toString()); |
| | | editor1.commit(); |
| | | //活动专题3 |
| | | List<SpecialOffer2> list3 = gson.fromJson( |
| | | jsonObject.optJSONObject("data").optJSONObject("activityArea") |
| | | data.optJSONObject("activityArea") |
| | | .optJSONArray("list").toString(), |
| | | new TypeToken<List<SpecialOffer2>>() { |
| | | }.getType()); |
| | | if (mSpecial3s.size() > 0) { |
| | | mSpecial3s.clear(); |
| | | } |
| | | String url = jsonObject.optJSONObject("data") |
| | | String url = data |
| | | .optJSONObject("activityArea").optString("bottomPicture"); |
| | | |
| | | showBigActivity(list3, url); |
| | |
| | | } |
| | | DiskLruCache.Editor editor2 = cache |
| | | .edit(getKey("activityArea")); |
| | | editor2.set(0, jsonObject.optJSONObject("data") |
| | | editor2.set(0, data |
| | | .optJSONObject("activityArea").toString()); |
| | | editor2.commit(); |
| | | //活动专题4 |
| | | List<HomeBanner> list4 = gson.fromJson( |
| | | jsonObject.optJSONObject("data") |
| | | data |
| | | .optJSONArray("invitePicList").toString(), |
| | | new TypeToken<List<HomeBanner>>() { |
| | | }.getType()); |
| | |
| | | } |
| | | DiskLruCache.Editor editor3 = cache |
| | | .edit(getKey("invitePicList")); |
| | | editor3.set(0, jsonObject.optJSONObject("data") |
| | | editor3.set(0, data |
| | | .optJSONArray("invitePicList").toString()); |
| | | editor3.commit(); |
| | | //活动专题5 |
| | | List<SpecialOffer2> list5 = gson.fromJson( |
| | | jsonObject.optJSONObject("data").optJSONObject("blockArea") |
| | | data.optJSONObject("blockArea") |
| | | .optJSONArray("list").toString(), |
| | | new TypeToken<List<SpecialOffer2>>() { |
| | | }.getType()); |
| | | list5.clear(); |
| | | showActivity2(list5); |
| | | |
| | | if (list5 == null || list5.size() == 0) { |
| | |
| | | } |
| | | DiskLruCache.Editor editor4 = cache |
| | | .edit(getKey("blockArea")); |
| | | editor4.set(0, jsonObject.optJSONObject("data").optJSONObject("blockArea") |
| | | editor4.set(0, data.optJSONObject("blockArea") |
| | | .optJSONArray("list").toString()); |
| | | editor4.commit(); |
| | | |
| | | |
| | | //今日爆款 |
| | | final JSONObject hotSales = data.optJSONObject("hotSales"); |
| | | if (hotSales != null) { |
| | | List<TaoBaoGoodsBrief> list = gson.fromJson(hotSales. |
| | | optJSONArray("goodsList").toString(), new TypeToken<List<TaoBaoGoodsBrief>>() { |
| | | }.getType()); |
| | | mHotGoodsList.clear(); |
| | | mHotGoodsList.addAll(list); |
| | | tv_hot_goods_more.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | JumpDetail jumpDetail = gson.fromJson(hotSales.optJSONObject("jumpDetail").toString(), JumpDetail.class); |
| | | com.alibaba.fastjson.JSONObject params = com.alibaba.fastjson.JSONObject.parseObject(hotSales.optJSONObject("params").toString()); |
| | | JumpActivityUtil.jumpPage(getActivity(), jumpDetail, params); |
| | | } |
| | | }); |
| | | |
| | | DiskLruCache.Editor editorHotSales = cache |
| | | .edit(getKey("hotSales")); |
| | | editorHotSales.set(0, hotSales.toString()); |
| | | editorHotSales.commit(); |
| | | } |
| | | setHotGoods(); |
| | | |
| | | |
| | | //推荐热点 |
| | | // RecommendHot recommendHot = gson.fromJson(jsonObject.optJSONObject("data") |
| | |
| | | }); |
| | | } |
| | | |
| | | |
| | | /* |
| | | *推荐商品 |
| | | */ |
| | |
| | | } |
| | | |
| | | mList.addAll(list); |
| | | |
| | | |
| | | goodsAdapter.setGoodsType(goodsType); |
| | | goodsAdapter.notifyDataSetChanged(); |
| | | if (isTop) { |
| | |
| | | // 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); |
| | |
| | | */ |
| | | 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); |
| | | 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))); |
| | | // 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++) { |
| | |
| | | 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.FIT_XY); |
| | |
| | | } 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()) { |
| | |
| | | } |
| | | |
| | | 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; |
| | |
| | | } |
| | | }); |
| | | 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); |
| | | } |