Java Code Examples for android.support.v7.widget.RecyclerView#AdapterDataObserver

The following examples show how to use android.support.v7.widget.RecyclerView#AdapterDataObserver . 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: RecyclerViewAdapterTest.java    From android-mvvm with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    List<ViewModel> vms = TestViewModel.dummyViewModels(INITIAL_COUNT);

    viewModelsSource = BehaviorSubject.createDefault(vms);
    testViewProvider = new TestViewProvider();
    testBinder = new TestViewModelBinder();
    subscriptionCounter = new SubscriptionCounter<>();
    sut = new RecyclerViewAdapter(viewModelsSource.compose(subscriptionCounter),
            testViewProvider, testBinder);

    notifyCallCount = 0;
    defaultObserver = new RecyclerView.AdapterDataObserver() {
        @Override
        public void onChanged() {
            notifyCallCount++;
        }
    };
    sut.registerAdapterDataObserver(defaultObserver);
}
 
Example 2
Source File: StickyHeaderAdapter.java    From iGap-Android with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * overwrite the registerAdapterDataObserver to correctly forward all events to the FastAdapter
 *
 * @param observer
 */
@Override
public void registerAdapterDataObserver(RecyclerView.AdapterDataObserver observer) {
    super.registerAdapterDataObserver(observer);
    if (mFastAdapter != null) {
        mFastAdapter.registerAdapterDataObserver(observer);
    }
}
 
Example 3
Source File: RecyclerViewAdapter.java    From android-mvvm with Apache License 2.0 5 votes vote down vote up
@Override
public void unregisterAdapterDataObserver(RecyclerView.AdapterDataObserver observer) {
    super.unregisterAdapterDataObserver(observer);
    Disposable subscription = subscriptions.remove(observer);
    if (subscription != null && !subscription.isDisposed()) {
        subscription.dispose();
    }
}
 
Example 4
Source File: TvRecyclerView.java    From TvRecyclerView with Apache License 2.0 5 votes vote down vote up
public TvAdapter() {
    mDataObserver = new RecyclerView.AdapterDataObserver() {
        @Override
        public void onChanged() {
            super.onChanged();
        }

        @Override
        public void onItemRangeInserted(final int positionStart, int itemCount) {
            registerRecoverFocus(positionStart);
            super.onItemRangeInserted(positionStart, itemCount);
        }

        @Override
        public void onItemRangeRemoved(int positionStart, int itemCount) {
            registerRecoverFocus(positionStart - itemCount);
            super.onItemRangeRemoved(positionStart, itemCount);
        }

        @Override
        public void onItemRangeMoved(int fromPosition, int toPosition, int itemCount) {
            registerRecoverFocus(toPosition);
            super.onItemRangeMoved(fromPosition, toPosition, itemCount);
        }

        @Override
        public void onItemRangeChanged(int positionStart, int itemCount) {
            registerRecoverFocus(positionStart);
            super.onItemRangeChanged(positionStart, itemCount);
        }
    };

    registerAdapterDataObserver(mDataObserver);
}
 
Example 5
Source File: RecyclerArrayAdapter.java    From BookReader with Apache License 2.0 5 votes vote down vote up
@Override
public void registerAdapterDataObserver(RecyclerView.AdapterDataObserver observer) {
    if (observer instanceof EasyRecyclerView.EasyDataObserver) {
        mObserver = observer;
    } else {
        super.registerAdapterDataObserver(observer);
    }
}
 
Example 6
Source File: BaseFilter.java    From PlayWidget with MIT License 5 votes vote down vote up
void init(@NonNull FilterableAdapter<T> adapter) throws AssertionError {
    this.adapter = adapter;
    dataSetObserver = new DataSetObserver() {
        @Override
        public void onChanged() {
            super.onChanged();
            if (!isFiltered())
                return;
            performFiltering(lastConstraint);
        }

        @Override
        public void onInvalidated() {
            super.onInvalidated();
            if (!isFiltered())
                return;
            lastResults = new FilterResults();
            lastResults.count = -1;
            lastResults.values = Collections.emptyList();
        }
    };
    adapterDataObserver = new RecyclerView.AdapterDataObserver() {
        @Override
        public void onChanged() {
            super.onChanged();
            if (!isFiltered())
                return;
            performFiltering(lastConstraint);
        }
    };
}
 
Example 7
Source File: RecyclerArrayAdapter.java    From fangzhuishushenqi with Apache License 2.0 5 votes vote down vote up
@Override
public void registerAdapterDataObserver(RecyclerView.AdapterDataObserver observer) {
    if (observer instanceof EasyRecyclerView.EasyDataObserver) {
        mObserver = observer;
    } else {
        super.registerAdapterDataObserver(observer);
    }
}
 
Example 8
Source File: BaseFilter.java    From PlayWidget with MIT License 4 votes vote down vote up
public RecyclerView.AdapterDataObserver getAdapterDataObserver() {
    return adapterDataObserver;
}
 
Example 9
Source File: RecyclerViewPagerAdapter.java    From RecyclerViewPager with Apache License 2.0 4 votes vote down vote up
@Override
public void unregisterAdapterDataObserver(RecyclerView.AdapterDataObserver observer) {
    super.unregisterAdapterDataObserver(observer);
    mAdapter.unregisterAdapterDataObserver(observer);
}
 
