| | |
| | | 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; |
| | |
| | | @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(); |
| | |
| | | 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(circleSpecials.size() <= 8 ? View.GONE : View.VISIBLE); |
| | | initSeekBar(); |
| | | |
| | | if (list2 == null || list2.size() == 0) { |
| | | rv_special_offer.setVisibility(View.GONE); |
| | |
| | | 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进度的颜色设置为和seekbar的颜色设置的一样的,所以就不显示进度了。 |
| | | gradientDrawable.setSize(DimenUtils.dip2px(getContext(), 50) * 4 / (circleSpecials.size() / 2) |
| | | , DimenUtils.dip2px(getContext(), 4)); |
| | | } |
| | | } |
| | | |
| | | |
| | | private void setGoodsIndex() { |
| | | if (pd == null) { |
| | |
| | | } |
| | | circleSpecials.addAll(list2); |
| | | specialAdapter2.notifyDataSetChanged(); |
| | | seekBar.setVisibility(circleSpecials.size() <= 8 ? 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 { |
| | |
| | | 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 smallImageWidth; |
| | | 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); |
| | | |
| | | float actTotalHeight = (screenWidth - DimenUtils.dip2px(getContext(), 20)) * 7 / 20; |
| | | |
| | | 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); |
| | | } |