Search in sources :

Example 96 with ViewTreeObserver

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

the class Editor method getInsertionController.

InsertionPointCursorController getInsertionController() {
    if (!mInsertionControllerEnabled) {
        return null;
    }
    if (mInsertionPointCursorController == null) {
        mInsertionPointCursorController = new InsertionPointCursorController();
        final ViewTreeObserver observer = mTextView.getViewTreeObserver();
        observer.addOnTouchModeChangeListener(mInsertionPointCursorController);
    }
    return mInsertionPointCursorController;
}
Also used : ViewTreeObserver(android.view.ViewTreeObserver)

Example 97 with ViewTreeObserver

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

the class Editor method getSelectionController.

SelectionModifierCursorController getSelectionController() {
    if (!mSelectionControllerEnabled) {
        return null;
    }
    if (mSelectionModifierCursorController == null) {
        mSelectionModifierCursorController = new SelectionModifierCursorController();
        final ViewTreeObserver observer = mTextView.getViewTreeObserver();
        observer.addOnTouchModeChangeListener(mSelectionModifierCursorController);
    }
    return mSelectionModifierCursorController;
}
Also used : ViewTreeObserver(android.view.ViewTreeObserver)

Example 98 with ViewTreeObserver

use of android.view.ViewTreeObserver in project floatingsearchview by arimorty.

the class FloatingSearchView method onLayout.

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    super.onLayout(changed, l, t, r, b);
    if (mIsInitialLayout) {
        // we need to add 5dp to the mSuggestionsSection because we are
        // going to move it up by 5dp in order to cover the search bar's
        // shadow padding and rounded corners. We also need to add an additional 10dp to
        // mSuggestionsSection in order to hide mSuggestionListContainer's
        // rounded corners and shadow for both, top and bottom.
        int addedHeight = 3 * Util.dpToPx(CARD_VIEW_CORNERS_AND_TOP_BOTTOM_SHADOW_HEIGHT);
        final int finalHeight = mSuggestionsSection.getHeight() + addedHeight;
        mSuggestionsSection.getLayoutParams().height = finalHeight;
        mSuggestionsSection.requestLayout();
        ViewTreeObserver vto = mSuggestionListContainer.getViewTreeObserver();
        vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

            @Override
            public void onGlobalLayout() {
                if (mSuggestionsSection.getHeight() == finalHeight) {
                    Util.removeGlobalLayoutObserver(mSuggestionListContainer, this);
                    mIsSuggestionsSectionHeightSet = true;
                    moveSuggestListToInitialPos();
                    if (mSuggestionSecHeightListener != null) {
                        mSuggestionSecHeightListener.onSuggestionSecHeightSet();
                        mSuggestionSecHeightListener = null;
                    }
                }
            }
        });
        mIsInitialLayout = false;
        refreshDimBackground();
        if (isInEditMode()) {
            inflateOverflowMenu(mMenuId);
        }
    }
}
Also used : ViewTreeObserver(android.view.ViewTreeObserver)

Example 99 with ViewTreeObserver

use of android.view.ViewTreeObserver in project MaterialLibrary by DeveloperPaul123.

the class BaseFabListActivity method toggleButton.

/**
 * Toggles the material floating action button.
 * @param visible
 */
public void toggleButton(final boolean visible) {
    if (isShowing != visible) {
        isShowing = visible;
        int height = materialFloatingActionButton.getHeight();
        if (height == 0) {
            ViewTreeObserver vto = materialFloatingActionButton.getViewTreeObserver();
            if (vto.isAlive()) {
                vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {

                    @Override
                    public boolean onPreDraw() {
                        ViewTreeObserver currentVto = materialFloatingActionButton.getViewTreeObserver();
                        if (currentVto.isAlive()) {
                            currentVto.removeOnPreDrawListener(this);
                        }
                        toggleButton(visible);
                        return true;
                    }
                });
                return;
            }
        }
        int translationY = visible ? 0 : height;
        materialFloatingActionButton.animate().setInterpolator(interpolator).setDuration(500).translationY(translationY);
        // On pre-Honeycomb a translated view is still clickable, so we need to disable clicks manually
        materialFloatingActionButton.setClickable(visible);
    }
}
Also used : ViewTreeObserver(android.view.ViewTreeObserver)

Example 100 with ViewTreeObserver

use of android.view.ViewTreeObserver in project httpclient by pixmob.

the class ActivityChooserView method dismissPopup.

/**
 * Dismisses the popup window with activities.
 *
 * @return True if dismissed, false if already dismissed.
 */
public boolean dismissPopup() {
    if (isShowingPopup()) {
        getListPopupWindow().dismiss();
        ViewTreeObserver viewTreeObserver = getViewTreeObserver();
        if (viewTreeObserver.isAlive()) {
            viewTreeObserver.removeGlobalOnLayoutListener(mOnGlobalLayoutListener);
        }
    }
    return true;
}
Also used : ViewTreeObserver(android.view.ViewTreeObserver)

Aggregations

ViewTreeObserver (android.view.ViewTreeObserver)222 View (android.view.View)56 OnGlobalLayoutListener (android.view.ViewTreeObserver.OnGlobalLayoutListener)25 ImageView (android.widget.ImageView)25 TextView (android.widget.TextView)15 ViewGroup (android.view.ViewGroup)14 SuppressLint (android.annotation.SuppressLint)13 AdapterView (android.widget.AdapterView)12 TypedArray (android.content.res.TypedArray)7 Test (org.junit.Test)7 RectF (android.graphics.RectF)6 DisplayMetrics (android.util.DisplayMetrics)6 ViewParent (android.view.ViewParent)6 LinearLayout (android.widget.LinearLayout)6 ListView (android.widget.ListView)6 Resources (android.content.res.Resources)5 ValueAnimator (android.animation.ValueAnimator)4 TargetApi (android.annotation.TargetApi)4 Activity (android.app.Activity)4 Paint (android.graphics.Paint)4