Search in sources :

Example 6 with OnPreDrawListener

use of android.view.ViewTreeObserver.OnPreDrawListener in project SeaStar by 13120241790.

the class DragPointView method initbg.

private void initbg() {
    setGravity(Gravity.CENTER);
    getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {

        @SuppressWarnings("deprecation")
        @Override
        public boolean onPreDraw() {
            if (!initBgFlag) {
                DragPointView.this.setBackgroundDrawable(createStateListDrawable((getHeight() > getWidth() ? getHeight() : getWidth()) / 2, backgroundColor));
                initBgFlag = true;
                return false;
            }
            return true;
        }
    });
}
Also used : OnPreDrawListener(android.view.ViewTreeObserver.OnPreDrawListener)

Example 7 with OnPreDrawListener

use of android.view.ViewTreeObserver.OnPreDrawListener in project GestureViews by alexvasilkov.

the class FullImageActivity method runAfterImageDraw.

/**
 * Runs provided action after image is drawn for the first time.
 */
private void runAfterImageDraw(final Runnable action) {
    image.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {

        @Override
        public boolean onPreDraw() {
            image.getViewTreeObserver().removeOnPreDrawListener(this);
            runOnNextFrame(action);
            return true;
        }
    });
    image.invalidate();
}
Also used : OnPreDrawListener(android.view.ViewTreeObserver.OnPreDrawListener)

Example 8 with OnPreDrawListener

use of android.view.ViewTreeObserver.OnPreDrawListener in project libgdx by libgdx.

the class AndroidOnscreenKeyboard method setVisible.

public void setVisible(boolean visible) {
    if (visible && dialog != null) {
        dialog.dismiss();
        dialog = null;
    }
    if (visible && dialog == null && !input.isPeripheralAvailable(Peripheral.HardwareKeyboard)) {
        handler.post(new Runnable() {

            @Override
            public void run() {
                dialog = createDialog();
                dialog.show();
                handler.post(new Runnable() {

                    @Override
                    public void run() {
                        dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
                        InputMethodManager input = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
                        if (input != null)
                            input.showSoftInput(textView, InputMethodManager.SHOW_FORCED);
                    }
                });
                final View content = dialog.getWindow().findViewById(Window.ID_ANDROID_CONTENT);
                content.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {

                    int[] screenloc = new int[2];

                    private int keyboardHeight;

                    private boolean keyboardShowing;

                    @Override
                    public boolean onPreDraw() {
                        content.getLocationOnScreen(screenloc);
                        keyboardHeight = Math.abs(screenloc[1]);
                        if (keyboardHeight > 0)
                            keyboardShowing = true;
                        if (keyboardHeight == 0 && keyboardShowing) {
                            dialog.dismiss();
                            dialog = null;
                        }
                        return true;
                    }
                });
            }
        });
    } else {
        if (!visible && dialog != null) {
            dialog.dismiss();
        }
    }
}
Also used : InputMethodManager(android.view.inputmethod.InputMethodManager) TextView(android.widget.TextView) View(android.view.View) OnPreDrawListener(android.view.ViewTreeObserver.OnPreDrawListener)

Example 9 with OnPreDrawListener

use of android.view.ViewTreeObserver.OnPreDrawListener in project AisenWeiBo by wangdan.

the class WallpaperViewer method init.

public void init() {
    setBackgroundResource(R.drawable.wallpaper_viewer_bg);
    getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {

        @Override
        public boolean onPreDraw() {
            getViewTreeObserver().removeOnPreDrawListener(this);
            // 初始化 innerView
            mInnerView = new View(getContext());
            mInnerView.setLayoutParams(new LayoutParams((int) (getWidth() * INN_WIDTH_PERCENTS), LayoutParams.MATCH_PARENT));
            mInnerView.setBackgroundResource(R.drawable.wallpaper_viewer_inn_bg);
            mInnCenterPositionX = (int) (getWidth() * (1 - INN_WIDTH_PERCENTS) / 2);
            setInnViewPositionX(mInnCenterPositionX);
            addView(mInnerView);
            return true;
        }
    });
}
Also used : OnPreDrawListener(android.view.ViewTreeObserver.OnPreDrawListener) View(android.view.View)

Example 10 with OnPreDrawListener

use of android.view.ViewTreeObserver.OnPreDrawListener in project UltimateAndroid by cymcsg.

the class RotaryView method init.

public void init() {
    paint = new Paint();
    paint.setAntiAlias(true);
    paint.setStyle(Paint.Style.FILL_AND_STROKE);
    paintWhite = new Paint();
    paintWhite.setAntiAlias(true);
    paintWhite.setColor(0xffffffff);
    paintWhite.setStyle(Paint.Style.FILL_AND_STROKE);
    bitmapRefreshPaint = new Paint();
    bitmapRefreshPaint.setAntiAlias(true);
    setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    // 绘制完毕
    this.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {

        public boolean onPreDraw() {
            Init();
            getViewTreeObserver().removeOnPreDrawListener(this);
            return false;
        }
    });
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) OnPreDrawListener(android.view.ViewTreeObserver.OnPreDrawListener)

Aggregations

OnPreDrawListener (android.view.ViewTreeObserver.OnPreDrawListener)12 View (android.view.View)5 AnimatorSet (android.animation.AnimatorSet)2 ViewGroup (android.view.ViewGroup)2 LayoutParams (android.view.ViewGroup.LayoutParams)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 ObjectAnimator (android.animation.ObjectAnimator)1 Resources (android.content.res.Resources)1 Bitmap (android.graphics.Bitmap)1 Outline (android.graphics.Outline)1 Paint (android.graphics.Paint)1 Rect (android.graphics.Rect)1 RectF (android.graphics.RectF)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Drawable (android.graphics.drawable.Drawable)1 ViewOutlineProvider (android.view.ViewOutlineProvider)1