fast swipe TouchEvent.ACTION_MOVE is missing Y coordinates and X coordinates

浪尽此生 提交于 2020-01-05 02:57:10

问题


My this question is somewhat related to my previous one that is here... I am getting X and Y values on TouchEvent.ACTION_MOVE. It works fine if I move my finger slowly but if I move my finger fast is misses out X and Y coordinates for which I have used History Events but still of no use.. I want continuous X and Y values without any jump

Sample Code

void printSamples(MotionEvent ev, RectangleParticleEmitter ps) {

    final int historySize = ev.getHistorySize();
    final int pointerCount = ev.getPointerCount();

     for (int h = 0; h < historySize; h++) {

         System.out.println("At time "+ ev.getHistoricalEventTime(h));

         for (int p = 0; p < pointerCount; p++) {


             System.out.println("****************************************");
             System.out.println("Pointer Count "+pointerCount);
             System.out.println("Pointer "+ev.getPointerId(p));
             System.out.println("Historical X "+ev.getHistoricalX(p, h));

             System.out.println("Historical Y "+ev.getHistoricalY(p, h));                
             System.out.println("****************************************");



             ps.setCenter(ev.getHistoricalX(p), ev.getHistoricalY(p));
         }
     }

     System.out.printf("At time %d:", ev.getEventTime());

     for (int p = 0; p < pointerCount; p++) {


         System.out.println("#######################################");
         System.out.println("Pointer ID "+ev.getPointerId(p));
         System.out.println("Pointer X "+ev.getX(p));
         System.out.println("Pointer Y "+ev.getY(p));
         System.out.println("#######################################");

     }
 }

LOG

 03-15 07:41:17.570: I/System.out(2877): At time 12650702
