android - GUI won't update till the end of function execution -


i working on simple log in activity. have button , rotation animation. when button clicked should run animation , call login method takes few seconds finish.

the problem animation starts when login function execution finished (just before layout changed).

this tried:

 private void btnpprijava_click(object sender, eventargs e)         {             this.runonuithread(() => {             string username = edttxtkorisnicko.text;             string password = edttxtsifra.text;              var rotateaboutcorneranimation = animationutils.loadanimation(this, resource.layout.rotationanimation);             imageviewforrotation.visibility = viewstates.visible;             imageviewforrotation.startanimation(rotateaboutcorneranimation);              success = logincontroller.instance.login(username, password);                  if (success)             {                 startactivity(typeof(mainactivity));             }         }} 

i tried put these 3 lines of code in runonuithread:

    var rotateaboutcorneranimation = animationutils.loadanimation(this, resource.layout.rotationanimation);     imageviewforrotation.visibility = viewstates.visible;     imageviewforrotation.startanimation(rotateaboutcorneranimation); 

can point me doing wrong?

the solution put code in new thread , 3 lines mentioned above in runonuithread.

    private void btnpprijava_click(object sender, eventargs e)     {         new system.threading.thread(new system.threading.threadstart(() =>         {             string korisnicko = edttxtkorisnicko.text;             string sifra = edttxtsifra.text;              if (korisnicko != "" && sifra != "")             {                 bool prijavljen = false;                   var rotateaboutcorneranimation = animationutils.loadanimation(this, resource.layout.rotationanimation);                  this.runonuithread(() =>                 {                     ivrotacija.visibility = viewstates.visible;                     ivrotacija.startanimation(rotateaboutcorneranimation);                 });                   prijavljen = logincontroller.instance.prijava(korisnicko, sifra);                   if (prijavljen)                 {                     startactivity(typeof(mainactivity));                 }                 else                 {                     ivrotacija.visibility = viewstates.visible;                 }             }         })).start();     } 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -