Example usage for android.view ViewTreeObserver removeGlobalOnLayoutListener

List of usage examples for android.view ViewTreeObserver removeGlobalOnLayoutListener

Introduction

In this page you can find the example usage for android.view ViewTreeObserver removeGlobalOnLayoutListener.

Prototype

@Deprecated
public void removeGlobalOnLayoutListener(OnGlobalLayoutListener victim) 

Source Link

Document

Remove a previously installed global layout callback

Usage

From source file:Main.java

@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static final void removeOnGlobalLayoutListener(ViewTreeObserver viewTreeObserver,
        ViewTreeObserver.OnGlobalLayoutListener onGlobalLayoutListener) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        viewTreeObserver.removeGlobalOnLayoutListener(onGlobalLayoutListener);
    } else {/*from  w w w  .  j  a  va  2s. com*/
        viewTreeObserver.removeOnGlobalLayoutListener(onGlobalLayoutListener);
    }
}

From source file:Main.java

public static void removeGlobalLayout(ViewTreeObserver viewTreeObserver,
        ViewTreeObserver.OnGlobalLayoutListener layoutListener) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        viewTreeObserver.removeOnGlobalLayoutListener(layoutListener);
    } else {/*from   w w  w  .  ja  v a 2  s.c  om*/
        viewTreeObserver.removeGlobalOnLayoutListener(layoutListener);
    }

}

From source file:com.getkeepsafe.taptargetview.ViewUtil.java

@SuppressWarnings("deprecation")
static void removeOnGlobalLayoutListener(ViewTreeObserver observer,
        ViewTreeObserver.OnGlobalLayoutListener listener) {
    if (Build.VERSION.SDK_INT >= 16) {
        observer.removeOnGlobalLayoutListener(listener);
    } else {//from  w  w  w  . j a va2 s . c  o  m
        observer.removeGlobalOnLayoutListener(listener);
    }
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static void removeGlobalLayoutListener(final ViewTreeObserver viewTreeObserver,
        final ViewTreeObserver.OnGlobalLayoutListener listener) {
    if (viewTreeObserver == null) {
        return;/*  www  .  j a v  a 2  s  . c om*/
    }
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        viewTreeObserver.removeGlobalOnLayoutListener(listener);
    } else {
        viewTreeObserver.removeOnGlobalLayoutListener(listener);
    }
}

From source file:org.linphone.compatibility.ApiFivePlus.java

public static void removeGlobalLayoutListener(ViewTreeObserver viewTreeObserver,
        OnGlobalLayoutListener keyboardListener) {
    viewTreeObserver.removeGlobalOnLayoutListener(keyboardListener);
}

From source file:com.agenmate.lollipop.util.ViewUtils.java

public static void waitForLayoutPrepared(final View view, final LayoutPreparedListener listener) {
    final ViewTreeObserver viewTreeObserver = view.getViewTreeObserver();
    if (viewTreeObserver != null) {
        viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override/*from   w  ww  . j a  v  a2  s  .co  m*/
            public void onGlobalLayout() {
                invokeLayoutListener();
                removeGlobalOnLayoutListenerIfNeeded();
            }

            private void invokeLayoutListener() {
                if (listener != null) {
                    listener.onLayoutPrepared(view);
                }
            }

            private void removeGlobalOnLayoutListenerIfNeeded() {
                final ViewTreeObserver laterViewTreeObserver = view.getViewTreeObserver();
                if (laterViewTreeObserver != null && laterViewTreeObserver.isAlive()) {
                    laterViewTreeObserver.removeGlobalOnLayoutListener(this);
                }
            }
        });
    }
}

From source file:com.hobby.uiframework.widget.PagerSlidingTab.java

public static void removeGlobalOnLayoutListener(ViewTreeObserver mViewTreeObserver,
        ViewTreeObserver.OnGlobalLayoutListener listener) {
    if (android.os.Build.VERSION.SDK_INT < 16) {
        mViewTreeObserver.removeGlobalOnLayoutListener(listener);
    } else {//  w w  w .j  a v  a  2  s.c  o  m
        mViewTreeObserver.removeOnGlobalLayoutListener(listener);
    }
}

From source file:despotoski.nikola.github.com.bottomnavigationlayout.Util.java

public static void runOnAttachedToLayout(View v, final Runnable runnable) {
    if (ViewCompat.isLaidOut(v))
        runnable.run();/*from   www . ja  v  a2 s.c o m*/
    else {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            v.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
                @TargetApi(Build.VERSION_CODES.HONEYCOMB)
                @Override
                public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft,
                        int oldTop, int oldRight, int oldBottom) {
                    runnable.run();
                    v.removeOnLayoutChangeListener(this);
                }
            });
            return;
        }

        final ViewTreeObserver viewTreeObserver = v.getViewTreeObserver();
        if (viewTreeObserver != null && viewTreeObserver.isAlive()) {
            viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                    runnable.run();
                    if (viewTreeObserver.isAlive())
                        //noinspection deprecation
                        viewTreeObserver.removeGlobalOnLayoutListener(this);
                }
            });
        }
    }
}

From source file:io.digibyte.presenter.fragments.FragmentTransactionDetails.java

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final ViewTreeObserver observer = txViewPager.getViewTreeObserver();
    observer.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override//from   w w  w  . j  a va2 s .c  o  m
        public void onGlobalLayout() {
            observer.removeGlobalOnLayoutListener(this);
            BRAnimator.animateBackgroundDim(backgroundLayout, false);
            BRAnimator.animateSignalSlide(txViewPager, false, null);
        }
    });

}

From source file:com.example.ray.firstapp.bottombar.BottomBarBadge.java

protected BottomBarBadge(Context context, final View tabToAddTo, // Rhyming accidentally! That's a Smoove Move!
        int backgroundColor) {
    super(context);

    setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    setGravity(Gravity.CENTER);/*from   w  w w  .  j  av a  2s. c o  m*/
    MiscUtils.setTextAppearance(this, R.style.BB_BottomBarBadge_Text);

    int three = MiscUtils.dpToPixel(context, 3);
    ShapeDrawable backgroundCircle = BadgeCircle.make(three * 3, backgroundColor);
    setPadding(three, three, three, three);
    setBackgroundCompat(backgroundCircle);

    getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @SuppressWarnings("deprecation")
        @Override
        public void onGlobalLayout() {
            adjustPositionAndSize(tabToAddTo);
            ViewTreeObserver obs = getViewTreeObserver();

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                obs.removeOnGlobalLayoutListener(this);
            } else {
                obs.removeGlobalOnLayoutListener(this);
            }
        }
    });
}