java - AsyncTask keeps on giving output and updating my list -


this asynctask code , using populate custom listview . think wrong code .this piece of code keeps on running , don't know how many times. @ end giving me right results after many updates on textview (designation). not degrading performance of application showing multiple updates on textview before reaching result.

i getting data in desig[0] variable , have on code .

data coming azure don't worry if not azure guy . me on java part.

one more thing whole code inside getview() method.

    final string[] desig = new string[1];                  try {                     mclient = new mobileserviceclient(                             "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",                             "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",                             getcontext());                      muser = mclient.gettable(user.class);                      new asynctask<void, void, boolean>() {                         @override                         protected boolean doinbackground(void... params) {                             try {                                 final mobileservicelist<user> result =                                         muser.where().field("name").eq(currentitem.getfrom()).select("designation").execute().get();                                     int counter=                                         muser.where().select("designation").execute().get().gettotalcount();                                 log.v("counteeeerr", string.valueof(counter));                                 (user item : result) {                                     // log.i(tag, "read object id " + item.id);                                     desig[0] = item.getdesignation();                                     log.v("finally designation is", desig[0]);                                   }                                 return true;                              } catch (exception exception) {                                 exception.printstacktrace();                                 return false;                             }                         }                          @override                         protected void onpostexecute(boolean avoid) {                             super.onpostexecute(avoid);                            // gb.setdesignation(desig[0]);                          if(avoid) {                             designation.settext(desig[0]);                         }                          }                 }.execute(); 

here logcat

14 06:39:20.351  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:39:20.351  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ project head, mojokarma 07-14 06:39:22.851  26899-26899/com.mojokarma.mojokarma d/dalvikvm﹕ gc_for_alloc freed 1846k, 19% free 8126k/10028k, paused 14ms, total 14ms 07-14 06:39:22.855  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:39:22.855  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ project head, mojokarma 07-14 06:39:25.099  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:39:25.099  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ cfo , hp 07-14 06:39:27.423  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:39:27.423  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ cfo , hp 07-14 06:39:29.679  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:39:29.679  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ project head, mojokarma 07-14 06:39:31.903  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:39:31.903  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ project head, mojokarma 07-14 06:39:34.083  26899-27003/com.mojokarma.mojokarma d/dalvikvm﹕ gc_for_alloc freed 1769k, 19% free 8156k/10028k, paused 7ms, total 10ms 07-14 06:39:34.363  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:39:34.363  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ cfo , hp 07-14 06:39:36.615  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:39:36.615  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ cfo , hp 07-14 06:39:39.007  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:39:39.007  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ project head, mojokarma 07-14 06:39:41.491  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:39:41.491  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ project head, mojokarma 07-14 06:39:43.847  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:39:43.847  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ cfo , hp 07-14 06:39:46.111  26899-27003/com.mojokarma.mojokarma d/dalvikvm﹕ gc_for_alloc freed 1812k, 19% free 8160k/10028k, paused 5ms, total 7ms 07-14 06:39:46.675  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:39:46.675  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ cfo , hp 07-14 06:39:49.015  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:39:49.015  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ project head, mojokarma 07-14 06:39:51.243  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:39:51.243  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ project head, mojokarma 07-14 06:39:53.515  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:39:53.515  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ cfo , hp 07-14 06:39:55.723  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:39:55.723  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ cfo , hp 07-14 06:39:57.575  26899-27003/com.mojokarma.mojokarma d/dalvikvm﹕ gc_for_alloc freed 1818k, 19% free 8161k/10036k, paused 5ms, total 7ms 07-14 06:39:58.111  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:39:58.111  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ project head, mojokarma 07-14 06:40:00.375  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:40:00.375  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ project head, mojokarma 07-14 06:40:02.695  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:40:02.695  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ cfo , hp 07-14 06:40:05.519  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:40:05.519  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ cfo , hp 07-14 06:40:07.775  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:40:07.775  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ project head, mojokarma 07-14 06:40:09.955  26899-27003/com.mojokarma.mojokarma d/dalvikvm﹕ gc_for_alloc freed 1825k, 19% free 8154k/10036k, paused 5ms, total 6ms 07-14 06:40:10.515  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:40:10.515  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ project head, mojokarma 07-14 06:40:12.823  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:40:12.823  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ cfo , hp 07-14 06:40:15.103  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:40:15.103  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ cfo , hp 07-14 06:40:17.523  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:40:17.523  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ project head, mojokarma 07-14 06:40:20.475  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:40:20.475  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ project head, mojokarma 07-14 06:40:21.807  26899-26997/com.mojokarma.mojokarma d/dalvikvm﹕ gc_for_alloc freed 1809k, 19% free 8160k/10036k, paused 11ms, total 11ms 07-14 06:40:23.047  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:40:23.047  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ cfo , hp 07-14 06:40:25.331  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:40:25.331  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ cfo , hp 07-14 06:40:27.511  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:40:27.511  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ project head, mojokarma 07-14 06:40:29.695  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:40:29.695  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ project head, mojokarma 07-14 06:40:31.987  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:40:31.987  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ cfo , hp 07-14 06:40:33.063  26899-27003/com.mojokarma.mojokarma d/dalvikvm﹕ gc_for_alloc freed 1818k, 19% free 8151k/10036k, paused 9ms, total 9ms 07-14 06:40:34.451  26899-26997/com.mojokarma.mojokarma v/counteeeerr﹕ 4 07-14 06:40:34.451  26899-26997/com.mojokarma.mojokarma v/finally designation is﹕ cfo , hp 

expected result:-

these 4 lines , expecting :-

finally designation is﹕ project head, mojokarma

finally designation is﹕ project head, mojokarma

finally designation is﹕ cfo , hp

finally designation is﹕ cfo , hp

i getting:-

you can see , getting same results again , again .let me know if want else .

  1. never put code inside getview() of adapter.

  2. you should data fetching in fragment/activity , pass data array in adapter

  3. this scenario correct, getview() called multiple time during it's life cycle, not in our control.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -