Java Code Examples for android.support.v7.widget.RecyclerView#removeItemDecoration()

The following examples show how to use android.support.v7.widget.RecyclerView#removeItemDecoration() . 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: GroupDividerDemoActivity.java    From expandable-recyclerview with MIT License 6 votes vote down vote up
private void horizontal(RecyclerView recyclerView) {
    recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
    if (divider != null) {
        recyclerView.removeItemDecoration(divider);
    }
    divider = new NestedAdapterDivider(this, NestedAdapterDivider.HORIZONTAL);

    divider
            .setDividerBeforeFirstGroup(getDividerDrawable(R.drawable.v_divider_before_first))
            .setDividerBetweenGroup(getDividerDrawable(R.drawable.v_divider_between_group))
            .setDividerAfterLastGroup(getDividerDrawable(R.drawable.v_divider_after_last))
            .setDividerBetweenChild(getDividerDrawable(R.drawable.v_divider_between_child))
            .setDividerBetweenGroupAndChild(getDividerDrawable(R.drawable.v_divider_between_group_child))
    ;

    recyclerView.addItemDecoration(divider);

    adapter = new HDividerAdapter(shopList);
    recyclerView.setAdapter(adapter);
}
 
Example 2
Source File: GroupDividerDemoActivity.java    From expandable-recyclerview with MIT License 6 votes vote down vote up
private void vertical(RecyclerView recyclerView) {
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    if (divider != null) {
        recyclerView.removeItemDecoration(divider);
    }
    divider = new NestedAdapterDivider(this, NestedAdapterDivider.VERTICAL);

    divider
            .setDividerBeforeFirstGroup(getDividerDrawable(R.drawable.h_divider_before_first))
            .setDividerBetweenGroup(getDividerDrawable(R.drawable.h_divider_between_group))
            .setDividerAfterLastGroup(getDividerDrawable(R.drawable.h_divider_after_last))
            .setDividerBetweenChild(getDividerDrawable(R.drawable.h_divider_between_child))
            .setDividerBetweenGroupAndChild(getDividerDrawable(R.drawable.h_divider_between_group_child))
    ;

    recyclerView.addItemDecoration(divider);

    adapter = new VDividerAdapter(shopList);
    recyclerView.setAdapter(adapter);

}
 
Example 3
Source File: ShieldDisplayNodeAdapter.java    From Shield with MIT License 6 votes vote down vote up
@Override
public void onDetachedFromRecyclerView(@NonNull RecyclerView recyclerView) {
    topBottomLocationManager.setRecyclerView(null);
    if (recyclerView != null && mHorDividerDecoration != null && (!disableDecoration)) {
        recyclerView.removeItemDecoration(mHorDividerDecoration);
    }

    if (recyclerView.getLayoutManager() instanceof StaggeredGridLayoutManager) {
        recyclerView.removeItemDecoration(staggeredGridSpaceDecoration);
    }

    this.recyclerView.removeOnLayoutChangeListener(onLayoutChangeListener);
    this.recyclerView.removeOnScrollListener(onScrollListener);

    this.recyclerView = null;
    super.onDetachedFromRecyclerView(recyclerView);
}
 
Example 4
Source File: BBSSubjectTypePopupWindow.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
private void initView(Context context) {
    listView = (RecyclerView) mConvertView.findViewById(R.id.recycler_pop_bbs_subject_type_list);
    final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false);
    listView.setLayoutManager(linearLayoutManager);
    if (itemDecoration==null) {
        itemDecoration = new DividerItemDecoration(context, DividerItemDecoration.VERTICAL_LIST);
    }else {
        listView.removeItemDecoration(itemDecoration);
    }
    listView.addItemDecoration(itemDecoration);
    adapter = new CommonRecycleViewAdapter<String>(context, typeList, R.layout.item_pop_okr_detail_work_cycle_list) {
        @Override
        public void convert(CommonRecyclerViewHolder holder, String s) {
            TextView view = holder.getView(R.id.tv_item_pop_okr_detail_work_cycle_title);
            view.setText(s);
            view.setTextColor(Color.DKGRAY);
        }
    };
    adapter.setOnItemClickListener(new CommonRecycleViewAdapter.OnItemClickListener() {
        @Override
        public void onItemClick(View view, int position) {
            XLog.debug("click type item:"+position);
            if (listener!=null) {
                listener.onItemChoose(typeList.get(position));
            }
        }
    });
    listView.setAdapter(adapter);
}
 
