修复游戏动态查看大图数组越界的问题

This commit is contained in:
leafwai
2022-04-14 20:25:11 +08:00
parent 25a325f7f7
commit cde9401b36

View File

@ -2,7 +2,6 @@ package com.gh.common.util;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.LinearLayout;
import com.facebook.drawee.drawable.ScalingUtils;
@ -19,11 +18,9 @@ import java.util.List;
**/
public class ConcernContentUtils {
private static final ArrayList<SimpleDraweeView> imageViewList = new ArrayList<>();
public static void addContentPic(Context context, LinearLayout linearLayout, List<String> list,
String entrance, int width) {
imageViewList.clear();
ArrayList<SimpleDraweeView> imageViewList = new ArrayList<>();
int count = list.size();
int index = 0;
for (int i = 0, size = (int) Math.ceil(list.size() / 3.0f); i < size; i++) {
@ -36,6 +33,11 @@ public class ConcernContentUtils {
for (int j = 0; j < 3; j++) {
SimpleDraweeView draweeView = getImageView(context, list, entrance, index, width, 0);
imageViewList.add(draweeView);
int position = index;
draweeView.setOnClickListener(v -> {
Intent checkIntent = ImageViewerActivity.getIntent(context, (ArrayList<String>) list, position, imageViewList, entrance);
context.startActivity(checkIntent);
});
ll.addView(draweeView);
index += 1;
}
@ -45,6 +47,11 @@ public class ConcernContentUtils {
case 1:
SimpleDraweeView draweeView = getImageView(context, list, entrance, index, width, 1);
imageViewList.add(draweeView);
int position1 = index;
draweeView.setOnClickListener(v -> {
Intent checkIntent = ImageViewerActivity.getIntent(context, (ArrayList<String>) list, position1, imageViewList, entrance);
context.startActivity(checkIntent);
});
linearLayout.addView(draweeView);
count -= 1;
index += 1;
@ -55,6 +62,11 @@ public class ConcernContentUtils {
for (int j = 0; j < 2; j++) {
SimpleDraweeView imageView = getImageView(context, list, entrance, index, width, 2);
imageViewList.add(imageView);
int position2 = index;
imageView.setOnClickListener(v -> {
Intent checkIntent = ImageViewerActivity.getIntent(context, (ArrayList<String>) list, position2, imageViewList, entrance);
context.startActivity(checkIntent);
});
ll.addView(imageView);
index += 1;
}
@ -102,10 +114,6 @@ public class ConcernContentUtils {
ScalingUtils.ScaleType.CENTER_CROP, list.get(position));
break;
}
imageView.setOnClickListener(v -> {
Intent checkIntent = ImageViewerActivity.getIntent(context, (ArrayList<String>) list, position, imageViewList, entrance);
context.startActivity(checkIntent);
});
return imageView;
}