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();
}
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);
}
}
}
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);
}
}
}
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;
}
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);
}
}
}
Aggregations