use of android.os.Handler.Callback in project nmid-headline by miao1007.
the class EditPage method afterPlatformListGot.
/** display platform list */
public void afterPlatformListGot() {
int size = platformList == null ? 0 : platformList.length;
views = new View[size];
final int dp_24 = dipToPx(getContext(), 24);
LayoutParams lpItem = new LayoutParams(dp_24, dp_24);
final int dp_9 = dipToPx(getContext(), 9);
lpItem.setMargins(0, 0, dp_9, 0);
FrameLayout.LayoutParams lpMask = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
lpMask.gravity = Gravity.LEFT | Gravity.TOP;
int selection = 0;
for (int i = 0; i < size; i++) {
FrameLayout fl = new FrameLayout(getContext());
fl.setLayoutParams(lpItem);
if (i >= size - 1) {
fl.setLayoutParams(new LayoutParams(dp_24, dp_24));
}
llPlat.addView(fl);
fl.setOnClickListener(this);
ImageView iv = new ImageView(getContext());
iv.setScaleType(ScaleType.CENTER_INSIDE);
iv.setImageBitmap(getPlatLogo(platformList[i]));
iv.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
fl.addView(iv);
views[i] = new View(getContext());
views[i].setBackgroundColor(0xcfffffff);
views[i].setOnClickListener(this);
String platformName = platformList[i].getName();
for (Platform plat : platforms) {
if (platformName.equals(plat.getName())) {
views[i].setVisibility(View.INVISIBLE);
selection = i;
}
}
views[i].setLayoutParams(lpMask);
fl.addView(views[i]);
}
final int postSel = selection;
UIHandler.sendEmptyMessageDelayed(0, 333, new Callback() {
public boolean handleMessage(Message msg) {
HorizontalScrollView hsv = (HorizontalScrollView) llPlat.getParent();
hsv.scrollTo(postSel * (dp_24 + dp_9), 0);
return false;
}
});
}
Aggregations