private void unregisterListener() {
   if (mSuperScrollListener != null && mViewTreeObserver != null) {
     if (mViewTreeObserver.isAlive()) {
       mViewTreeObserver.removeOnScrollChangedListener(mSuperScrollListener);
     }
     mViewTreeObserver = null;
   }
 }
 public void tearDownListener() {
   final ViewTreeObserver viewTreeObserver = mView.getViewTreeObserver();
   if (viewTreeObserver != null) {
     viewTreeObserver.removeGlobalOnLayoutListener(this);
     viewTreeObserver.removeOnGlobalFocusChangeListener(this);
     viewTreeObserver.removeOnPreDrawListener(this);
     viewTreeObserver.removeOnScrollChangedListener(this);
     viewTreeObserver.removeOnTouchModeChangeListener(this);
   }
 }
 private void registerListener(View anchor) {
   if (mSuperScrollListener != null) {
     ViewTreeObserver vto =
         (anchor.getWindowToken() != null) ? anchor.getViewTreeObserver() : null;
     if (vto != mViewTreeObserver) {
       if (mViewTreeObserver != null && mViewTreeObserver.isAlive()) {
         mViewTreeObserver.removeOnScrollChangedListener(mSuperScrollListener);
       }
       if ((mViewTreeObserver = vto) != null) {
         vto.addOnScrollChangedListener(mSuperScrollListener);
       }
     }
   }
 }
예제 #4
0
  public void testAccessOnScrollChangedListener() throws Throwable {
    layout(R.layout.scrollview_layout);
    final ScrollView scrollView = (ScrollView) mActivity.findViewById(R.id.scroll_view);

    mViewTreeObserver = scrollView.getViewTreeObserver();

    final MockOnScrollChangedListener listener = new MockOnScrollChangedListener();
    assertFalse(listener.hasCalledOnScrollChanged());
    mViewTreeObserver.addOnScrollChangedListener(listener);

    runTestOnUiThread(
        new Runnable() {
          @Override
          public void run() {
            scrollView.fullScroll(View.FOCUS_DOWN);
          }
        });
    mInstrumentation.waitForIdleSync();
    new PollingCheck() {
      @Override
      protected boolean check() {
        return listener.hasCalledOnScrollChanged();
      }
    }.run();

    listener.reset();
    assertFalse(listener.hasCalledOnScrollChanged());

    mViewTreeObserver.removeOnScrollChangedListener(listener);
    runTestOnUiThread(
        new Runnable() {
          @Override
          public void run() {
            scrollView.fullScroll(View.FOCUS_UP);
          }
        });
    assertFalse(listener.hasCalledOnScrollChanged());
  }
package com.actionbarsherlock.internal.widget;
예제 #6
0
파일: zzgb.java 프로젝트: yusato0378/aa
 protected void zzb(ViewTreeObserver viewtreeobserver) {
   viewtreeobserver.removeOnScrollChangedListener(this);
 }