android - how to re decorate recyclerView items below an item that is removed -
i have decorator added recyclerview, , on initial load , when orientation changes decorator works great. when remove item want redecorate based on new positions of items after delete not working.
i have tried adding new decorators, failed; now
i thought calling on recyclerview force re draw: executing code background not change.
@override public void onitemrangechanged(int positionstart, int itemcount) { super.onitemrangechanged(positionstart, itemcount); log.e(tag, "range start: " + positionstart + " count: " + itemcount ); runnable pendingremovalrunnable = new runnable() { @override public void run() { mrecyclerview.invalidateitemdecorations(); log.d(tag, "run"); } }; pendingremovalrunnable.run(); } });
this decorator code:
@override public void getitemoffsets(rect outrect, view view, recyclerview parent, recyclerview.state state) { super.getitemoffsets(outrect, view, parent, state); int pos = parent.getchildadapterposition(view); if (pos == -1) return; string vid = ((rvadapter)parent.getadapter()).getvid(pos); misinlist = playlistmanager.get(view.getcontext()).getisinplaylist(vid); mistop = playlistmanager.get(view.getcontext()).getistop(vid); misbottom = playlistmanager.get(view.getcontext()).getisbottom(vid); mregularlayout = (linearlayout) view.findviewbyid(r.id.regularlayout); if (misinlist) { if (mistop) { mregularlayout.setbackground(contextcompat .getdrawable(view.getcontext(), r.drawable.list_selector_playlist_top)); } else { if (misbottom) { mregularlayout.setbackground(contextcompat. getdrawable(view.getcontext(), r.drawable.list_selector_playlist_bottom)); } else { mregularlayout.setbackground( contextcompat.getdrawable(view.getcontext(), r.drawable.list_selector_playlist)); } } else { mregularlayout.setbackground(contextcompat. getdrawable(view.getcontext(), r.drawable.list_selector));} }
try this,
set recyclerview adapter in onresume() method of list activity. set again when changes made on recyclerview.
hope helps.
Comments
Post a Comment