java - How do i set data to every single recyclerView? -
about app:
i've made app @ start receiving tcp server tcp client number of cash registers conected network, after open activity called "help
" tcp server receiving other data server device id , amount of receipts got in it.
question?
for when open activity app load number of recyclerview
equals number of cash registers sent server , apply all recyclerviews
same amount of receipts , id, have it's assign data single recyclerview
.
example
app starting, server sending number of 5 devices, i'm opening activity , asking again data server, server sending 0#17#190 (0 staying cash register active 17 receipts , 190 money in ) , have apply 1st recyclerview in list , ask server again data of 2nd..3rd... cash registers.
here mainactivity code connect server , data:
public static class connecttask extends asynctask<string, string, client> { @override protected client doinbackground(string... message) { client = new client(new client.onmessagereceived() { @override public void messagereceived(string message) { publishprogress(message); } }); client.run(); return null; } @override protected void onprogressupdate(string... values) { super.onprogressupdate(values); if(mainactivity.active){ msgserver.settextcolor(color.parsecolor("#00ff00")); msgserver.settext("online"); selfnumber = values[0]; } if(help.active){ stringtokenizer stringtokenizer = new stringtokenizer(string.valueof(values[0]),"#"); status = stringtokenizer.nexttoken(); receipt = stringtokenizer.nexttoken(); eur = stringtokenizer.nexttoken(); for(int i=0; i< integer.valueof(selfnumber); i++){ help.adapter = new selfadapter(("cassa self n°" + integer.tostring(i+1)),"eur: " + eur,"sc: " + receipt,help.img); help.selflist.add(help.adapter); help.adapterview.notifydatasetchanged(); } } } }
while in activity recall client connection with:
mainactivity.startconnection.removecallbacks(mainactivity.runnableconnection) mainactivity.startconnection.postdelayed(mainactivity.runnableconnection,5000); mainactivity.startmessage.removecallbacks(mainactivity.runnablemessage); mainactivity.startmessage.postdelayed(mainactivity.runnablemessage,5500);
if need more code i'll able post more.
please check sample example recyclerview here https://www.simplifiedcoding.net/android-recyclerview-and-cardview-tutorial/
Comments
Post a Comment