android - Keep menuitem animations from overlapping? -


so i'm trying animate refresh menuitem whenever webview loading , whenever activity starts. i'm trying hide forward menuitem whenever it's not necessary. following code works except whenever webview loading , hit or when try more 1 task @ time (clicking through lot of history). whenever happens refresh menuitem tends duplicate, animate, , overlap itself. happens forward menuitem. tends overlapped animated refresh icon. there way keep happening? following code code except whatever not relevant has been trimmed. can me overcome bug?

public class tideweb extends activity {     private static webview webview;     string name = null;     menuitem refresh, forward;     actionbar ab;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         intent launchingintent = getintent();         name = launchingintent.gettype().tostring();         setcontentview(r.layout.webview);         webview = (webview) findviewbyid(r.id.webview);         webview.setwebviewclient(new webviewclient() {             public boolean shouldoverrideurlloading(webview webview, string url) {                     if (refresh != null && refresh.getactionview() == null) {                         startanimation();                     }                     ab.setsubtitle("loading...");                     webview.loadurl(url);                  return true;              }         });         webview.setwebchromeclient(new webchromeclient() {             public void onprogresschanged(webview view, int progress) {                 setsupportprogress(progress * 100);                 if (progress == 100) {                     view.clearcache(true);                     stopanimation();                     ab.setsubtitle(name);                 }             }         });         string url = launchingintent.getdata().tostring();          webview.loadurl(url);     }      @override     public boolean oncreateoptionsmenu(menu menu) {         getsupportmenuinflater().inflate(r.menu.tideweb, menu);         forward = menu.finditem(r.id.forward_menu);         if (webview.isfocused() && webview.cangoforward()) {             forward.setvisible(true);         } else {             forward.setvisible(false);         }         ab.setsubtitle("loading...");         refresh = menu.finditem(r.id.refresh_menu);         if (refresh != null && refresh.getactionview() == null) {             startanimation();         }         return true;     }      @override     public boolean onoptionsitemselected(menuitem item) {         switch (item.getitemid()) {         case r.id.forward_menu:             webview.goforward();             invalidateoptionsmenu();             break;         case r.id.refresh_menu:             webview.reload();             invalidateoptionsmenu();             break;         case android.r.id.home:             intent intent = new intent(this, main.class);             intent.addflags(intent.flag_activity_clear_top);             startactivity(intent);             return true;         }         return true;     }      public void onbackpressed() {         if (webview.isfocused() && webview.cangoback()) {             webview.goback();             invalidateoptionsmenu();         } else {             super.onbackpressed();             finish();         }     }      private void startanimation() {     if (refresh != null && refresh.getactionview() == null) {             final layoutinflater inflater = (layoutinflater) getapplication()                 .getsystemservice(context.layout_inflater_service);             final relativelayout ivrefresh = (relativelayout) inflater.inflate(                 r.layout.refresh_view, null);              final animation rotation = animationutils.loadanimation(                 getapplication(), r.anim.rotate);             ivrefresh.startanimation(rotation);             refresh.setactionview(ivrefresh);         }     }      private void stopanimation() {         if (refresh != null && refresh.getactionview() != null) {             refresh.getactionview().clearanimation();             refresh.setactionview(null);         }     } } 

loading, back: loading, back

loading, , back: loading, , back

i didn't find fix this, instead of using image , animating it, set actionview progressbar. overlapping doesn't happen anymore, guess it's fixed now.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -