| | |
| | | */ |
| | | |
| | | 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; |
| | |
| | | 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()); |
| | | } |
| | | } |
| | | }; |
| | |
| | | if (last == total - 1 && mList.size() < count && isLoad) { |
| | | page++; |
| | | isLoad = false; |
| | | tv_loading.setText("正在加载更多数据"); |
| | | tv_loading.setText(getResources().getString(R.string.loading_more_text)); |
| | | iv_loading.setVisibility(View.VISIBLE); |
| | | guessLikeByDevice(); |
| | | } |
| | |
| | | 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); |
| | |
| | | } else { |
| | | fl_fragment_activity.setVisibility(View.VISIBLE); |
| | | } |
| | | showActivity1(list3, url); |
| | | showBigActivity(list3, url); |
| | | } |
| | | |
| | | } |
| | |
| | | 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 { |
| | |
| | | }); |
| | | } |
| | | |
| | | /* |
| | | 活动专题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; |
| | |
| | | } |
| | | 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); |
| | |
| | | |
| | | 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) { |
| | |
| | | (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() { |