Example 5
Source File: GsPreferenceFragmentCompat.java    From memetastic with GNU General Public License v3.0 5 votes vote down vote up
public void setDividerVisibility(boolean visible) {
    _isDividerVisible = visible;
    RecyclerView recyclerView = getListView();
    if (visible) {
        recyclerView.addItemDecoration(new DividerDecoration(getContext(), getDividerColor(), _flatPosIsPreferenceCategoryCallback));
    } else if (recyclerView.getItemDecorationCount() > 0) {
        recyclerView.removeItemDecoration(recyclerView.getItemDecorationAt(0));
    }
}
 
Example 6
Source File: SectionDAdapter.java    From Shield with MIT License 5 votes vote down vote up
@Override
public void onDetachedFromRecyclerView(RecyclerView recyclerView) {
    if (recyclerView != null && mHorDividerDecoration != null) {
        recyclerView.removeItemDecoration(mHorDividerDecoration);
    }
    super.onDetachedFromRecyclerView(recyclerView);
}
 
Example 7
Source File: GsPreferenceFragmentCompat.java    From openlauncher with Apache License 2.0 5 votes vote down vote up
public void setDividerVisibility(boolean visible) {
    _isDividerVisible = visible;
    RecyclerView recyclerView = getListView();
    if (visible) {
        recyclerView.addItemDecoration(new DividerDecoration(getContext(), getDividerColor(), _flatPosIsPreferenceCategoryCallback));
    } else if (recyclerView.getItemDecorationCount() > 0) {
        recyclerView.removeItemDecoration(recyclerView.getItemDecorationAt(0));
    }
}
 
Example 8
Source File: SearchView.java    From Material-SearchView with Apache License 2.0 5 votes vote down vote up
private void initViews(@NonNull final View layout) {
    mRoot = (RelativeLayout) layout.findViewById(R.id.root);
    mSearchOverlay = (CardView) layout.findViewById(R.id.search_overlay);
    mNavBackBtn = (ImageButton) layout.findViewById(R.id.ibtn_navigation_back);
    mCloseVoiceBtn = (ImageButton) layout.findViewById(R.id.ibtn_voice_close);
    mSearchEditText = (SearchEditText) layout.findViewById(R.id.et_search_text);
    mSearchRegion = (RelativeLayout) layout.findViewById(R.id.search_region);
    mSuggestionsRegion = (LinearLayout) layout.findViewById(R.id.suggestions_region);
    mSuggestionsView = (RecyclerView) layout.findViewById(R.id.suggestion_list);
    if (mAdapter != null) {
        mSuggestionsView.setAdapter(mAdapter);
    }
    mSuggestionsView.setLayoutManager(new VerticalLinearLayoutManager(getActivity()));

    if (mDecoration != null) {
        mSuggestionsView.removeItemDecoration(mDecoration);
        mSuggestionsView.addItemDecoration(mDecoration);
    }

    Typeface typeface = RobotoTypefaces.obtainTypeface(
            getActivity().getApplicationContext(),
            this.mTypefaceValue);
    RobotoTypefaces.setUpTypeface(mSearchEditText, typeface);

    mSearchEditText.setText(mQuery);
    mSearchEditText.setHint(mHint);
    if (mSelection == -1) {
        if (mQuery != null) {
            mSearchEditText.setSelection(mQuery.length());
        }
    } else {
        mSearchEditText.setSelection(mSelection);
    }
}
 
