use of android.view.ViewTreeObserver.OnGlobalLayoutListener in project android_frameworks_base by ResurrectionRemix.
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 Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ColorPickerFragment method setUpHelpScreen.
private void setUpHelpScreen() {
mShowHelpScreen = getShowHelpScreen();
mCheckShowHelpScreen = (CheckedTextView) mColorPickerView.findViewById(R.id.color_picker_check_show_help_screen);
mCheckShowHelpScreen.setChecked(!mShowHelpScreen);
mCheckShowHelpScreen.setOnClickListener(this);
mCloseHelpScreen = (Button) mColorPickerView.findViewById(R.id.color_picker_help_button_ok);
mCloseHelpScreen.setOnClickListener(this);
mHelpScreen.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
mHelpScreenHeight = mHelpScreen.getHeight();
mHelpScreen.getViewTreeObserver().removeOnGlobalLayoutListener(this);
if (!mHelpScreenVisible) {
mHelpScreen.setTranslationY(mFavoritesLayoutHeight);
mHelpScreen.setAlpha(0f);
mHelpScreen.setVisibility(View.GONE);
}
}
});
mHelpScreen.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
}
use of android.view.ViewTreeObserver.OnGlobalLayoutListener in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ColorPickerFragment method setUpFavoriteColorButtons.
private void setUpFavoriteColorButtons() {
mShowFavorites = getShowFavorites();
TypedArray ta = mResources.obtainTypedArray(R.array.color_picker_favorite_color_buttons);
for (int i = 0; i < 4; i++) {
int resId = ta.getResourceId(i, 0);
int buttonNumber = i + 1;
String tag = String.valueOf(buttonNumber);
ColorViewButton button = (ColorViewButton) mColorPickerView.findViewById(resId);
button.setTag(tag);
button.setBorderColor(mBorderColor);
button.setOnLongClickListener(this);
if (getFavoriteButtonValue(button) != 0) {
button.setColor(getFavoriteButtonValue(button));
button.setOnClickListener(this);
} else {
button.setShowFavoriteIcon(true);
}
}
ta.recycle();
mFavoritesLayout.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
mFavoritesLayoutHeight = mFavoritesLayout.getHeight() + mResources.getDimensionPixelSize(R.dimen.color_picker_color_buttons_container_margin_bottom);
mFavoritesLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
if (!mShowFavorites) {
int childCount = mColorButtonsLayout.getChildCount();
for (int i = 0; i < childCount; i++) {
if (i == 0) {
mFavoritesLayout.setAlpha(0f);
} else {
View child = mColorButtonsLayout.getChildAt(i);
child.setTranslationY(0 - mFavoritesLayoutHeight);
}
}
}
}
});
}
use of android.view.ViewTreeObserver.OnGlobalLayoutListener in project UltimateAndroid by cymcsg.
the class FadingActionBarHelperBase method createView.
public final View createView(LayoutInflater inflater) {
//
// Prepare everything
mInflater = inflater;
if (mContentView == null) {
mContentView = inflater.inflate(mContentLayoutResId, null);
}
if (mHeaderView == null) {
mHeaderView = inflater.inflate(mHeaderLayoutResId, null, false);
}
//
// See if we are in a ListView, WebView or ScrollView scenario
ListView listView = (ListView) mContentView.findViewById(android.R.id.list);
View root;
if (listView != null) {
root = createListView(listView);
} else if (mContentView instanceof ObservableWebViewWithHeader) {
root = createWebView();
} else {
root = createScrollView();
}
if (mHeaderOverlayView == null && mHeaderOverlayLayoutResId != 0) {
mHeaderOverlayView = inflater.inflate(mHeaderOverlayLayoutResId, mMarginView, false);
}
if (mHeaderOverlayView != null) {
mMarginView.addView(mHeaderOverlayView);
}
// Use measured height here as an estimate of the header height, later on after the layout is complete
// we'll use the actual height
int widthMeasureSpec = MeasureSpec.makeMeasureSpec(LayoutParams.MATCH_PARENT, MeasureSpec.EXACTLY);
int heightMeasureSpec = MeasureSpec.makeMeasureSpec(LayoutParams.WRAP_CONTENT, MeasureSpec.EXACTLY);
mHeaderView.measure(widthMeasureSpec, heightMeasureSpec);
updateHeaderHeight(mHeaderView.getMeasuredHeight());
root.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
int headerHeight = mHeaderContainer.getHeight();
if (!mFirstGlobalLayoutPerformed && headerHeight != 0) {
updateHeaderHeight(headerHeight);
mFirstGlobalLayoutPerformed = true;
}
}
});
return root;
}
use of android.view.ViewTreeObserver.OnGlobalLayoutListener in project ABPlayer by winkstu.
the class XMultiColumnListView method initWithContext.
protected void initWithContext(Context context) {
mScroller = new Scroller(context, new DecelerateInterpolator());
// XListView need the scroll event, and it will dispatch the event to
// user's listener (as a proxy).
super.setOnScrollListener(this);
// init header view
mHeaderView = new XListViewHeader(context);
mHeaderViewContent = (RelativeLayout) mHeaderView.findViewById(R.id.xlistview_header_content);
mHeaderTimeView = (TextView) mHeaderView.findViewById(R.id.xlistview_header_time);
addHeaderView(mHeaderView);
// init footer view
mFooterView = new XListViewFooter(context);
// init header height
mHeaderView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
mHeaderViewHeight = mHeaderViewContent.getHeight();
getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
});
// 默认关闭所有操作
disablePullLoad();
disablePullRefreash();
// setPullRefreshEnable(mEnablePullRefresh);
// setPullLoadEnable(mEnablePullLoad);
}
Aggregations