Search in sources :

Example 21 with OnGlobalLayoutListener

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();
}
Also used : RectF(android.graphics.RectF) OnGlobalLayoutListener(android.view.ViewTreeObserver.OnGlobalLayoutListener) ViewTreeObserver(android.view.ViewTreeObserver)

Example 22 with OnGlobalLayoutListener

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;
        }
    });
}
Also used : OnGlobalLayoutListener(android.view.ViewTreeObserver.OnGlobalLayoutListener) ColorPickerView(net.margaritov.preference.colorpicker.widget.ColorPickerView) View(android.view.View) ApplyColorView(net.margaritov.preference.colorpicker.widget.ApplyColorView) TextView(android.widget.TextView) CheckedTextView(android.widget.CheckedTextView) MotionEvent(android.view.MotionEvent)

Example 23 with OnGlobalLayoutListener

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);
                    }
                }
            }
        }
    });
}
Also used : TypedArray(android.content.res.TypedArray) ColorViewButton(net.margaritov.preference.colorpicker.widget.ColorViewButton) OnGlobalLayoutListener(android.view.ViewTreeObserver.OnGlobalLayoutListener) ColorPickerView(net.margaritov.preference.colorpicker.widget.ColorPickerView) View(android.view.View) ApplyColorView(net.margaritov.preference.colorpicker.widget.ApplyColorView) TextView(android.widget.TextView) CheckedTextView(android.widget.CheckedTextView)

Example 24 with OnGlobalLayoutListener

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;
}
Also used : AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) OnGlobalLayoutListener(android.view.ViewTreeObserver.OnGlobalLayoutListener) AbsListView(android.widget.AbsListView) ObservableScrollView(com.marshalchen.common.uimodule.fadingactionbar.view.ObservableScrollView) View(android.view.View) ListView(android.widget.ListView) ObservableWebViewWithHeader(com.marshalchen.common.uimodule.fadingactionbar.view.ObservableWebViewWithHeader)

Example 25 with OnGlobalLayoutListener

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);
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) OnGlobalLayoutListener(android.view.ViewTreeObserver.OnGlobalLayoutListener) Scroller(android.widget.Scroller) XListViewHeader(me.maxwin.view.XListViewHeader) XListViewFooter(me.maxwin.view.XListViewFooter)

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