android - Two separate ASyncTasks wrongly combining data when processing JSON -
i have project tablayout + viewpager scroll through 2 different fragments (one shows data happening , other shows data).
in oncreateview's of both of these call same asynctask class difference being params changing.
fetchitems asynctask = new fetchitems(getcontext(), this); asynctask.executeonexecutor(asynctask.thread_pool_executor,"someparams");
the json result processed here:
try { linkedlist<leagueitem> leagues = new linkedlist<>(); leagueitem newleague; //for every league in array (int = 0; < jsonbody.length(); i++) { newleague = new leagueitem(); //hold league games jsonobject jsonleagueinfo = jsonbody.getjsonobject(i); newleague.setleaguename(jsonleagueinfo.getstring("name")); jsonarray leaguematches = jsonleagueinfo.getjsonarray("matches"); //for every match in league for(int j = 0;j<leaguematches.length();j++){ jsonobject matchinformation = leaguematches.getjsonobject(j); jsonarray teamsarray = matchinformation.getjsonarray("teams"); matchitem currentmatch = new matchitem(); //for both teams in match for(int k=0;k<2;k++){ jsonobject teaminfo = teamsarray.getjsonobject(k); string name = teaminfo.getstring("name"); string logourl = teaminfo.getstring("logo"); jsonobject scores = teaminfo.getjsonobject("results"); string runningscore = scores.getstring("runningscore"); teamitem currentteam = new teamitem(shortname, logourl, integer.parseint(runningscore), homenum); currentmatch.addteam(currentteam); } newleague.addmatch(currentmatch); } leagues.add(newleague); } return leagues; }
i'm finding both objects returned have crossover data shouldn't there. both of parent objects correct in add correct number of league items, every league contains pretty data i'm iterating over. missing huge here? thought calling executeonexecuter getting 2 separate threads different objects.
thanks.
Comments
Post a Comment