entrance检查与统一
This commit is contained in:
@ -20,42 +20,40 @@ import java.util.List;
|
||||
**/
|
||||
public class ConcernContentUtils {
|
||||
|
||||
public static void addContentPic(int width, LinearLayout linearLayout, List<String> list, Context context) {
|
||||
public static void addContentPic(Context context, LinearLayout linearLayout, List<String> list,
|
||||
String entrance, int width) {
|
||||
int count = list.size();
|
||||
LinearLayout ll;
|
||||
int index = 0;
|
||||
for (int i = 0, size = (int) Math.ceil(list.size() / 3.0f); i < size; i++) {
|
||||
switch (count % 3) {
|
||||
case 0:
|
||||
ll = new LinearLayout(context);
|
||||
ll.setOrientation(LinearLayout.HORIZONTAL);
|
||||
for (int j = 0; j < 3; j++) {
|
||||
ll.addView(getImageView(list, index, width, 0, context));
|
||||
index += 1;
|
||||
}
|
||||
linearLayout.addView(ll);
|
||||
count -= 3;
|
||||
break;
|
||||
case 1:
|
||||
linearLayout.addView(getImageView(list, index, width, 1, context));
|
||||
count -= 1;
|
||||
int type = count % 3;
|
||||
if (type == 0) {
|
||||
LinearLayout ll = new LinearLayout(context);
|
||||
ll.setOrientation(LinearLayout.HORIZONTAL);
|
||||
for (int j = 0; j < 3; j++) {
|
||||
ll.addView(getImageView(context, list, entrance, index, width, 0));
|
||||
index += 1;
|
||||
break;
|
||||
case 2:
|
||||
ll = new LinearLayout(context);
|
||||
ll.setOrientation(LinearLayout.HORIZONTAL);
|
||||
for (int j = 0; j < 2; j++) {
|
||||
ll.addView(getImageView(list, index, width, 2, context));
|
||||
index += 1;
|
||||
}
|
||||
linearLayout.addView(ll);
|
||||
count -= 2;
|
||||
break;
|
||||
}
|
||||
linearLayout.addView(ll);
|
||||
count -= 3;
|
||||
} else if (type == 1) {
|
||||
linearLayout.addView(getImageView(context, list, entrance, index, width, 1));
|
||||
count -= 1;
|
||||
index += 1;
|
||||
} else if (type == 2) {
|
||||
LinearLayout ll = new LinearLayout(context);
|
||||
ll.setOrientation(LinearLayout.HORIZONTAL);
|
||||
for (int j = 0; j < 2; j++) {
|
||||
ll.addView(getImageView(context, list, entrance, index, width, 2));
|
||||
index += 1;
|
||||
}
|
||||
linearLayout.addView(ll);
|
||||
count -= 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static SimpleDraweeView getImageView(final List<String> list, final int position, int width, int type, final Context context) {
|
||||
private static SimpleDraweeView getImageView(final Context context, final List<String> list, final String entrance,
|
||||
final int position, int width, int type) {
|
||||
SimpleDraweeView imageView;
|
||||
if (type == 0) {
|
||||
imageView = new SimpleDraweeView(context);
|
||||
@ -65,14 +63,16 @@ public class ConcernContentUtils {
|
||||
DisplayUtils.dip2px(context, 2), DisplayUtils.dip2px(context, 4));
|
||||
lparams.weight = 1;
|
||||
imageView.setLayoutParams(lparams);
|
||||
ImageUtils.getInstance().display(context.getResources(), imageView, ScalingUtils.ScaleType.CENTER_CROP, list.get(position));
|
||||
ImageUtils.getInstance().display(context.getResources(), imageView,
|
||||
ScalingUtils.ScaleType.CENTER_CROP, list.get(position));
|
||||
} else if (type == 1) {
|
||||
imageView = new SimpleDraweeView(context);
|
||||
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(width, width / 2);
|
||||
lparams.setMargins(DisplayUtils.dip2px(context, 2), 0,
|
||||
DisplayUtils.dip2px(context, 2), DisplayUtils.dip2px(context, 4));
|
||||
imageView.setLayoutParams(lparams);
|
||||
ImageUtils.getInstance().display(context.getResources(), imageView, ScalingUtils.ScaleType.CENTER_CROP, list.get(position));
|
||||
ImageUtils.getInstance().display(context.getResources(), imageView,
|
||||
ScalingUtils.ScaleType.CENTER_CROP, list.get(position));
|
||||
} else {
|
||||
imageView = new SimpleDraweeView(context);
|
||||
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
|
||||
@ -81,7 +81,8 @@ public class ConcernContentUtils {
|
||||
DisplayUtils.dip2px(context, 2), DisplayUtils.dip2px(context, 4));
|
||||
lparams.weight = 1;
|
||||
imageView.setLayoutParams(lparams);
|
||||
ImageUtils.getInstance().display(context.getResources(), imageView, ScalingUtils.ScaleType.CENTER_CROP, list.get(position));
|
||||
ImageUtils.getInstance().display(context.getResources(), imageView,
|
||||
ScalingUtils.ScaleType.CENTER_CROP, list.get(position));
|
||||
}
|
||||
imageView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -90,6 +91,7 @@ public class ConcernContentUtils {
|
||||
checkIntent.putExtra("urls", (ArrayList<String>) list);
|
||||
checkIntent.putExtra("current", position);
|
||||
checkIntent.putExtra("ScaleType", "FIT_CENTER");
|
||||
checkIntent.putExtra("entrance", entrance);
|
||||
context.startActivity(checkIntent);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user