Java Code Examples for android.view.ViewTreeObserver#OnScrollChangedListener
The following examples show how to use
android.view.ViewTreeObserver#OnScrollChangedListener .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlurDrawableActivity.java From Blur with Apache License 2.0 | 6 votes |
public ViewTreeObserver.OnScrollChangedListener getOnScrollChangedListener() { if (mOnScrollChangedListener == null) { mOnScrollChangedListener = new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { //BlurDrawable ViewCompat.postInvalidateOnAnimation(mBlurDrawableRelativeLayout); //BlurMaskRelativeLayout int scrollY = mScrollView.getScrollY(); Log.i("robin","scrollY:"+scrollY); float alpha = (float) scrollY/1000; if (alpha > 1f) { alpha = 1f; } Log.i("robin","alpha:"+alpha); mBlurMaskRelativeLayout.setAlpha(1f-(alpha)); } }; } return mOnScrollChangedListener; }
Example 2
Source File: AccountSigninConfirmationView.java From 365browser with Apache License 2.0 | 6 votes |
/** * Sets observer. See {@link Observer}. Regardless of the passed value, notifications for * the previous observer will be canceled. * * @param observer Instance that will receive notifications, or null to clear the observer. */ public void setObserver(@Nullable Observer observer) { removeObservers(); if (observer == null) return; mObserver = observer; mOnGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { checkScrolledToBottom(); } }; getViewTreeObserver().addOnGlobalLayoutListener(mOnGlobalLayoutListener); mOnScrollChangedListener = new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { checkScrolledToBottom(); } }; getViewTreeObserver().addOnScrollChangedListener(mOnScrollChangedListener); }
Example 3
Source File: GlassView.java From GlassView with Apache License 2.0 | 6 votes |
private ViewTreeObserver.OnScrollChangedListener getScrollChangedListener() { if (mScrollChangedListener == null) { mScrollChangedListener = new ViewTreeObserver.OnScrollChangedListener() { /** * Callback method to be invoked when something in the view tree * has been scrolled. */ @Override public void onScrollChanged() { //Log.d(TAG, "onScrollChanged() called"); invalidate(); } }; } return mScrollChangedListener; }
Example 4
Source File: ActionBarPopupWindow.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void init() { if (superListenerField != null) { try { mSuperScrollListener = (ViewTreeObserver.OnScrollChangedListener) superListenerField.get(this); superListenerField.set(this, NOP); } catch (Exception e) { mSuperScrollListener = null; } } }
Example 5
Source File: EmojiView.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void init() { if (superListenerField != null) { try { mSuperScrollListener = (ViewTreeObserver.OnScrollChangedListener) superListenerField.get(this); superListenerField.set(this, NOP); } catch (Exception e) { mSuperScrollListener = null; } } }
Example 6
Source File: ActionBarPopupWindow.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void init() { if (superListenerField != null) { try { mSuperScrollListener = (ViewTreeObserver.OnScrollChangedListener) superListenerField.get(this); superListenerField.set(this, NOP); } catch (Exception e) { mSuperScrollListener = null; } } }
Example 7
Source File: EmojiView.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void init() { if (superListenerField != null) { try { mSuperScrollListener = (ViewTreeObserver.OnScrollChangedListener) superListenerField.get(this); superListenerField.set(this, NOP); } catch (Exception e) { mSuperScrollListener = null; } } }
Example 8
Source File: ActionBarPopupWindow.java From KrGallery with GNU General Public License v2.0 | 5 votes |
private void init() { if (superListenerField != null) { try { mSuperScrollListener = (ViewTreeObserver.OnScrollChangedListener) superListenerField.get(this); superListenerField.set(this, NOP); } catch (Exception e) { mSuperScrollListener = null; } } }
Example 9
Source File: MDRootLayout.java From talk-android with MIT License | 5 votes |
private void addScrollListener(final ViewGroup vg, final boolean setForTop, final boolean setForBottom) { if ((!setForBottom && mTopOnScrollChangedListener == null || (setForBottom && mBottomOnScrollChangedListener == null))) { ViewTreeObserver.OnScrollChangedListener onScrollChangedListener = new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { boolean hasButtons = false; for (MDButton button : mButtons) { if (button != null && button.getVisibility() != View.GONE) { hasButtons = true; break; } } if (vg instanceof WebView) { invalidateDividersForWebView((WebView) vg, setForTop, setForBottom, hasButtons); } else { invalidateDividersForScrollingView(vg, setForTop, setForBottom, hasButtons); } invalidate(); } }; if (!setForBottom) { mTopOnScrollChangedListener = onScrollChangedListener; vg.getViewTreeObserver().addOnScrollChangedListener(mTopOnScrollChangedListener); } else { mBottomOnScrollChangedListener = onScrollChangedListener; vg.getViewTreeObserver().addOnScrollChangedListener(mBottomOnScrollChangedListener); } onScrollChangedListener.onScrollChanged(); } }
Example 10
Source File: ActionBarPopupWindow.java From Yahala-Messenger with MIT License | 5 votes |
private void init() { if (superListenerField != null) { try { mSuperScrollListener = (ViewTreeObserver.OnScrollChangedListener) superListenerField.get(this); superListenerField.set(this, NOP); } catch (Exception e) { mSuperScrollListener = null; } } }
Example 11
Source File: BlurDrawableActivity.java From BlurView with Apache License 2.0 | 5 votes |
public ViewTreeObserver.OnScrollChangedListener getOnScrollChangedListener() { if (mOnScrollChangedListener == null) { mOnScrollChangedListener = new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { //BlurDrawable ViewCompat.postInvalidateOnAnimation(mBlurDrawableRelativeLayout); } }; } return mOnScrollChangedListener; }
Example 12
Source File: ProductFragment.java From openshop.io-android with MIT License | 5 votes |
/** * Prepare scroll view related animations and floating wishlist button. * * @param view fragment base view. */ private void prepareScrollViewAndWishlist(View view) { final View productBackground = view.findViewById(R.id.product_background); wishlistButton = view.findViewById(R.id.product_add_to_wish_list); scrollViewListener = new ViewTreeObserver.OnScrollChangedListener() { private boolean alphaFull = false; @Override public void onScrollChanged() { int scrollY = contentScrollLayout.getScrollY(); if (productImagesRecycler != null) { if (wishlistButton.getWidth() * 2 > scrollY) { wishlistButton.setTranslationX(scrollY / 4); } else { wishlistButton.setTranslationX(wishlistButton.getWidth() / 2); } float alphaRatio; if (productImagesRecycler.getHeight() > scrollY) { productImagesRecycler.setTranslationY(scrollY / 2); alphaRatio = (float) scrollY / productImagesRecycler.getHeight(); } else { alphaRatio = 1; } // Timber.e("scrollY:" + scrollY + ". Alpha:" + alphaRatio); if (alphaFull) { if (alphaRatio <= 0.99) alphaFull = false; } else { if (alphaRatio >= 0.9) alphaFull = true; productBackground.setAlpha(alphaRatio); } } else { Timber.e("Null productImagesScroll"); } } }; }
Example 13
Source File: PEWTextView.java From ParallaxEverywhere with MIT License | 5 votes |
@Override protected void onAttachedToWindow() { super.onAttachedToWindow(); mOnScrollChangedListener = new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { applyParallax(); } }; mOnGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { heightView = (float) getHeight(); widthView = (float) getWidth(); applyParallax(); } }; ViewTreeObserver viewTreeObserver = getViewTreeObserver(); viewTreeObserver.addOnScrollChangedListener(mOnScrollChangedListener); viewTreeObserver.addOnGlobalLayoutListener(mOnGlobalLayoutListener); if (updateOnDraw && android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { onDrawListener = new ViewTreeObserver.OnDrawListener() { @Override public void onDraw() { applyParallax(); } }; viewTreeObserver.addOnDrawListener(onDrawListener); } parallaxAnimation(); }
Example 14
Source File: PEWImageView.java From ParallaxEverywhere with MIT License | 5 votes |
@Override protected void onAttachedToWindow() { super.onAttachedToWindow(); mOnScrollChangedListener = new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { applyParallax(); } }; mOnGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { heightImageView = (float) getHeight(); widthImageView = (float) getWidth(); applyParallax(); } }; ViewTreeObserver viewTreeObserver = getViewTreeObserver(); viewTreeObserver.addOnScrollChangedListener(mOnScrollChangedListener); viewTreeObserver.addOnGlobalLayoutListener(mOnGlobalLayoutListener); if (updateOnDraw && android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { onDrawListener = new ViewTreeObserver.OnDrawListener() { @Override public void onDraw() { applyParallax(); } }; viewTreeObserver.addOnDrawListener(onDrawListener); } parallaxAnimation(); }
Example 15
Source File: ActionBarPopupWindow.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void init() { if (superListenerField != null) { try { mSuperScrollListener = (ViewTreeObserver.OnScrollChangedListener) superListenerField.get(this); superListenerField.set(this, NOP); } catch (Exception e) { mSuperScrollListener = null; } } }
Example 16
Source File: ActionBarPopupWindow.java From Telegram with GNU General Public License v2.0 | 5 votes |
private void init() { if (superListenerField != null) { try { mSuperScrollListener = (ViewTreeObserver.OnScrollChangedListener) superListenerField.get(this); superListenerField.set(this, NOP); } catch (Exception e) { mSuperScrollListener = null; } } }