android - Refresh json thread to parse data on specific intervals -


ideally want implement

method level synchronization whole method synchronized every 1minute

not

block level synchronization set of statements synchronized

but don't know why when new runnable handler execute method @ set interval. parses unchanged json data again , again populating listview in redundant manner.

how can implement handler parse data json has changed/updated previous 60seconds, without repeating data on list view?

    private class myasynctask extends asynctask<void, void, string> {      @override     protected void onpreexecute() {         super.onpreexecute();         dialog = new progressdialog(regionlistactivity.this);         dialog.setmessage("please wait..");         dialog.setprogressstyle(progressdialog.style_spinner);         dialog.show();     }      @override     protected string doinbackground(void... params) {         string url_structure = globaldata.main_url + sessionid                 + "/user_session/?sections=app-basic&company_id="                 + companyid;         string response_structure = callwebservice                 .getresponseofurl(url_structure);         parseregionlist(response_structure);          string url_unit = globaldata.main_url + sessionid                 + "/reporting/system/unit_status/?sections&company_id="                 + companyid;         string response_unit = callwebservice.getresponseofurl(url_unit);         parseunitstatus(response_unit);         return null;      }      @suppresswarnings("null")     @override     protected void onpostexecute(string result) {         super.onpostexecute(result);         dialog.dismiss();          if (!alregions.isempty() && !alparents.isempty()) {             expandableadapter = new expandablelistadapter(                     regionlistactivity.this, alparents);             lvexpandablerl.setadapter(expandableadapter);              globaldata.alassetsglobal = hashmapassets;             globaldata.alcomponetsglobal = hashmapcomponents;          }          else {             lvexpandablerl.setvisibility(view.gone);             tvnorecordsrl.setvisibility(view.visible);         }          tvcompanynamerl.settext(globaldata.company_name);         tvactivealarmsrl.settext(globaldata.active_alarms);         tvunitsofflinerl.settext(globaldata.offline_count);          /*          * try { if(alunitnumber.size()>0 && alunitnumber != null) {          * al_unit_snumber=alunitnumber;          * lvunitsoffline.setvisibility(view.visible); adapter= new          * unitlistadapter(regionlistactivity.this, alunitnumber);          * lvunitsoffline.setadapter(adapter); } else {          * lvunitsoffline.setvisibility(view.gone);          * tvnorecordsunitlistoffline.setvisibility(view.visible); } } catch          * (exception e) { // todo auto-generated catch block          * e.printstacktrace(); }          *           * if(alunitstatus.size()>0 && alunitstatus != null)          *           * alunitstatus=(arraylist<dataunits>)getarguments()          * .getserializable(webelement.records); if(alunitstatus.size()>0 &&          * alunitstatus != null) { al_unit_snumber=alunitnumber;          * lvunitsoffline.setvisibility(view.visible); adapter= new          * unitlistadapter(regionlistactivity.this, alunitstatus);          * lvunitsoffline.setadapter(adapter); } else {          * lvunitsoffline.setvisibility(view.gone);          * tvnorecordsunitlistoffline.setvisibility(view.visible); }          */      }     new handler().postdelayed(new runnable() {         public void run() {             // call json methods here             new myasynctask().execute();         }     }, 60000);  } 


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -