use of android.view.ViewTreeObserver.OnGlobalLayoutListener in project UltimateAndroid by cymcsg.
the class PagerSlidingTabStrip method notifyDataSetChanged.
public void notifyDataSetChanged() {
tabsContainer.removeAllViews();
tabCount = pager.getAdapter().getCount();
for (int i = 0; i < tabCount; i++) {
if (pager.getAdapter() instanceof IconTabProvider) {
addIconTab(i, ((IconTabProvider) pager.getAdapter()).getPageIconResId(i));
} else {
addTextTab(i, pager.getAdapter().getPageTitle(i).toString());
}
}
updateTabStyles();
getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
@Override
public void onGlobalLayout() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
getViewTreeObserver().removeGlobalOnLayoutListener(this);
} else {
getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
currentPosition = pager.getCurrentItem();
scrollToChild(currentPosition, 0);
}
});
}
use of android.view.ViewTreeObserver.OnGlobalLayoutListener in project android_frameworks_base by AOSPA.
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 SuperToasts by JohnPersano.
the class TabStrip method notifyDataSetChanged.
private void notifyDataSetChanged() {
tabsContainer.removeAllViews();
tabCount = pager.getAdapter().getCount();
for (int i = 0; i < tabCount; i++) {
if (pager.getAdapter() instanceof IconTabProvider) {
addIconTab(i, ((IconTabProvider) pager.getAdapter()).getPageIconResId(i));
} else {
addTextTab(i, pager.getAdapter().getPageTitle(i).toString());
}
}
updateTabStyles();
getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
@Override
public void onGlobalLayout() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
getViewTreeObserver().removeGlobalOnLayoutListener(this);
} else {
getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
currentPosition = pager.getCurrentItem();
scrollToChild(currentPosition, 0);
}
});
}
use of android.view.ViewTreeObserver.OnGlobalLayoutListener in project android_frameworks_base by crdroidandroid.
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 crdroidandroid.
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