相册
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
public class MyGallery extends HorizontalScrollView {
private List a = new ArrayList();
private List b = new ArrayList();
private Context c;
private int d;
private int e = -1;
private int f = 4;
private int g = 0;
private int h;
private OnClickListener i;
private OnLongClickListener j;
private int k = 200;
private float l = 1.2f;
private LayoutInflater m;
private List n;
private int o = -5;
public MyGallery(Context context) {
super(context);
this.c = context;
}
public MyGallery(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.c = context;
}
public MyGallery(Context context, AttributeSet attributeSet, int i2) {
super(context, attributeSet, i2);
this.c = context;
}
private void a() {
removeAllViews();
LinearLayout linearLayout = new LinearLayout(this.c);
linearLayout.setLayoutParams(new LayoutParams(-1, -2));
int i2 = 0;
while (true) {
int i3 = i2;
if (i3 >= this.n.size()) {
addView(linearLayout);
a(Integer.valueOf(this.g));
return;
}
bc bcVar = (bc) this.n.get(i3);
FrameLayout frameLayout = (FrameLayout) this.m.inflate(C0000R.layout.mygallery_item, null);
frameLayout.setLayoutParams(new LayoutParams(this.h, (this.h * 9) / 16));
ImageView imageView = (ImageView) frameLayout.findViewById(C0000R.id.image);
imageView.setTag(Integer.valueOf(i3));
imageView.setOnClickListener(this.i);
imageView.setOnLongClickListener(this.j);
TextView textView = (TextView) frameLayout.findViewById(C0000R.id.text);
textView.setText(bcVar.a);
textView.setTextColor(bcVar.b);
imageView.setImageBitmap(bcVar.c);
imageView.setScaleType(ScaleType.FIT_XY);
linearLayout.addView(frameLayout);
this.a.add(imageView);
this.b.add(textView);
a(Integer.valueOf(i3));
i2 = i3 + 1;
}
}
public void a(Integer num) {
if (num.intValue() != this.e) {
if (this.e != -1) {
((ImageView) this.a.get(this.e)).setBackgroundResource(0);
}
((ImageView) this.a.get(num.intValue())).setBackgroundResource(C0000R.drawable.select_effect);
this.e = num.intValue();
}
}
/* access modifiers changed from: protected */
public void onLayout(boolean z, int i2, int i3, int i4, int i5) {
super.onLayout(z, i2, i3, i4, i5);
if (this.d != getWidth()) {
this.d = getWidth();
this.h = this.d / this.f;
a();
}
}
}
网友评论