Example 10
Source File: BaseAdapter.java    From Expert-Android-Programming with MIT License 4 votes vote down vote up
protected void setBaseAdapter(RecyclerView.Adapter baseAdapter, boolean notifyDataSetChanged) {
  if (mBaseAdapter != null && mAdapterDataObserver != null) {
    mBaseAdapter.unregisterAdapterDataObserver(mAdapterDataObserver);
  }
  mBaseAdapter = baseAdapter;
  mAdapterDataObserver = null;
  if (mBaseAdapter != null) {
    mAdapterDataObserver = new RecyclerView.AdapterDataObserver() {
      @Override
      public void onChanged() {
        super.onChanged();
        if (isBaseAdapterEnabled()) {
          notifyDataSetChanged();
        }
      }

      @Override
      public void onItemRangeChanged(int positionStart, int itemCount) {
        super.onItemRangeChanged(positionStart, itemCount);
        if (isBaseAdapterEnabled()) {
          notifyItemRangeChanged(getItemViewPosition(positionStart), itemCount);
        }
      }

      @Override
      public void onItemRangeInserted(int positionStart, int itemCount) {
        super.onItemRangeInserted(positionStart, itemCount);
        if (isBaseAdapterEnabled()) {
          notifyItemRangeInserted(getItemViewPosition(positionStart), itemCount);
        }
      }

      @Override
      public void onItemRangeMoved(int fromPosition, int toPosition, int itemCount) {
        super.onItemRangeMoved(fromPosition, toPosition, itemCount);
        if (isBaseAdapterEnabled()) {
          notifyItemMoved(getItemViewPosition(fromPosition), getItemViewPosition(toPosition));
        }
      }

      @Override
      public void onItemRangeRemoved(int positionStart, int itemCount) {
        super.onItemRangeRemoved(positionStart, itemCount);
        if (isBaseAdapterEnabled()) {
          notifyItemRangeRemoved(getItemViewPosition(positionStart), itemCount);
        }
      }
    };
    mBaseAdapter.registerAdapterDataObserver(mAdapterDataObserver);
  }
  if (notifyDataSetChanged) {
    notifyDataSetChanged();
  }
}
 
Example 11
Source File: RecyclerViewPagerAdapter.java    From DragBoardView with Apache License 2.0 4 votes vote down vote up
@Override
public void unregisterAdapterDataObserver(RecyclerView.AdapterDataObserver observer) {
    super.unregisterAdapterDataObserver(observer);
    mAdapter.unregisterAdapterDataObserver(observer);
}
 
Example 12
Source File: RecyclerViewPagerAdapter.java    From oneHookLibraryAndroid with Apache License 2.0 4 votes vote down vote up
@Override
public void unregisterAdapterDataObserver(RecyclerView.AdapterDataObserver observer) {
    super.unregisterAdapterDataObserver(observer);
    mAdapter.unregisterAdapterDataObserver(observer);
}
 
Example 13
Source File: BindSuperAdapter.java    From LazyRecyclerAdapter with MIT License 4 votes vote down vote up
@Override
public void registerAdapterDataObserver(RecyclerView.AdapterDataObserver observer) {
    adapter.registerAdapterDataObserver(observer);
}
 
Example 14
Source File: AnimatorAdapter.java    From GankGirl with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void unregisterAdapterDataObserver(RecyclerView.AdapterDataObserver observer) {
    super.unregisterAdapterDataObserver(observer);
    mAdapter.unregisterAdapterDataObserver(observer);
}
 
Example 15
Source File: SwipeAdapterWrapper.java    From SwipeRecyclerView-master with Apache License 2.0 4 votes vote down vote up
@Override
public void unregisterAdapterDataObserver(RecyclerView.AdapterDataObserver observer) {
    super.unregisterAdapterDataObserver(observer);
}
 
Example 16
Source File: RecyclerFooterAdapterWrapper.java    From SupportSwipeLoadmore with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void registerAdapterDataObserver(RecyclerView.AdapterDataObserver observer) {
    mRealAdapter.registerAdapterDataObserver(observer);
}
 
Example 17
Source File: RecyclerFooterAdapterWrapper.java    From SupportSwipeLoadmore with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void unregisterAdapterDataObserver(RecyclerView.AdapterDataObserver observer) {
    mRealAdapter.unregisterAdapterDataObserver(observer);
}
 
Example 18
Source File: RecyclerViewAdapter.java    From android-mvvm with Apache License 2.0 4 votes vote down vote up
@Override
public void registerAdapterDataObserver(RecyclerView.AdapterDataObserver observer) {
    subscriptions.put(observer, source.subscribe());
    super.registerAdapterDataObserver(observer);
}
 
Example 19
Source File: AnimatorAdapter.java    From GankGirl with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void registerAdapterDataObserver(RecyclerView.AdapterDataObserver observer) {
    super.registerAdapterDataObserver(observer);
    mAdapter.registerAdapterDataObserver(observer);
}
 
Example 20
Source File: RecyclerViewPagerAdapter.java    From timecat with Apache License 2.0 4 votes vote down vote up
@Override
public void unregisterAdapterDataObserver(RecyclerView.AdapterDataObserver observer) {
    super.unregisterAdapterDataObserver(observer);
    mAdapter.unregisterAdapterDataObserver(observer);
}