private void initView() { this.scrollView.getViewTreeObserver().addOnScrollChangedListener(new OnScrollChangedListener() { int HEIGHT = RadarActivity.this.getResources().getDisplayMetrics().heightPixels; int[] area = new int[2]; public void onScrollChanged() { RadarActivity.this.nutritionLayout.getLocationOnScreen(this.area); if (this.area[1] + RadarActivity.this.nutritionLayout.getHeight() < this.HEIGHT) { RadarActivity.this.nutritionLayout.startAnim(); } RadarActivity.this.sportLayout.getLocationOnScreen(this.area); if (this.area[1] + RadarActivity.this.sportLayout.getHeight() < this.HEIGHT) { RadarActivity.this.sportLayout.startAnim(); } RadarActivity.this.ringNutrition.getLocationOnScreen(this.area); if (this.area[1] + RadarActivity.this.ringNutrition.getHeight() < this.HEIGHT) { RadarActivity.this.ringNutrition.startAnim(); } RadarActivity.this.ringHeat.getLocationInWindow(this.area); if (this.area[1] + RadarActivity.this.ringHeat.getHeight() < this.HEIGHT) { RadarActivity.this.ringHeat.startAnim(); } } }); }
private void setScrollView(){ sv.getViewTreeObserver().addOnScrollChangedListener(new OnScrollChangedListener() { @Override public void onScrollChanged() { int scrollY = sv.getScrollY(); //for verticalScrollView mHeader.setTranslationY(Math.max(-scrollY, mMinHeaderTranslation)); //header_logo --> actionbar icon float ratio = clamp(mHeader.getTranslationY() / mMinHeaderTranslation, 0.0f, 1.0f); interpolate(mHeaderLogo, getActionBarIconView(), mSmoothInterpolator.getInterpolation(ratio)); interpolate2(sp, getActionBarIconView(), mSmoothInterpolator.getInterpolation(ratio)); //actionbar title alpha //getActionBarTitleView().setAlpha(clamp(5.0F * ratio - 4.0F, 0.0F, 1.0F)); //--------------------------------- //better way thanks to @cyrilmottier setTitleAlpha(clamp(5.0F * ratio - 4.0F, 0.0F, 1.0F)); } }); }
private void init() { if (superListenerField != null) { try { mSuperScrollListener = (OnScrollChangedListener) superListenerField.get(this); superListenerField.set(this, NOP); } catch (Exception e) { mSuperScrollListener = null; } } }
private static void m2531a(PopupWindow popupWindow) { try { Field declaredField = PopupWindow.class.getDeclaredField("mAnchor"); declaredField.setAccessible(true); Field declaredField2 = PopupWindow.class.getDeclaredField("mOnScrollChangedListener"); declaredField2.setAccessible(true); declaredField2.set(popupWindow, new ba(declaredField, popupWindow, (OnScrollChangedListener) declaredField2.get(popupWindow))); } catch (Throwable e) { Log.d("AppCompatPopupWindow", "Exception while installing workaround OnScrollChangedListener", e); } }
@Override public void call(final Subscriber<? super ViewScrollChangeEvent> subscriber) { final ViewTreeObserver viewTreeObserver = view.getViewTreeObserver(); final OnScrollChangedListener listener = new OnScrollChangedListener() { int oldX, oldY; @Override public void onScrollChanged() { if (!subscriber.isUnsubscribed()) { int scrollX = view.getScrollX(); int scrollY = view.getScrollY(); subscriber.onNext(ViewScrollChangeEvent.create(view, scrollX, scrollY, oldX, oldY)); oldX = scrollX; oldY = scrollY; } } }; viewTreeObserver.addOnScrollChangedListener(listener); subscriber.add(new MainThreadSubscription() { @Override protected void onUnsubscribe() { viewTreeObserver.removeOnScrollChangedListener(listener); } }); }
public static void zza(Activity paramActivity, ViewTreeObserver.OnScrollChangedListener paramOnScrollChangedListener) { Window localWindow = paramActivity.getWindow(); if ((localWindow != null) && (localWindow.getDecorView() != null) && (localWindow.getDecorView().getViewTreeObserver() != null)) { localWindow.getDecorView().getViewTreeObserver().addOnScrollChangedListener(paramOnScrollChangedListener); } }
public static void zzb(Activity paramActivity, ViewTreeObserver.OnScrollChangedListener paramOnScrollChangedListener) { Window localWindow = paramActivity.getWindow(); if ((localWindow != null) && (localWindow.getDecorView() != null) && (localWindow.getDecorView().getViewTreeObserver() != null)) { localWindow.getDecorView().getViewTreeObserver().removeOnScrollChangedListener(paramOnScrollChangedListener); } }
/** * Constructs a new IncognitoBottomSheetContent. * @param activity The {@link Activity} displaying this bottom sheet content. */ public IncognitoBottomSheetContent(final Activity activity) { LayoutInflater inflater = LayoutInflater.from(activity); mView = inflater.inflate(R.layout.incognito_bottom_sheet_content, null); View learnMore = mView.findViewById(R.id.learn_more); learnMore.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { HelpAndFeedback.getInstance(activity).show(activity, activity.getString(R.string.help_context_incognito_learn_more), Profile.getLastUsedProfile(), null); } }); final FadingShadowView shadow = (FadingShadowView) mView.findViewById(R.id.shadow); shadow.init( ApiCompatibilityUtils.getColor(mView.getResources(), R.color.toolbar_shadow_color), FadingShadow.POSITION_TOP); mScrollView = (ScrollView) mView.findViewById(R.id.scroll_view); mScrollView.getViewTreeObserver().addOnScrollChangedListener(new OnScrollChangedListener() { @Override public void onScrollChanged() { boolean shadowVisible = mScrollView.canScrollVertically(-1); shadow.setVisibility(shadowVisible ? View.VISIBLE : View.GONE); } }); }