|
|
@@ -3,6 +3,7 @@ package com.sheep.gamegroup.view.activity;
|
|
|
import android.annotation.SuppressLint;
|
|
|
import android.app.Activity;
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
+import android.graphics.drawable.GradientDrawable;
|
|
|
import android.os.Build;
|
|
|
import android.os.Bundle;
|
|
|
import android.support.annotation.Nullable;
|
|
|
@@ -15,15 +16,13 @@ import android.util.SparseArray;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.MotionEvent;
|
|
|
import android.view.View;
|
|
|
+import android.view.ViewGroup;
|
|
|
import android.widget.ImageView;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
-import com.bumptech.glide.Glide;
|
|
|
import com.bumptech.glide.load.DataSource;
|
|
|
import com.bumptech.glide.load.engine.GlideException;
|
|
|
-import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
|
|
import com.bumptech.glide.request.RequestListener;
|
|
|
-import com.bumptech.glide.request.RequestOptions;
|
|
|
import com.bumptech.glide.request.target.Target;
|
|
|
import com.kfzs.duanduan.utils.StatusBarUtils;
|
|
|
import com.sheep.gamegroup.absBase.BaseActivity;
|
|
|
@@ -207,26 +206,65 @@ public class ActInvitation extends BaseActivity {
|
|
|
for (final PictureInvitationEntity item : mPictureList) {
|
|
|
View itemView = LayoutInflater.from(SheepApp.getInstance()).inflate(R.layout.item_image2, null);
|
|
|
|
|
|
+ View image_container = itemView.findViewById(R.id.image_container);
|
|
|
ImageView image_full = itemView.findViewById(R.id.image_full);
|
|
|
+ View image_bottom_top = itemView.findViewById(R.id.image_bottom_top);
|
|
|
ImageView image_bottom = itemView.findViewById(R.id.image_bottom);
|
|
|
- Glide.with(SheepApp.getInstance())
|
|
|
- .load(item.getPicture())
|
|
|
- .listener(new RequestListener<Drawable>() {
|
|
|
- @Override
|
|
|
- public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
|
|
- item.setLoaded(false);
|
|
|
- return false;
|
|
|
- }
|
|
|
+ ImageView image_logo = itemView.findViewById(R.id.image_logo);
|
|
|
+ TextView image_tip = itemView.findViewById(R.id.image_tip);
|
|
|
+ RequestListener<Drawable> listener = new RequestListener<Drawable>() {
|
|
|
+ @Override
|
|
|
+ public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
|
|
+ item.setLoaded(false);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
|
|
|
- item.setLoaded(true);
|
|
|
- return false;
|
|
|
- }
|
|
|
- })
|
|
|
- .apply(new RequestOptions().transform(new RoundedCorners((int) getResources().getDimension(R.dimen.content_padding_8))).fitCenter())
|
|
|
- .into(image_full);
|
|
|
- GlideImageLoader.saveAndSetRqImage(image_bottom, item.getLink(), 800);
|
|
|
+ @Override
|
|
|
+ public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
|
|
|
+ item.setLoaded(true);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ if(item.getPicture() != null)
|
|
|
+ GlideImageLoader.downloadAndRoundedImage(String.valueOf(item.getPicture().hashCode()), item.getPicture(), image_full, getResources().getDimensionPixelSize(R.dimen.content_padding_8), listener);
|
|
|
+ //之前的方法实际上没有实现圆角效果
|
|
|
+// Glide.with(SheepApp.getInstance())
|
|
|
+// .load(item.getPicture())
|
|
|
+// .listener(listener)
|
|
|
+// .apply(new RequestOptions().transform(new RoundedCorners((int) getResources().getDimension(R.dimen.content_padding_8))).fitCenter())
|
|
|
+// .into(image_full);
|
|
|
+ int vWidth = viewPager.getWidth();
|
|
|
+ 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) (vWidth * rqRadius));
|
|
|
+ //重新设置logo的宽高
|
|
|
+ ViewGroup.LayoutParams layoutParams = image_logo.getLayoutParams();
|
|
|
+ layoutParams.width = (int) (vWidth * logoRadius);
|
|
|
+ layoutParams.height = (int) (vWidth * logoRadius);
|
|
|
+ image_logo.setLayoutParams(layoutParams);
|
|
|
+ //重新设置二维码上部的距离
|
|
|
+ ViewGroup.LayoutParams layoutParamsTop = image_bottom_top.getLayoutParams();
|
|
|
+ layoutParamsTop.height = (int) (vWidth * topRadius);
|
|
|
+ image_bottom_top.setLayoutParams(layoutParamsTop);
|
|
|
+ //重新设置《扫我开始赚钱》的高度
|
|
|
+ ViewGroup.LayoutParams layoutParamsTip = image_tip.getLayoutParams();
|
|
|
+ layoutParamsTip.height = (int) (vWidth * (tipRadius + topRadius * 3 / 2));
|
|
|
+ image_tip.setLayoutParams(layoutParamsTip);
|
|
|
+ image_tip.setTextSize(vWidth * tipRadius / G.DENSITY);
|
|
|
+ //重新设置整个二维码外容器的高度
|
|
|
+ ViewGroup.LayoutParams layoutParamsContainer = image_container.getLayoutParams();
|
|
|
+ layoutParamsContainer.width = (int) (vWidth * containerWidthRadius);
|
|
|
+ layoutParamsContainer.height = (int) (vWidth * containerHeightRadius);
|
|
|
+ image_container.setLayoutParams(layoutParamsContainer);
|
|
|
+ Drawable bg = image_container.getBackground();
|
|
|
+ if (bg instanceof GradientDrawable) {
|
|
|
+ ((GradientDrawable) bg).setCornerRadius(vWidth * radius);
|
|
|
+ }
|
|
|
viewArrayList.add(itemView);
|
|
|
viewList.put(size, itemView);
|
|
|
size++;
|