Android MVP: handling changes to RecyclerView -
when using recyclerview in android app, many posts , tutorials have adapter handle managing updates list, using solutions diffutil. not seem follow mvp, however, adapter exists in view layer.
so, how can presenter (or model) given responsibility of managing changes list of items displayed recyclerview, while keeping recyclerview date?
for example, recyclerview displaying list of available bluetooth devices phone can connect to, each row containing device name , rssi value. presenter wants display devices greatest least rssi value, , wants insert new devices discovered , remove ones no longer available.
source 1 , source 2 great starters i've used inplement recyclerviews using mvp, not cover data sets actively change.
i think best way use
private observablelist list;
and later
this.observablelist.addonlistchangedcallback(new observablelist.onlistchangedcallback<observablelist<***>>() { @override public void onchanged(observablelist<***> items) { } @override public void onitemrangechanged(observablelist<***> items, int positionstart, int itemcount) { } @override public void onitemrangeinserted(observablelist<***> items, int positionstart, int itemcount) { recycleradapter.notifydatasetchanged(); //for example }
Comments
Post a Comment