|
|
@@ -111,6 +111,7 @@ public class ActInvitation extends BaseActivity {
|
|
|
|
|
|
private List<PictureInvitationEntity> mPictureList = new ArrayList<>();
|
|
|
private List<View> viewArrayList = new ArrayList<>();
|
|
|
+ private SparseArray<BitmapFactory.Options> optionsList = new SparseArray<>();
|
|
|
|
|
|
@SuppressLint("ClickableViewAccessibility")
|
|
|
@Override
|
|
|
@@ -211,7 +212,7 @@ public class ActInvitation extends BaseActivity {
|
|
|
private void loadData() {
|
|
|
int size = 0;
|
|
|
for (final PictureInvitationEntity item : mPictureList) {
|
|
|
- View itemView = LayoutInflater.from(SheepApp.getInstance()).inflate(R.layout.item_image2, null);
|
|
|
+ final View itemView = LayoutInflater.from(SheepApp.getInstance()).inflate(R.layout.item_image2, null);
|
|
|
|
|
|
final View image_container = itemView.findViewById(R.id.image_container);
|
|
|
final ImageView image_full = itemView.findViewById(R.id.image_full);
|
|
|
@@ -236,12 +237,16 @@ public class ActInvitation extends BaseActivity {
|
|
|
|
|
|
// if(item.getPicture() != null)
|
|
|
// GlideImageLoader.downloadAndRoundedImage(name, item.getPicture(), image_full, getResources().getDimensionPixelSize(R.dimen.content_padding_8), listener);
|
|
|
+ final int index = size;
|
|
|
+ viewArrayList.add(itemView);
|
|
|
+ viewList.put(size, itemView);
|
|
|
GlideImageLoader.downLoadImage(name, item.getPicture(), new Action1<File>() {
|
|
|
@Override
|
|
|
public void call(File file) {
|
|
|
BitmapFactory.Options options = FileUtil.getImageOptions(file);
|
|
|
final int w = options.outWidth;
|
|
|
final int h = options.outHeight;
|
|
|
+ optionsList.put(index, options);
|
|
|
// int w = width;
|
|
|
// int h = width * options.outHeight / options.outWidth;
|
|
|
Glide.with(SheepApp.getInstance())
|
|
|
@@ -249,56 +254,7 @@ public class ActInvitation extends BaseActivity {
|
|
|
.listener(listener)
|
|
|
.apply(new RequestOptions().override(w, h).transform(new RoundedCorners(getResources().getDimensionPixelSize(R.dimen.content_padding_8))))
|
|
|
.into(image_full);
|
|
|
- viewPager.postDelayed(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- image_container.setVisibility(View.VISIBLE);
|
|
|
- int vWidth = viewPager.getWidth();
|
|
|
- int vHeight = viewPager.getHeight();
|
|
|
- float imgWidth = vWidth;
|
|
|
- float imgHeight = vHeight;
|
|
|
- int imgHeightPadding = 0;
|
|
|
- if(vHeight * 1.0F / vWidth > h * 1.0F / w){//图片上下有padding
|
|
|
- imgHeight = imgWidth * h / w;
|
|
|
- imgHeightPadding = (int) ((vHeight - imgHeight) / 2);
|
|
|
- } else {//图片左右有padding
|
|
|
- imgWidth = imgHeight * w / h;
|
|
|
- }
|
|
|
-
|
|
|
- float containerWidthRadius = 60 / 216F;
|
|
|
- float containerHeightRadius = 70 / 216F;
|
|
|
- float rqRadius = 53 / 216F;
|
|
|
- float tipRadius = 5 / 216F;
|
|
|
- float radius = 4 / 216F;
|
|
|
- float topRadius = 2 / 216F;
|
|
|
- float logoRadius = rqRadius * 16 / 68;
|
|
|
- GlideImageLoader.saveAndSetRqImage(image_bottom, item.getLink(), (int) (imgWidth * rqRadius));
|
|
|
- //重新设置logo的宽高
|
|
|
- ViewGroup.LayoutParams layoutParams = image_logo.getLayoutParams();
|
|
|
- layoutParams.width = (int) (imgWidth * logoRadius);
|
|
|
- layoutParams.height = (int) (imgWidth * logoRadius);
|
|
|
- image_logo.setLayoutParams(layoutParams);
|
|
|
- //重新设置二维码上部的距离
|
|
|
- ViewGroup.LayoutParams layoutParamsTop = image_bottom_top.getLayoutParams();
|
|
|
- layoutParamsTop.height = (int) (imgWidth * topRadius);
|
|
|
- image_bottom_top.setLayoutParams(layoutParamsTop);
|
|
|
- //重新设置《扫我开始赚钱》的高度
|
|
|
- ViewGroup.LayoutParams layoutParamsTip = image_tip.getLayoutParams();
|
|
|
- layoutParamsTip.height = (int) (imgWidth * (tipRadius + topRadius * 3 / 2));
|
|
|
- image_tip.setLayoutParams(layoutParamsTip);
|
|
|
- image_tip.setTextSize(imgWidth * tipRadius / G.DENSITY);
|
|
|
- //重新设置整个二维码外容器的高度
|
|
|
- RelativeLayout.LayoutParams layoutParamsContainer = (RelativeLayout.LayoutParams) image_container.getLayoutParams();
|
|
|
- layoutParamsContainer.width = (int) (imgWidth * containerWidthRadius);
|
|
|
- layoutParamsContainer.height = (int) (imgWidth * containerHeightRadius);
|
|
|
- layoutParamsContainer.bottomMargin = imgHeightPadding;
|
|
|
- image_container.setLayoutParams(layoutParamsContainer);
|
|
|
- Drawable bg = image_container.getBackground();
|
|
|
- if (bg instanceof GradientDrawable) {
|
|
|
- ((GradientDrawable) bg).setCornerRadius(imgWidth * radius);
|
|
|
- }
|
|
|
- }
|
|
|
- }, 50L);
|
|
|
+ updateLayoutParams(index, 500L);
|
|
|
}
|
|
|
});
|
|
|
//之前的方法实际上没有实现圆角效果
|
|
|
@@ -307,8 +263,6 @@ public class ActInvitation extends BaseActivity {
|
|
|
// .listener(listener)
|
|
|
// .apply(new RequestOptions().transform(new RoundedCorners((int) getResources().getDimension(R.dimen.content_padding_8))).fitCenter())
|
|
|
// .into(image_full);
|
|
|
- viewArrayList.add(itemView);
|
|
|
- viewList.put(size, itemView);
|
|
|
size++;
|
|
|
}
|
|
|
ArrayPagerAdapter adapter = new ArrayPagerAdapter(viewArrayList);
|
|
|
@@ -324,6 +278,7 @@ public class ActInvitation extends BaseActivity {
|
|
|
@Override
|
|
|
public void onPageSelected(int position) {
|
|
|
curPosition = position;
|
|
|
+ updateLayoutParams(position, 50L);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -335,6 +290,72 @@ public class ActInvitation extends BaseActivity {
|
|
|
viewPager.setCurrentItem((size - 1) / 2, false);
|
|
|
}
|
|
|
|
|
|
+ private void updateLayoutParams(int position, long time) {
|
|
|
+ BitmapFactory.Options options = optionsList.get(position);
|
|
|
+ if(options == null){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ View itemView = viewArrayList.get(position);
|
|
|
+ final PictureInvitationEntity item = mPictureList.get(position);
|
|
|
+ final int w = options.outWidth;
|
|
|
+ final int h = options.outHeight;
|
|
|
+ final View image_container = itemView.findViewById(R.id.image_container);
|
|
|
+ final View image_bottom_top = itemView.findViewById(R.id.image_bottom_top);
|
|
|
+ final ImageView image_bottom = itemView.findViewById(R.id.image_bottom);
|
|
|
+ final ImageView image_logo = itemView.findViewById(R.id.image_logo);
|
|
|
+ final TextView image_tip = itemView.findViewById(R.id.image_tip);
|
|
|
+ viewPager.postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ image_container.setVisibility(View.VISIBLE);
|
|
|
+ int vWidth = viewPager.getWidth();
|
|
|
+ int vHeight = viewPager.getHeight();
|
|
|
+ float imgWidth = vWidth;
|
|
|
+ float imgHeight = vHeight;
|
|
|
+ int imgHeightPadding = 0;
|
|
|
+ if(vHeight * 1.0F / vWidth > h * 1.0F / w){//图片上下有padding
|
|
|
+ imgHeight = imgWidth * h / w;
|
|
|
+ imgHeightPadding = (int) ((vHeight - imgHeight) / 2);
|
|
|
+ } else {//图片左右有padding
|
|
|
+ imgWidth = imgHeight * w / h;
|
|
|
+ }
|
|
|
+
|
|
|
+ float containerWidthRadius = 60 / 216F;
|
|
|
+ float containerHeightRadius = 70 / 216F;
|
|
|
+ float rqRadius = 53 / 216F;
|
|
|
+ float tipRadius = 5 / 216F;
|
|
|
+ float radius = 4 / 216F;
|
|
|
+ float topRadius = 2 / 216F;
|
|
|
+ float logoRadius = rqRadius * 16 / 68;
|
|
|
+ GlideImageLoader.saveAndSetRqImage(image_bottom, item.getLink(), (int) (imgWidth * rqRadius));
|
|
|
+ //重新设置logo的宽高
|
|
|
+ ViewGroup.LayoutParams layoutParams = image_logo.getLayoutParams();
|
|
|
+ layoutParams.width = (int) (imgWidth * logoRadius);
|
|
|
+ layoutParams.height = (int) (imgWidth * logoRadius);
|
|
|
+ image_logo.setLayoutParams(layoutParams);
|
|
|
+ //重新设置二维码上部的距离
|
|
|
+ ViewGroup.LayoutParams layoutParamsTop = image_bottom_top.getLayoutParams();
|
|
|
+ layoutParamsTop.height = (int) (imgWidth * topRadius);
|
|
|
+ image_bottom_top.setLayoutParams(layoutParamsTop);
|
|
|
+ //重新设置《扫我开始赚钱》的高度
|
|
|
+ ViewGroup.LayoutParams layoutParamsTip = image_tip.getLayoutParams();
|
|
|
+ layoutParamsTip.height = (int) (imgWidth * (tipRadius + topRadius * 3 / 2));
|
|
|
+ image_tip.setLayoutParams(layoutParamsTip);
|
|
|
+ image_tip.setTextSize(imgWidth * tipRadius / G.DENSITY);
|
|
|
+ //重新设置整个二维码外容器的高度
|
|
|
+ RelativeLayout.LayoutParams layoutParamsContainer = (RelativeLayout.LayoutParams) image_container.getLayoutParams();
|
|
|
+ layoutParamsContainer.width = (int) (imgWidth * containerWidthRadius);
|
|
|
+ layoutParamsContainer.height = (int) (imgWidth * containerHeightRadius);
|
|
|
+ layoutParamsContainer.bottomMargin = imgHeightPadding;
|
|
|
+ image_container.setLayoutParams(layoutParamsContainer);
|
|
|
+ Drawable bg = image_container.getBackground();
|
|
|
+ if (bg instanceof GradientDrawable) {
|
|
|
+ ((GradientDrawable) bg).setCornerRadius(imgWidth * radius);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, time);
|
|
|
+ }
|
|
|
+
|
|
|
private int curPosition = 0;
|
|
|
private SparseArray<View> viewList = new SparseArray<>();
|
|
|
|