java - Object of syncronized list can't be changed from interface callback -


expected totally minusing.

i'm using method, makes request server in thread :

    getgeocodingresults(finaldepartureurl, new ivolleycallback() {                     @override                     public void onsuccess(jsonobject jsonobject) {                         handlevolleyresponse(jsonobject, order, 1);                         ordersfragment.syncedorderslist.get(ordersfragment.syncedorderslist.indexof(order)).setdeparturepoint(order.getdeparturepoint());                         ordersfragment.syncedorderslist.set(ordersfragment.syncedorderslist.indexof(order), order);                  }); 

onsuccess moght called in main thread, , set new value static syncronized list. here declaration :

syncedorderslist  = collections.synchronizedlist(new arraylist(orderslist));  

but when check same object after callback execution, see , new value field wasn't setted - departurepoint filed null.

what i'm doing wrong ?

method, loop through items , call backgroung operation @ each loop :

 public void addorderstomap(linkedblockingqueue<order> list) {     if (orderstodisplay != null)         clearmap();     if (list != null && !list.isempty()) {         (final order order : list) {             string finaldepartureurl = constants.url_geocoding + getaddressurlstring(constants.flag_address_departure,order);             string finaldestinationurl = constants.url_geocoding + getaddressurlstring(constants.flag_address_destination, order);             getgeocodingresults(finaldepartureurl, new ivolleycallback() {                 @override                 public void onsuccess(jsonobject jsonobject) {                     handlevolleyresponse(jsonobject, order, constants.flag_address_departure);                 }             });             getgeocodingresults(finaldestinationurl, new ivolleycallback() {                 @override                 public void onsuccess(jsonobject jsonobject) {                     handlevolleyresponse(jsonobject, order, constants.flag_address_destination);                 }             });                /*                 *  log.i(tag + " lat lng", a[0].tostring());                 *  here value of setted field null                 */             }      }  } 

handlevolleyresponse method, parse data , set new value object's field :

 private void handlevolleyresponse(jsonobject jsonobject, order order, int flag) {   /* ... here json data parsing */     switch (flag) {        case constants.flag_address_departure:       /* here point, set parsed value  object's field */              ordersfragment.syncedorderslist.get(ordersfragment.syncedorderslist.indexof(order)).setdeparturepoint(latlng);         order.setdeparturepoint(latlng);         setmarker();         break;   case constants.flag_address_destination:     /* here point, set parsed value object's field */         ordersfragment.syncedorderslist.get(ordersfragment.syncedorderslist.indexof(order)).setdestinationpoint(latlng);    order.setdestinationpoint(latlng);   setmarker();    break;  }  } 


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -