移除冗余代码

This commit is contained in:
张晨
2024-05-27 09:31:05 +08:00
parent 81f96577d0
commit d7d91b002e

View File

@ -2,17 +2,13 @@ package com.gh.common.util;
import android.content.Context;
import android.content.Intent;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.facebook.drawee.drawable.ScalingUtils;
import com.facebook.drawee.view.SimpleDraweeView;
import com.gh.gamecenter.ImageViewerActivity;
import com.gh.gamecenter.core.utils.DisplayUtils;
import com.gh.gamecenter.common.utils.ImageUtils;
import org.jetbrains.annotations.NotNull;
import com.gh.gamecenter.core.utils.DisplayUtils;
import java.util.ArrayList;
import java.util.List;
@ -83,49 +79,6 @@ public class ConcernContentUtils {
}
}
public static void addArticlePic(@NotNull Context context, @NotNull LinearLayout linearLayout, @NotNull List<String> list, @NotNull String entrance, int width) {
int count = list.size();
if (count == 1) {
LinearLayout ll = new LinearLayout(context);
ll.setOrientation(LinearLayout.HORIZONTAL);
SimpleDraweeView imageView = new SimpleDraweeView(context);
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
width, width / 3);
imageView.setLayoutParams(lparams);
ImageUtils.display(context.getResources(), imageView, width, ScalingUtils.ScaleType.CENTER_CROP, list.get(0));
ll.addView(imageView);
linearLayout.addView(ll);
} else {
LinearLayout ll = null;
int imageWidth = (width - DisplayUtils.dip2px(context, 4) * 2) / 3;
for (int i = 0; i < 3; i++) {
if (i == 0) {
ll = new LinearLayout(context);
linearLayout.addView(ll);
}
SimpleDraweeView imageView = new SimpleDraweeView(context);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(imageWidth, imageWidth);
switch (i) {
case 0:
layoutParams.setMargins(0, 0, DisplayUtils.dip2px(context, 4), 0);
break;
case 1:
layoutParams.setMargins(0, 0, 0, 0);
break;
default:
layoutParams.setMargins(DisplayUtils.dip2px(context, 4), 0, 0, 0);
break;
}
imageView.setLayoutParams(layoutParams);
ImageUtils.display(context.getResources(), imageView, imageWidth, ScalingUtils.ScaleType.CENTER_CROP, list.get(i));
ll.addView(imageView);
}
}
}
private static SimpleDraweeView getImageView(final Context context,
final List<String> list,
final int position,