android - problems with objectanimator and the end listener -


i'm writing code make circle fall. problem when call method puts piece random, well, in second turn puts 2 pieces , in 3 turn 3 pieces. know problem appears when put line : game.juegamaquina(); inside end listener.

the code :

 public boolean ontouchevent(motionevent event) {         final int fila;         final int columna;          pixel_x = (int) event.getx();         pixel_y = (int) event.gety();         fila = getfila(pixel_y);         columna = getcolumna(pixel_x);          if (game.tablerolleno()) {             toast.maketext(getapplicationcontext(), r.string.fin_del_juego,                     toast.length_long).show();             return true;         }          if (game.sepuedecolocarficha(fila, columna) != true) {             toast.maketext(getapplicationcontext(), r.string.nosepuedecolocarficha,                     toast.length_short).show();             return true;         }          if(event.getaction() == motionevent.action_down) {             if(pixel_y > 200) {                 animator.start();                 animator.setintvalues(200, getpixelfromfila(getfila(pixel_y)));                 animator.addlistener(new animator.animatorlistener() {                     @override                     public void onanimationstart(animator animation) {                         // todo auto-generated method stub                         game.juegamaquina();                     }                      @override                     public void onanimationrepeat(animator animation) {                         // todo auto-generated method stub                     }                      @override                     public void onanimationend(animator animation) {                         // todo auto-generated method stub                         game.ponerjugador(fila, columna);                         if (game.comprobarcuatro(game.jugador)) {                             toast.maketext(getapplicationcontext(), "has ganado " + nombrefinal,                                     toast.length_long).show();                             if (game.fin()) {                                 fragmentodialogo dialogo = new fragmentodialogo();                                 dialogo.show(getfragmentmanager(), "alert dialog");                             }                         }                         game.juegamaquina();                     }                      @override                     public void onanimationcancel(animator animation) {                         // todo auto-generated method stub                     }                 });             }         }          return true;     } 

the solution write in onanimationend line :

animator.removealllisteners 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -