Search in sources :

Example 16 with OnGlobalLayoutListener

use of android.view.ViewTreeObserver.OnGlobalLayoutListener in project android_frameworks_base by DirtyUnicorns.

the class CropView method moveToLeft.

public void moveToLeft() {
    if (getWidth() == 0 || getHeight() == 0) {
        final ViewTreeObserver observer = getViewTreeObserver();
        observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

            public void onGlobalLayout() {
                moveToLeft();
                getViewTreeObserver().removeOnGlobalLayoutListener(this);
            }
        });
    }
    final RectF edges = mTempEdges;
    getEdgesHelper(edges);
    final float scale = mRenderer.scale;
    mCenterX += Math.ceil(edges.left / scale);
    updateCenter();
}
Also used : RectF(android.graphics.RectF) OnGlobalLayoutListener(android.view.ViewTreeObserver.OnGlobalLayoutListener) ViewTreeObserver(android.view.ViewTreeObserver)

Example 17 with OnGlobalLayoutListener

use of android.view.ViewTreeObserver.OnGlobalLayoutListener in project android_frameworks_base by DirtyUnicorns.

the class Spinner method onRestoreInstanceState.

@Override
public void onRestoreInstanceState(Parcelable state) {
    SavedState ss = (SavedState) state;
    super.onRestoreInstanceState(ss.getSuperState());
    if (ss.showDropdown) {
        ViewTreeObserver vto = getViewTreeObserver();
        if (vto != null) {
            final OnGlobalLayoutListener listener = new OnGlobalLayoutListener() {

                @Override
                public void onGlobalLayout() {
                    if (!mPopup.isShowing()) {
                        mPopup.show(getTextDirection(), getTextAlignment());
                    }
                    final ViewTreeObserver vto = getViewTreeObserver();
                    if (vto != null) {
                        vto.removeOnGlobalLayoutListener(this);
                    }
                }
            };
            vto.addOnGlobalLayoutListener(listener);
        }
    }
}
Also used : OnGlobalLayoutListener(android.view.ViewTreeObserver.OnGlobalLayoutListener) ViewTreeObserver(android.view.ViewTreeObserver)

Example 18 with OnGlobalLayoutListener

use of android.view.ViewTreeObserver.OnGlobalLayoutListener in project android_frameworks_base by AOSPA.

the class Spinner method onRestoreInstanceState.

@Override
public void onRestoreInstanceState(Parcelable state) {
    SavedState ss = (SavedState) state;
    super.onRestoreInstanceState(ss.getSuperState());
    if (ss.showDropdown) {
        ViewTreeObserver vto = getViewTreeObserver();
        if (vto != null) {
            final OnGlobalLayoutListener listener = new OnGlobalLayoutListener() {

                @Override
                public void onGlobalLayout() {
                    if (!mPopup.isShowing()) {
                        mPopup.show(getTextDirection(), getTextAlignment());
                    }
                    final ViewTreeObserver vto = getViewTreeObserver();
                    if (vto != null) {
                        vto.removeOnGlobalLayoutListener(this);
                    }
                }
            };
            vto.addOnGlobalLayoutListener(listener);
        }
    }
}
Also used : OnGlobalLayoutListener(android.view.ViewTreeObserver.OnGlobalLayoutListener) ViewTreeObserver(android.view.ViewTreeObserver)

Example 19 with OnGlobalLayoutListener

use of android.view.ViewTreeObserver.OnGlobalLayoutListener in project KISS by Neamar.

the class ColorPreference method onCreateDialogView.

@Override
protected View onCreateDialogView() {
    // Create layout from bound resource
    final View view = super.onCreateDialogView();
    // Configure the color picker
    this.palette = (ColorPickerPalette) view.findViewById(R.id.colorPicker);
    this.palette.init(ColorPickerDialog.SIZE_SMALL, 4, this);
    // Reconfigure color picker based on the available space
    view.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

        private boolean ignoreNextUpdate = false;

        public void onGlobalLayout() {
            if (this.ignoreNextUpdate) {
                this.ignoreNextUpdate = false;
                return;
            }
            // Calculate number of swatches to display
            int swatchSize = ColorPreference.this.palette.getResources().getDimensionPixelSize(R.dimen.color_swatch_small);
            ColorPreference.this.palette.init(ColorPickerDialog.SIZE_SMALL, (view.getWidth() - (swatchSize * 2 / 3)) / swatchSize, ColorPreference.this);
            // Cause redraw and (by extension) also a layout recalculation
            this.ignoreNextUpdate = true;
            ColorPreference.this.drawPalette();
        }
    });
    // Bind click events from the custom color values
    Button button1 = (Button) view.findViewById(R.id.colorTransparentDark);
    button1.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            ColorPreference.this.onColorSelected(0xAA000000);
        }
    });
    Button button2 = (Button) view.findViewById(R.id.colorTransparentWhite);
    button2.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            ColorPreference.this.onColorSelected(0xAAFFFFFF);
        }
    });
    Button button3 = (Button) view.findViewById(R.id.colorTransparent);
    button3.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            ColorPreference.this.onColorSelected(0x00000000);
        }
    });
    return view;
}
Also used : Button(android.widget.Button) OnGlobalLayoutListener(android.view.ViewTreeObserver.OnGlobalLayoutListener) View(android.view.View)

Example 20 with OnGlobalLayoutListener

use of android.view.ViewTreeObserver.OnGlobalLayoutListener in project android_frameworks_base by ResurrectionRemix.

the class Spinner method onRestoreInstanceState.

@Override
public void onRestoreInstanceState(Parcelable state) {
    SavedState ss = (SavedState) state;
    super.onRestoreInstanceState(ss.getSuperState());
    if (ss.showDropdown) {
        ViewTreeObserver vto = getViewTreeObserver();
        if (vto != null) {
            final OnGlobalLayoutListener listener = new OnGlobalLayoutListener() {

                @Override
                public void onGlobalLayout() {
                    if (!mPopup.isShowing()) {
                        mPopup.show(getTextDirection(), getTextAlignment());
                    }
                    final ViewTreeObserver vto = getViewTreeObserver();
                    if (vto != null) {
                        vto.removeOnGlobalLayoutListener(this);
                    }
                }
            };
            vto.addOnGlobalLayoutListener(listener);
        }
    }
}
Also used : OnGlobalLayoutListener(android.view.ViewTreeObserver.OnGlobalLayoutListener) ViewTreeObserver(android.view.ViewTreeObserver)

Aggregations

OnGlobalLayoutListener (android.view.ViewTreeObserver.OnGlobalLayoutListener)51 ViewTreeObserver (android.view.ViewTreeObserver)25 SuppressLint (android.annotation.SuppressLint)18 View (android.view.View)13 Paint (android.graphics.Paint)12 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)8 TypedArray (android.content.res.TypedArray)7 DisplayMetrics (android.util.DisplayMetrics)7 RectF (android.graphics.RectF)6 TextView (android.widget.TextView)6 AbsListView (android.widget.AbsListView)4 ListView (android.widget.ListView)4 Scroller (android.widget.Scroller)4 Animator (android.animation.Animator)3 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)3 AnimatorSet (android.animation.AnimatorSet)3 ObjectAnimator (android.animation.ObjectAnimator)3 ValueAnimator (android.animation.ValueAnimator)3 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)3 AppWidgetHostView (android.appwidget.AppWidgetHostView)3