|
|
@@ -2,6 +2,7 @@ package com.sheep.gamegroup.view.activity;
|
|
|
|
|
|
import android.annotation.SuppressLint;
|
|
|
import android.app.Activity;
|
|
|
+import android.graphics.BitmapFactory;
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
import android.graphics.drawable.GradientDrawable;
|
|
|
import android.os.Build;
|
|
|
@@ -18,11 +19,15 @@ import android.view.MotionEvent;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
import android.widget.ImageView;
|
|
|
+import android.widget.RelativeLayout;
|
|
|
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;
|
|
|
@@ -37,6 +42,7 @@ import com.sheep.gamegroup.util.CommonUtil;
|
|
|
import com.sheep.gamegroup.util.DataUtil;
|
|
|
import com.sheep.gamegroup.util.GlideImageLoader;
|
|
|
import com.sheep.gamegroup.util.ListUtil;
|
|
|
+import com.sheep.gamegroup.util.LogUtil;
|
|
|
import com.sheep.gamegroup.util.StringUtils;
|
|
|
import com.sheep.gamegroup.util.ViewHolder;
|
|
|
import com.sheep.gamegroup.util.ViewUtil;
|
|
|
@@ -47,6 +53,7 @@ import com.sheep.jiuyan.samllsheep.BuildConfig;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.ClassFileHelper;
|
|
|
+import com.sheep.jiuyan.samllsheep.utils.FileUtil;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.G;
|
|
|
import com.umeng.socialize.ShareAction;
|
|
|
import com.umeng.socialize.bean.SHARE_MEDIA;
|
|
|
@@ -206,13 +213,13 @@ 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);
|
|
|
- ImageView image_logo = itemView.findViewById(R.id.image_logo);
|
|
|
- TextView image_tip = itemView.findViewById(R.id.image_tip);
|
|
|
- RequestListener<Drawable> listener = new RequestListener<Drawable>() {
|
|
|
+ final View image_container = itemView.findViewById(R.id.image_container);
|
|
|
+ final ImageView image_full = itemView.findViewById(R.id.image_full);
|
|
|
+ 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);
|
|
|
+ final RequestListener<Drawable> listener = new RequestListener<Drawable>() {
|
|
|
@Override
|
|
|
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
|
|
item.setLoaded(false);
|
|
|
@@ -225,46 +232,81 @@ public class ActInvitation extends BaseActivity {
|
|
|
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);
|
|
|
+ String name = String.valueOf(item.getPicture().hashCode());
|
|
|
+
|
|
|
+// if(item.getPicture() != null)
|
|
|
+// GlideImageLoader.downloadAndRoundedImage(name, item.getPicture(), image_full, getResources().getDimensionPixelSize(R.dimen.content_padding_8), listener);
|
|
|
+ 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;
|
|
|
+// int w = width;
|
|
|
+// int h = width * options.outHeight / options.outWidth;
|
|
|
+ Glide.with(SheepApp.getInstance())
|
|
|
+ .load(file)
|
|
|
+ .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);
|
|
|
+ }
|
|
|
+ });
|
|
|
//之前的方法实际上没有实现圆角效果
|
|
|
// 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++;
|