Search in sources :

Example 41 with ViewTreeObserver

use of android.view.ViewTreeObserver in project Klyph by jonathangerbaud.

the class AbsHListView method onDetachedFromWindow.

@Override
protected void onDetachedFromWindow() {
    super.onDetachedFromWindow();
    // Dismiss the popup in case onSaveInstanceState() was not invoked
    // Detach any view left in the scrap heap
    mRecycler.clear();
    final ViewTreeObserver treeObserver = getViewTreeObserver();
    treeObserver.removeOnTouchModeChangeListener(this);
    if (mAdapter != null && mDataSetObserver != null) {
        mAdapter.unregisterDataSetObserver(mDataSetObserver);
        mDataSetObserver = null;
    }
    if (mFlingRunnable != null) {
        removeCallbacks(mFlingRunnable);
    }
    if (mPositionScroller != null) {
        mPositionScroller.stop();
    }
    if (mClearScrollingCache != null) {
        removeCallbacks(mClearScrollingCache);
    }
    if (mPerformClick != null) {
        removeCallbacks(mPerformClick);
    }
    if (mTouchModeReset != null) {
        removeCallbacks(mTouchModeReset);
        mTouchModeReset = null;
    }
    mIsAttached = false;
}
Also used : ViewTreeObserver(android.view.ViewTreeObserver)

Example 42 with ViewTreeObserver

use of android.view.ViewTreeObserver in project Jota-Text-Editor-old by jiro-aqua.

the class TextView method onDetachedFromWindow.

@Override
protected void onDetachedFromWindow() {
    super.onDetachedFromWindow();
    final ViewTreeObserver observer = getViewTreeObserver();
    if (observer != null) {
        if (mPreDrawState != PREDRAW_NOT_REGISTERED) {
            observer.removeOnPreDrawListener(this);
            mPreDrawState = PREDRAW_NOT_REGISTERED;
        }
        if (mInsertionPointCursorController != null) {
            observer.removeOnTouchModeChangeListener(mInsertionPointCursorController);
        }
        if (mSelectionModifierCursorController != null) {
            observer.removeOnTouchModeChangeListener(mSelectionModifierCursorController);
        }
    }
    if (mError != null) {
        hideError();
    }
    if (mBlink != null) {
        mBlink.cancel();
    }
    if (mInsertionPointCursorController != null) {
        mInsertionPointCursorController.onDetached();
    }
    if (mSelectionModifierCursorController != null) {
        mSelectionModifierCursorController.onDetached();
    }
    hideControllers();
}
Also used : ViewTreeObserver(android.view.ViewTreeObserver)

Example 43 with ViewTreeObserver

use of android.view.ViewTreeObserver in project Jota-Text-Editor-old by jiro-aqua.

the class TextView method getSelectionController.

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

Example 44 with ViewTreeObserver

use of android.view.ViewTreeObserver in project Jota-Text-Editor-old by jiro-aqua.

the class TextView method onAttachedToWindow.

@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();
    mTemporaryDetach = false;
    if (mShowErrorAfterAttach) {
        showError();
        mShowErrorAfterAttach = false;
    }
    final ViewTreeObserver observer = getViewTreeObserver();
    if (observer != null) {
        if (mInsertionPointCursorController != null) {
            observer.addOnTouchModeChangeListener(mInsertionPointCursorController);
        }
        if (mSelectionModifierCursorController != null) {
            observer.addOnTouchModeChangeListener(mSelectionModifierCursorController);
        }
    }
}
Also used : ViewTreeObserver(android.view.ViewTreeObserver)

Example 45 with ViewTreeObserver

use of android.view.ViewTreeObserver in project KJFrameForAndroid by kymjs.

the class CurtainViewController method prepareSlidingLayout.

/**
     * 为控件做一些属性设置
     */
protected void prepareSlidingLayout() {
    curtainLayoutParams = (FrameLayout.LayoutParams) curtainParent.getLayoutParams();
    ViewTreeObserver vto = curtainParent.getViewTreeObserver();
    vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

        @Override
        @SuppressLint("NewApi")
        public void onGlobalLayout() {
            hideCurtainLayout();
            ViewTreeObserver obs = curtainParent.getViewTreeObserver();
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                obs.removeOnGlobalLayoutListener(this);
            } else {
                obs.removeGlobalOnLayoutListener(this);
            }
        }
    });
    curtainParent.setOnTouchListener(new OnContentTouchListener());
    curtainParent.setOnKeyListener(new OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK && getSlidingStatus() == SlidingStatus.EXPANDED) {
                collapse();
                return true;
            } else {
                return false;
            }
        }
    });
}
Also used : KeyEvent(android.view.KeyEvent) FrameLayout(android.widget.FrameLayout) OnGlobalLayoutListener(android.view.ViewTreeObserver.OnGlobalLayoutListener) SuppressLint(android.annotation.SuppressLint) OnKeyListener(android.view.View.OnKeyListener) ViewTreeObserver(android.view.ViewTreeObserver) View(android.view.View) SuppressLint(android.annotation.SuppressLint)

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