function SlideButton(shape, theme) {
        shape = shape || Shape.RECT;
        theme = theme || Theme.DEFAULT;
        let thiz = this,
            oriX;
        thiz._shape = shape;
        thiz._theme = theme;
        thiz._params = new LinearLayout_.LayoutParams(shape === Shape.RECT ? -1 : DP * 40, shape === Shape.RECT ? DP * 36 : DP * 40);
        thiz._view = new TextView_(CONTEXT);
        thiz._pressedDrawable = new ColorDrawable_(0);
        thiz._unpressedDrawable = new ColorDrawable_(0);
        thiz._func = () => {};
        thiz._params.setMargins(DP * 6, DP * 6, DP * 6, DP * 6);
        thiz._view.setBackgroundDrawable(thiz._unpressedDrawable);
        thiz._view.setGravity(Gravity_.CENTER);
        thiz._view.setLayoutParams(thiz._params);
        thiz._view.setOnTouchListener(new View_.OnTouchListener({
            onTouch(v, event) {
                let width = v.getWidth(),
                    height = v.getHeight(),
                    x = event.getX(),
                    y = event.getY();
                switch (event.getAction()) {
                case MotionEvent_.ACTION_DOWN:
                    oriX = x;
                    v.setBackgroundDrawable(thiz._pressedDrawable);
                    break;
                case MotionEvent_.ACTION_MOVE:
                    if (x >= 0 && x <= width && y >= 0 && y <= height) {
                        v.setBackgroundDrawable(thiz._pressedDrawable);
                    } else {
                        v.setBackgroundDrawable(thiz._unpressedDrawable);
                    }
                    break;
                case MotionEvent_.ACTION_UP:
                    if (Math.abs(oriX - x) > width / 2) {
                        if (oriX < x) {
                            thiz._func(v, SlideButton.LEFT_RIGHT);
                        } else {
                            thiz._func(v, SlideButton.RIGHT_LEFT);
                        }
                    }
                    if (x >= 0 && x <= width && y >= 0 && y <= height) {
                        v.setBackgroundDrawable(thiz._unpressedDrawable);
                    }
                    break;
                case MotionEvent_.ACTION_CANCEL:
                    if (x >= 0 && x <= width && y >= 0 && y <= height) {
                        v.setBackgroundDrawable(thiz._unpressedDrawable);
                    }
                }
                return true;
            }
        }));
    }
/**
     * Class representing a slide button.
     * @since 2016-08-04
     * @class
     * @extends me.astro.widget.ImageButton
     * @memberOf me.astro.widget
     * @param {Number} [shape=me.astro.design.Shape.RECT] Shape of slide button
     * @param {me.astro.design.Theme} [theme=me.astro.design.Theme.DEFAULT] Theme of slide button
     */
Class representing a slide button.
Class representing a slide button .
function SlideButton(shape, theme) {
        shape = shape || Shape.RECT;
        theme = theme || Theme.DEFAULT;
        let thiz = this,
            oriX;
        thiz._shape = shape;
        thiz._theme = theme;
        thiz._params = new LinearLayout_.LayoutParams(shape === Shape.RECT ? -1 : DP * 40, shape === Shape.RECT ? DP * 36 : DP * 40);
        thiz._view = new TextView_(CONTEXT);
        thiz._pressedDrawable = new ColorDrawable_(0);
        thiz._unpressedDrawable = new ColorDrawable_(0);
        thiz._func = () => {};
        thiz._params.setMargins(DP * 6, DP * 6, DP * 6, DP * 6);
        thiz._view.setBackgroundDrawable(thiz._unpressedDrawable);
        thiz._view.setGravity(Gravity_.CENTER);
        thiz._view.setLayoutParams(thiz._params);
        thiz._view.setOnTouchListener(new View_.OnTouchListener({
            onTouch(v, event) {
                let width = v.getWidth(),
                    height = v.getHeight(),
                    x = event.getX(),
                    y = event.getY();
                switch (event.getAction()) {
                case MotionEvent_.ACTION_DOWN:
                    oriX = x;
                    v.setBackgroundDrawable(thiz._pressedDrawable);
                    break;
                case MotionEvent_.ACTION_MOVE:
                    if (x >= 0 && x <= width && y >= 0 && y <= height) {
                        v.setBackgroundDrawable(thiz._pressedDrawable);
                    } else {
                        v.setBackgroundDrawable(thiz._unpressedDrawable);
                    }
                    break;
                case MotionEvent_.ACTION_UP:
                    if (Math.abs(oriX - x) > width / 2) {
                        if (oriX < x) {
                            thiz._func(v, SlideButton.LEFT_RIGHT);
                        } else {
                            thiz._func(v, SlideButton.RIGHT_LEFT);
                        }
                    }
                    if (x >= 0 && x <= width && y >= 0 && y <= height) {
                        v.setBackgroundDrawable(thiz._unpressedDrawable);
                    }
                    break;
                case MotionEvent_.ACTION_CANCEL:
                    if (x >= 0 && x <= width && y >= 0 && y <= height) {
                        v.setBackgroundDrawable(thiz._unpressedDrawable);
                    }
                }
                return true;
            }
        }));
    }
function SlideButton ( shape , theme ) { shape = shape || Shape . RECT ; theme = theme || Theme . DEFAULT ; let thiz = this , oriX ; thiz . _shape = shape ; thiz . _theme = theme ; thiz . _params = new LinearLayout_ . LayoutParams ( shape === Shape . RECT ? - 1 : DP * 40 , shape === Shape . RECT ? DP * 36 : DP * 40 ) ; thiz . _view = new TextView_ ( CONTEXT ) ; thiz . _pressedDrawable = new ColorDrawable_ ( 0 ) ; thiz . _unpressedDrawable = new ColorDrawable_ ( 0 ) ; thiz . _func = ( ) => { } ; thiz . _params . setMargins ( DP * 6 , DP * 6 , DP * 6 , DP * 6 ) ; thiz . _view . setBackgroundDrawable ( thiz . _unpressedDrawable ) ; thiz . _view . setGravity ( Gravity_ . CENTER ) ; thiz . _view . setLayoutParams ( thiz . _params ) ; thiz . _view . setOnTouchListener ( new View_ . OnTouchListener ( { onTouch ( v , event ) { let width = v . getWidth ( ) , height = v . getHeight ( ) , x = event . getX ( ) , y = event . getY ( ) ; switch ( event . getAction ( ) ) { case MotionEvent_ . ACTION_DOWN : oriX = x ; v . setBackgroundDrawable ( thiz . _pressedDrawable ) ; break ; case MotionEvent_ . ACTION_MOVE : if ( x >= 0 && x <= width && y >= 0 && y <= height ) { v . setBackgroundDrawable ( thiz . _pressedDrawable ) ; } else { v . setBackgroundDrawable ( thiz . _unpressedDrawable ) ; } break ; case MotionEvent_ . ACTION_UP : if ( Math . abs ( oriX - x ) > width / 2 ) { if ( oriX < x ) { thiz . _func ( v , SlideButton . LEFT_RIGHT ) ; } else { thiz . _func ( v , SlideButton . RIGHT_LEFT ) ; } } if ( x >= 0 && x <= width && y >= 0 && y <= height ) { v . setBackgroundDrawable ( thiz . _unpressedDrawable ) ; } break ; case MotionEvent_ . ACTION_CANCEL : if ( x >= 0 && x <= width && y >= 0 && y <= height ) { v . setBackgroundDrawable ( thiz . _unpressedDrawable ) ; } } return true ; } } ) ) ; }
Class representing a slide button.
Class representing a slide button .