This commit is contained in:
张晨
2024-05-26 14:14:30 +08:00
parent 44a2e616ab
commit 81f96577d0
135 changed files with 10332 additions and 1865 deletions

View File

@ -2,6 +2,8 @@ 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;
@ -10,6 +12,8 @@ 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 java.util.ArrayList;
import java.util.List;
@ -79,6 +83,49 @@ 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,
@ -121,5 +168,4 @@ public class ConcernContentUtils {
}
return imageView;
}
}