android - Parse: Retrieve all data from different table at once -
i trying data different table tried use method. however, understand loop synchronous loop didn't stop when parse fetching data. did idea how solve it? there got parse method or intent services may situation?
private void getallinformation(){ string controlname; for(int i=0; i<3;i++){ if(i==0){ controlname = appconfiguration.strevent; } else if(i==1){ controlname = appconfiguration.strstore; } else if (i==2){ controlname = appconfiguration.strpromotion; } else{ return; } parsequery<parseobject> query = parsequery.getquery(controlname); query.findinbackground(new findcallback<parseobject>() { public void done(list<parseobject> objectlist, parseexception e) { if(e!=null){ toast.maketext(getapplicationcontext(),"error loading.please try again",toast.length_long ).show(); return; } if (objectlist!= null) { toast.maketext(getapplicationcontext(),"success",toast.length_long ).show(); parseobject.pinallinbackground(objectlist); } else{ toast.maketext(getapplicationcontext(),"some data null!",toast.length_long ).show(); } } }); } // getallofflineinformation(); }
you can use locks:
object lock = new object(); parsequery<parseobject> query = parsequery.getquery(controlname); query.findinbackground(new findcallback<parseobject>() { public void done(list<parseobject> objectlist, parseexception e) { synchronized (lock) { lock.notifyall(); } if(e!=null){ toast.maketext(getapplicationcontext(),"error loading.please try again",toast.length_long ).show(); return; } if (objectlist!= null) { toast.maketext(getapplicationcontext(),"success",toast.length_long ).show(); parseobject.pinallinbackground(objectlist); } else{ toast.maketext(getapplicationcontext(),"some data null!",toast.length_long ).show(); } } }); synchronized (lock) { lock.wait(); }
Comments
Post a Comment