Search in sources :

Example 1 with Callback

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;
        }
    });
}
Also used : LayoutParams(android.widget.LinearLayout.LayoutParams) Callback(android.os.Handler.Callback) Platform(cn.sharesdk.framework.Platform) CustomPlatform(cn.sharesdk.framework.CustomPlatform) Message(android.os.Message) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) View(android.view.View) TextView(android.widget.TextView) BitmapHelper.captureView(com.mob.tools.utils.BitmapHelper.captureView) HorizontalScrollView(android.widget.HorizontalScrollView)

Aggregations

Callback (android.os.Handler.Callback)1 Message (android.os.Message)1 View (android.view.View)1 FrameLayout (android.widget.FrameLayout)1 HorizontalScrollView (android.widget.HorizontalScrollView)1 ImageView (android.widget.ImageView)1 LayoutParams (android.widget.LinearLayout.LayoutParams)1 TextView (android.widget.TextView)1 CustomPlatform (cn.sharesdk.framework.CustomPlatform)1 Platform (cn.sharesdk.framework.Platform)1 BitmapHelper.captureView (com.mob.tools.utils.BitmapHelper.captureView)1