use of android.view.ViewTreeObserver in project android_frameworks_base by ResurrectionRemix.
the class ActivityChooserView method onDetachedFromWindow.
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
ActivityChooserModel dataModel = mAdapter.getDataModel();
if (dataModel != null) {
dataModel.unregisterObserver(mModelDataSetOberver);
}
ViewTreeObserver viewTreeObserver = getViewTreeObserver();
if (viewTreeObserver.isAlive()) {
viewTreeObserver.removeOnGlobalLayoutListener(mOnGlobalLayoutListener);
}
if (isShowingPopup()) {
dismissPopup();
}
mIsAttachedToWindow = false;
}
use of android.view.ViewTreeObserver in project CompactCalendarView by SundeepK.
the class CompactCalendarTab method openCalendarOnCreate.
private void openCalendarOnCreate(View v) {
final RelativeLayout layout = (RelativeLayout) v.findViewById(R.id.main_content);
ViewTreeObserver vto = layout.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (Build.VERSION.SDK_INT < 16) {
layout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
} else {
layout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
compactCalendarView.showCalendarWithAnimation();
}
});
}
use of android.view.ViewTreeObserver in project android_frameworks_base by ResurrectionRemix.
the class PopupWindow method detachFromAnchor.
private void detachFromAnchor() {
final View anchor = mAnchor != null ? mAnchor.get() : null;
if (anchor != null) {
final ViewTreeObserver vto = anchor.getViewTreeObserver();
vto.removeOnScrollChangedListener(mOnScrollChangedListener);
}
final View anchorRoot = mAnchorRoot != null ? mAnchorRoot.get() : null;
if (anchorRoot != null) {
anchorRoot.removeOnAttachStateChangeListener(mOnAnchorRootDetachedListener);
}
mAnchor = null;
mAnchorRoot = null;
mIsAnchorRootAttached = false;
}
use of android.view.ViewTreeObserver in project android_frameworks_base by ResurrectionRemix.
the class PopupWindow method attachToAnchor.
private void attachToAnchor(View anchor, int xoff, int yoff, int gravity) {
detachFromAnchor();
final ViewTreeObserver vto = anchor.getViewTreeObserver();
if (vto != null) {
vto.addOnScrollChangedListener(mOnScrollChangedListener);
}
final View anchorRoot = anchor.getRootView();
anchorRoot.addOnAttachStateChangeListener(mOnAnchorRootDetachedListener);
mAnchor = new WeakReference<>(anchor);
mAnchorRoot = new WeakReference<>(anchorRoot);
mIsAnchorRootAttached = anchorRoot.isAttachedToWindow();
mAnchorXoff = xoff;
mAnchorYoff = yoff;
mAnchoredGravity = gravity;
}
use of android.view.ViewTreeObserver in project ActionBarSherlock by JakeWharton.
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;
}
Aggregations