@Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.btn0:
       mRecyclerView.setAdapter(mAdapter);
       // 设置recyclerView的布局管理
       mRecyclerView.setLayoutManager(
           new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
       // 设置RecyclerView的Item间分割线
       mRecyclerView.addItemDecoration(mDivider);
       break;
     case R.id.btn1:
       mRecyclerView.removeItemDecoration(mDivider);
       mRecyclerView.setAdapter(mAdapter);
       // 设置recyclerView的竖直gridview布局管理
       mRecyclerView.setLayoutManager(new GridLayoutManager(this, 5));
       break;
     case R.id.btn2:
       mRecyclerView.removeItemDecoration(mDivider);
       mRecyclerView.setAdapter(mAdapter);
       // 设置recyclerView的水平gridview布局管理,需要确定item宽度
       mRecyclerView.setLayoutManager(
           new StaggeredGridLayoutManager(5, StaggeredGridLayoutManager.HORIZONTAL));
       break;
     case R.id.btn3:
       mRecyclerView.removeItemDecoration(mDivider);
       // 设置recyclerView瀑布流
       StaggeredAdapter adapter = new StaggeredAdapter(this, mDatas);
       mRecyclerView.setAdapter(adapter);
       mRecyclerView.setLayoutManager(
           new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
       break;
   }
 }
 public void finish() {
   if (mStarted) {
     mRecyclerView.removeItemDecoration(this);
   }
   releaseBothGlows();
   mRecyclerView = null;
   mStarted = false;
 }
 private void toggleEndOffsetVisibility() {
   if (mEndOffsetVisible) {
     mRecyclerView.removeItemDecoration(mEndOffsetItemDecoration);
     mEndOffsetVisible = false;
   } else {
     mRecyclerView.addItemDecoration(mEndOffsetItemDecoration);
     mEndOffsetVisible = true;
   }
 }
 private void toggleDividerVisibility() {
   if (mDividersVisible) {
     mRecyclerView.removeItemDecoration(mDividerItemDecoration);
     mDividersVisible = false;
   } else {
     mRecyclerView.addItemDecoration(mDividerItemDecoration);
     mDividersVisible = true;
   }
 }
 public void switchStyles() {
   if (showStyles) {
     showStyles = false;
     rv.removeItemDecoration(styleDecoration);
   } else {
     showStyles = true;
     rv.addItemDecoration(styleDecoration);
   }
   adapter.notifyDataSetChanged();
 }
 private void bindAdapter(RecyclerView recyclerView, RecordAdapter recordAdapter) {
   StickyHeadersItemDecoration stickyHeadersItemDecoration =
       new StickyHeadersBuilder()
           .setAdapter(recordAdapter)
           .setStickyHeadersAdapter(recordAdapter)
           .setRecyclerView(recyclerView)
           .build();
   recyclerView.removeItemDecoration(stickyHeadersItemDecoration);
   recyclerView.addItemDecoration(stickyHeadersItemDecoration);
 }
Exemple #7
0
  private void hideSearchSuggestions() {
    mDividerView.setVisibility(View.GONE);
    mBackgroundCoverFrameLayout.setVisibility(View.GONE);

    setUpLeftDrawable(false);

    mRecyclerView.setVisibility(View.GONE);
    mRecyclerView.removeItemDecoration(mDividerItemDecoration);

    mSearchEditText.clearFocus();
    mAreSearchSuggestionsVisible = false;
  }
  /** invalidate the gap between items. */
  public void invalidateItemGap() {
    if (null != gapDecoration) {
      listView.removeItemDecoration(gapDecoration);
    }

    ViewDecorator decorator = getViewDecorator();
    if (null == decorator) {
      Log.e(TAG, "EasyList.getViewDecorator is null");
    } else {
      boolean applyTopItem = getViewDecorator().applyItemGapForTop();
      int hPixel = getViewDecorator().getHorizontalGapPixelSize();
      int vPixel = getViewDecorator().getVerticalGapPixelSize();
      gapDecoration = new ItemGapDecorator(hPixel, vPixel, applyTopItem);
      listView.addItemDecoration(gapDecoration);
    }
  }
 public void reorderToTop() {
   if (mStarted) {
     mRecyclerView.removeItemDecoration(this);
     mRecyclerView.addItemDecoration(this);
   }
 }
 public void removeItemDecoration(RecyclerView.ItemDecoration decor) {
   recyclerView.removeItemDecoration(decor);
 }