Search in sources :

Example 16 with ViewTreeObserver

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

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.removeOnGlobalLayoutListener(mOnGlobalLayoutListener);
        }
    }
    return true;
}
Also used : ViewTreeObserver(android.view.ViewTreeObserver)

Example 17 with ViewTreeObserver

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

the class AbsListView method onAttachedToWindow.

@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();
    final ViewTreeObserver treeObserver = getViewTreeObserver();
    treeObserver.addOnTouchModeChangeListener(this);
    if (mTextFilterEnabled && mPopup != null && !mGlobalLayoutListenerAddedFilter) {
        treeObserver.addOnGlobalLayoutListener(this);
    }
    if (mAdapter != null && mDataSetObserver == null) {
        mDataSetObserver = new AdapterDataSetObserver();
        mAdapter.registerDataSetObserver(mDataSetObserver);
        // Data may have changed while we were detached. Refresh.
        mDataChanged = true;
        mOldItemCount = mItemCount;
        mItemCount = mAdapter.getCount();
    }
    mIsAttached = true;
}
Also used : ViewTreeObserver(android.view.ViewTreeObserver)

Example 18 with ViewTreeObserver

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

the class PopupWindow method registerForScrollChanged.

private void registerForScrollChanged(View anchor, int xoff, int yoff) {
    unregisterForScrollChanged();
    mAnchor = new WeakReference<View>(anchor);
    ViewTreeObserver vto = anchor.getViewTreeObserver();
    if (vto != null) {
        vto.addOnScrollChangedListener(mOnScrollChangedListener);
    }
    mAnchorXoff = xoff;
    mAnchorYoff = yoff;
}
Also used : View(android.view.View) ViewTreeObserver(android.view.ViewTreeObserver)

Example 19 with ViewTreeObserver

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

the class Editor method onAttachedToWindow.

void onAttachedToWindow() {
    if (mShowErrorAfterAttach) {
        showError();
        mShowErrorAfterAttach = false;
    }
    mTemporaryDetach = false;
    final ViewTreeObserver observer = mTextView.getViewTreeObserver();
    // The get method will add the listener on controller creation.
    if (mInsertionPointCursorController != null) {
        observer.addOnTouchModeChangeListener(mInsertionPointCursorController);
    }
    if (mSelectionModifierCursorController != null) {
        mSelectionModifierCursorController.resetTouchOffsets();
        observer.addOnTouchModeChangeListener(mSelectionModifierCursorController);
    }
    updateSpellCheckSpans(0, mTextView.getText().length(), true);
    if (mTextView.hasTransientState() && mTextView.getSelectionStart() != mTextView.getSelectionEnd()) {
        // Since transient state is reference counted make sure it stays matched
        // with our own calls to it for managing selection.
        // The action mode callback will set this back again when/if the action mode starts.
        mTextView.setHasTransientState(false);
        // We had an active selection from before, start the selection mode.
        startSelectionActionMode();
    }
}
Also used : ViewTreeObserver(android.view.ViewTreeObserver)

Example 20 with ViewTreeObserver

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

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)

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)12 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 Paint (android.graphics.Paint)4 Point (android.graphics.Point)4