Example 9
Source File: GsPreferenceFragmentCompat.java    From kimai-android with MIT License 5 votes vote down vote up
public void setDividerVisibility(boolean visible) {
    _isDividerVisible = visible;
    RecyclerView recyclerView = getListView();
    if (visible) {
        recyclerView.addItemDecoration(new DividerDecoration(getContext(), getDividerColor(), _flatPosIsPreferenceCategoryCallback));
    } else if (recyclerView.getItemDecorationCount() > 0) {
        recyclerView.removeItemDecoration(recyclerView.getItemDecorationAt(0));
    }
}
 
Example 10
Source File: StickyHeaderItemDecorator.java    From StickyHeader with Apache License 2.0 4 votes vote down vote up
private void destroyCallbacks(RecyclerView recyclerView) {
    recyclerView.removeItemDecoration(this);
}
 
Example 11
Source File: MarginFragment.java    From recycler-view-margin-decoration with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings( "UnusedParameters" )
private void initInstance( View rootView ){
    int orientation = getResources().getConfiguration().orientation;
    int orientationLinear;
    int orientationGrid;
    int orientationStaggeredGrid;
    if( orientation == Configuration.ORIENTATION_PORTRAIT ){
        orientationLinear = LinearLayoutManager.VERTICAL;
        orientationGrid = GridLayoutManager.VERTICAL;
        orientationStaggeredGrid = StaggeredGridLayoutManager.VERTICAL;
    }else{
        orientationLinear = LinearLayoutManager.HORIZONTAL;
        orientationGrid = GridLayoutManager.HORIZONTAL;
        orientationStaggeredGrid = StaggeredGridLayoutManager.HORIZONTAL;
    }

    rvMargin = (RecyclerView) rootView.findViewById( R.id.rv_margin );
    int itemSpace = getSpace();
    int layout = getArguments().getInt( KEY_LAYOUT );
    if( layout == LINEAR ){
        rvMargin.removeItemDecoration( linearMargin );
        LinearLayoutManager layout1 = new LinearLayoutManager( getContext(), orientationLinear, false );
        rvMargin.setLayoutManager( layout1 );
        linearMargin = new LayoutMarginDecoration( itemSpace );
        linearMargin.setPadding( rvMargin, getMarginTop(), getMarginBottom(), getMarginLeft(), getMarginRight() );
        linearMargin.setOnClickLayoutMarginItemListener( onClickItem() );
        rvMargin.addItemDecoration( linearMargin );
    }else if( layout == GRID ){
        int gridSpan = 3;
        rvMargin.removeItemDecoration( gridMargin );
        rvMargin.setLayoutManager( new GridLayoutManager( getContext(), gridSpan, orientationGrid, false ) );
        gridMargin = new LayoutMarginDecoration( gridSpan, itemSpace );
        gridMargin.setPadding( rvMargin, getMarginTop(), getMarginBottom(), getMarginLeft(), getMarginRight() );
        gridMargin.setOnClickLayoutMarginItemListener( onClickItem() );
        rvMargin.addItemDecoration( gridMargin );
    }else if( layout == STAGGERED_GRID ){
        int stagSpan = 3;
        rvMargin.removeItemDecoration( stagMargin );
        rvMargin.setLayoutManager( new StaggeredGridLayoutManager( stagSpan, orientationStaggeredGrid ) );
        stagMargin = new LayoutMarginDecoration( stagSpan, itemSpace );
        stagMargin.setPadding( rvMargin, getMarginTop(), getMarginBottom(), getMarginLeft(), getMarginRight() );
        stagMargin.setOnClickLayoutMarginItemListener( onClickItem() );
        rvMargin.addItemDecoration( stagMargin );
    }
    rvMargin.setAdapter( new MarginAdapter( getContext() ) );
}
 