03-15 07:41:17.570: I/System.out(2877): ****************************************
03-15 07:41:17.570: I/System.out(2877): Pointer Count 1
03-15 07:41:17.570: I/System.out(2877): Pointer 0
03-15 07:41:17.570: I/System.out(2877): Historical X 21.441616
03-15 07:41:17.570: I/System.out(2877): Historical Y 416.5561
03-15 07:41:17.570: I/System.out(2877): ****************************************
03-15 07:41:17.570: I/System.out(2877): At time 12650716:#######################################
03-15 07:41:17.570: I/System.out(2877): Pointer ID 0
03-15 07:41:17.580: I/System.out(2877): Pointer X 26.729622
03-15 07:41:17.580: I/System.out(2877): Pointer Y 412.76462
03-15 07:41:17.580: I/System.out(2877): #######################################
03-15 07:41:17.600: I/System.out(2877): At time 12650725
03-15 07:41:17.600: I/System.out(2877): ****************************************
03-15 07:41:17.610: I/System.out(2877): Pointer Count 1
03-15 07:41:17.610: I/System.out(2877): Pointer 0
03-15 07:41:17.610: I/System.out(2877): Historical X 38.56469
03-15 07:41:17.610: I/System.out(2877): Historical Y 405.6872
03-15 07:41:17.610: I/System.out(2877): ****************************************
03-15 07:41:17.610: I/System.out(2877): At time 12650745:#######################################
03-15 07:41:17.610: I/System.out(2877): Pointer ID 0
03-15 07:41:17.610: I/System.out(2877): Pointer X 55.56185
03-15 07:41:17.610: I/System.out(2877): Pointer Y 393.93365
03-15 07:41:17.610: I/System.out(2877): #######################################
03-15 07:41:17.640: I/System.out(2877): At time 12650751
03-15 07:41:17.640: I/System.out(2877): ****************************************
03-15 07:41:17.640: I/System.out(2877): Pointer Count 1
03-15 07:41:17.640: I/System.out(2877): Pointer 0
03-15 07:41:17.640: I/System.out(2877): Historical X 79.86151
03-15 07:41:17.640: I/System.out(2877): Historical Y 378.89417
03-15 07:41:17.640: I/System.out(2877): ****************************************
03-15 07:41:17.640: I/System.out(2877): At time 12650760
03-15 07:41:17.640: I/System.out(2877): ****************************************
03-15 07:41:17.640: I/System.out(2877): Pointer Count 1
03-15 07:41:17.640: I/System.out(2877): Pointer 0
03-15 07:41:17.640: I/System.out(2877): Historical X 111.46365
03-15 07:41:17.640: I/System.out(2877): Historical Y 359.43127
03-15 07:41:17.640: I/System.out(2877): ****************************************
03-15 07:41:17.640: I/System.out(2877): At time 12650774:#######################################
03-15 07:41:17.640: I/System.out(2877): Pointer ID 0
03-15 07:41:17.640: I/System.out(2877): Pointer X 151.1237
03-15 07:41:17.640: I/System.out(2877): Pointer Y 336.3033
03-15 07:41:17.640: I/System.out(2877): #######################################
03-15 07:41:17.670: I/System.out(2877): At time 12650786
03-15 07:41:17.670: I/System.out(2877): ****************************************
03-15 07:41:17.670: I/System.out(2877): Pointer Count 1
03-15 07:41:17.670: I/System.out(2877): Pointer 0
03-15 07:41:17.670: I/System.out(2877): Historical X 199.09349
03-15 07:41:17.670: I/System.out(2877): Historical Y 308.4992
03-15 07:41:17.670: I/System.out(2877): ****************************************
03-15 07:41:17.670: I/System.out(2877): At time 12650794:#######################################
03-15 07:41:17.670: I/System.out(2877): Pointer ID 0
03-15 07:41:17.670: I/System.out(2877): Pointer X 251.84766
03-15 07:41:17.670: I/System.out(2877): Pointer Y 279.93683
03-15 07:41:17.670: I/System.out(2877): #######################################
03-15 07:41:17.690: I/System.out(2877): At time 12650812
03-15 07:41:17.690: I/System.out(2877): ****************************************
03-15 07:41:17.690: I/System.out(2877): Pointer Count 1
03-15 07:41:17.690: I/System.out(2877): Pointer 0
03-15 07:41:17.690: I/System.out(2877): Historical X 309.51215
03-15 07:41:17.690: I/System.out(2877): Historical Y 248.97314
03-15 07:41:17.690: I/System.out(2877): ****************************************
03-15 07:41:17.690: I/System.out(2877): At time 12650818
03-15 07:41:17.690: I/System.out(2877): ****************************************
03-15 07:41:17.690: I/System.out(2877): Pointer Count 1
03-15 07:41:17.690: I/System.out(2877): Pointer 0
03-15 07:41:17.690: I/System.out(2877): Historical X 371.33145
03-15 07:41:17.690: I/System.out(2877): Historical Y 218.51501
03-15 07:41:17.690: I/System.out(2877): ****************************************
03-15 07:41:17.690: I/System.out(2877): At time 12650832:#######################################
03-15 07:41:17.690: I/System.out(2877): Pointer ID 0
03-15 07:41:17.690: I/System.out(2877): Pointer X 431.89175
03-15 07:41:17.690: I/System.out(2877): Pointer Y 189.06793
03-15 07:41:17.690: I/System.out(2877): #######################################
03-15 07:41:17.710: I/System.out(2877): At time 12650840
03-15 07:41:17.710: I/System.out(2877): ****************************************
03-15 07:41:17.710: I/System.out(2877): Pointer Count 1
03-15 07:41:17.710: I/System.out(2877): Pointer 0
03-15 07:41:17.710: I/System.out(2877): Historical X 492.2002
03-15 07:41:17.710: I/System.out(2877): Historical Y 159.2417
03-15 07:41:17.710: I/System.out(2877): ****************************************
03-15 07:41:17.710: I/System.out(2877): At time 12650856:#######################################
03-15 07:41:17.710: I/System.out(2877): Pointer ID 0
03-15 07:41:17.710: I/System.out(2877): Pointer X 550.87195
03-15 07:41:17.710: I/System.out(2877): Pointer Y 132.32227
03-15 07:41:17.710: I/System.out(2877): #######################################
03-15 07:41:17.730: I/System.out(2877): At time 12650869:#######################################
03-15 07:41:17.730: I/System.out(2877): Pointer ID 0
03-15 07:41:17.730: I/System.out(2877): Pointer X 607.1514
03-15 07:41:17.730: I/System.out(2877): Pointer Y 106.03476
03-15 07:41:17.730: I/System.out(2877): #######################################

来源:https://stackoverflow.com/questions/9715524/fast-swipe-touchevent-action-move-is-missing-y-coordinates-and-x-coordinates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!