Example 12
Source File: AttachPopupWindow.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
private void initView(final Context context) {
    ImageView close = (ImageView) mConvertView.findViewById(R.id.image_pop_bbs_subject_attach_list_close);
    close.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
        }
    });

    recyclerView = (RecyclerView) mConvertView.findViewById(R.id.recycler_pop_bbs_subject_attach_list);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false);
    recyclerView.setLayoutManager(linearLayoutManager);
    if (itemDecoration==null) {
        itemDecoration = new DividerItemDecoration(context, DividerItemDecoration.VERTICAL_LIST);
    }else {
        recyclerView.removeItemDecoration(itemDecoration);
    }
    recyclerView.addItemDecoration(itemDecoration);
    adapter = new CommonRecycleViewAdapter<AttachmentItemVO>(context, attachList, R.layout.item_bbs_subject_attach_list) {
        @Override
        public void convert(CommonRecyclerViewHolder holder,
                            AttachmentItemVO bbsSubjectAttachmentData) {
            int res = FileExtensionHelper.getImageResourceByFileExtension(bbsSubjectAttachmentData.getExtension());
            holder.setText(R.id.tv_item_bbs_subject_attach_title, bbsSubjectAttachmentData.getName())
                    .setImageViewResource(R.id.image_item_bbs_subject_attach_icon, res);
            if (listener!=null) {
                AttachStatus status = listener.getAttachStatus(bbsSubjectAttachmentData.getId());
                ImageView statusImage = holder.getView(R.id.image_item_bbs_subject_attach_status);
                CircleProgressBar circle = holder.getView(R.id.image_item_bbs_subject_attach_downloading);
                if (AttachStatus.ONCLOUD.equals(status)) {
                    statusImage.setImageResource(R.mipmap.icon_bbs_attach_download);
                    statusImage.setVisibility(View.VISIBLE);
                    circle.setVisibility(View.GONE);
                }else if (AttachStatus.DOWNLOADCOMPLETED.equals(status)) {
                    statusImage.setImageResource(R.mipmap.icon_bbs_attach_open);
                    statusImage.setVisibility(View.VISIBLE);
                    circle.setVisibility(View.GONE);
                }else if (AttachStatus.DOWNLOADING.equals(status)) {
                    statusImage.setVisibility(View.GONE);
                    circle.setVisibility(View.VISIBLE);
                }
            }
        }
    };
    recyclerView.setAdapter(adapter);
    adapter.setOnItemClickListener(new CommonRecycleViewAdapter.OnItemClickListener() {
        @Override
        public void onItemClick(View view, int position) {
            AttachmentItemVO data = attachList.get(position);
            if (listener!=null) {
                AttachStatus status = listener.getAttachStatus(data.getId());
                if (AttachStatus.ONCLOUD.equals(status)) {
                    ImageView statusImage = (ImageView) view.findViewById(R.id.image_item_bbs_subject_attach_status);
                    CircleProgressBar circle = (CircleProgressBar) view.findViewById(R.id.image_item_bbs_subject_attach_downloading);
                    statusImage.setVisibility(View.GONE);
                    circle.setVisibility(View.VISIBLE);
                    listener.startDownLoadFile(data.getId());
                }else if (AttachStatus.DOWNLOADCOMPLETED.equals(status)) {
                    listener.openCompletedFile(data.getId());
                }else if (AttachStatus.DOWNLOADING.equals(status)) {
                    XToast.INSTANCE.toastShort(context, "附件下载中,请稍后再试!");
                }
            }
        }
    });

}
 
Example 13
Source File: WhatsNewAdapter.java    From fdroidclient with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onDetachedFromRecyclerView(@NonNull RecyclerView recyclerView) {
    recyclerView.removeItemDecoration(appListDecorator);
    super.onDetachedFromRecyclerView(recyclerView);
}
 
Example 14
Source File: AppListAdapter.java    From fdroidclient with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onDetachedFromRecyclerView(@NonNull RecyclerView recyclerView) {
    recyclerView.removeItemDecoration(divider);
    super.onDetachedFromRecyclerView(recyclerView);
}